Repository navigation
dsh plugin exec cannot resolve installation peers before the first profile launch #5537
Replies: 2 comments
|
Your diagnosis matches what master still does today: In the current checkout (0.1.6-alpha.1) the forwarder is The fallback you described is Workarounds on master:
One honest caveat: the behavior your proposed fix introduces (heal before forwarding every plugin command) is not present in this checkout's If you still hit a failure after the launch-first workaround, I'd be interested in the exact command, the dsh version, and the full error. |
2026-09-18 update: alpha.2 also fails after a profile launch β verified host-side patchFollowing up on this existing report, including the September 16 reply: on DSH 0.1.6-alpha.2, launching the profile first no longer makes I am attaching the complete patch and a self-contained regression below in accordance with the current Discussions-first contribution policy. This is a local verified candidate, not a claim that the official alpha.2 release is already fixed. Version and reproduction
The observed command sequence in the disposable exact-alpha.2 installation was: # Use the isolated alpha.2 dsh executable and a new disposable DSH_HOME.
# The path below denotes the locally packed Codex Connect artifact used in the test.
dsh plugin --profile web add file:/absolute/path/dsh-codex-connect-0.1.0-alpha.4.36.tgz
dsh web --help
dsh plugin --profile web exec dsh-codex-connect doctor --jsonExpected: the plugin command can resolve host-provided peers and emit its diagnostic report. An Actual: module linking fails before the doctor runs; stdout is zero bytes: The dependency is declared by the plugin and present in the host. Directly invoking the installed plugin CLI has the same failure; Why alpha.2 changes the behavior
Runtime resolution is process-local; pnpm and the plugin executable do not inherit the parent Node resolver. A preceding The older patch linked in the original post targeted the old CLI owner and prepared fallbacks for every plugin command. The new proposal below is narrower and targets the current shared package-operation owner. Proposed patchInside the existing profile manifest writer lock, prepare a profile-local projection using the existing --- a/packages/boot/plugin-manager/src/operations.ts
+++ b/packages/boot/plugin-manager/src/operations.ts
@@ -7,6 +7,7 @@
import {
DEFAULT_PROFILE_BUNDLES, initProfile, PROFILE_TEMPLATES, readProfileManifest,
resolveBundleDir, resolveProfileDir, loadOverlayPatches, type ProfileManifest,
+ healIsolatedProfileModuleFallback, loadProfileDirectory,
} from '@deepseek-ai/dsh-app-boot'
import { scrubbedParentEnv } from '@deepseek-ai/dsh-subprocess'
import type { PackageResult } from './types.ts'
@@ -181,6 +182,15 @@
initProfile(dir, template?.bundles ?? DEFAULT_PROFILE_BUNDLES)
options.onOutput?.(`dsh: initialized profile ${context.profile} at ${dir}\n`, 'stderr')
}
+ if (options.execution === 'cli' && args[0] === 'exec') {
+ options.signal?.throwIfAborted()
+ // A child process cannot inherit the running profile resolver. Use the
+ // host-owned disk projection for this explicit cross-process command,
+ // under the existing profile writer lock; ordinary boot stays runtime-only.
+ const profile = loadProfileDirectory('dsh', dir, context.installAnchor, { userLayer: false })
+ healIsolatedProfileModuleFallback({ installAnchor: context.installAnchor, profile })
+ options.signal?.throwIfAborted()
+ }
return runProfilePnpm(context, args, options)
}, options.lockWaitMs === undefined ? undefined : { waitMs: options.lockWaitMs })
}No plugin-name special case, hard-coded peer list, copied dependencies, resolver rewrite, or JSON-validation relaxation is introduced. The helper retains host package identity and profile-local package precedence. Ordinary runtime-only launches, service operations, and non- Scope: this patch handles Validation already completed
The eight upstream-command cases cover ESM/CommonJS host module identity, repeated execution, preservation of profile-owned dependencies, invalid user-patch preservation, non-exec isolation, service isolation, cancellation before spawning/projection, and explicit application-profile scope. All optional Codex Connect defaults remained false. Real provider requests: zero. The runtime/model responses are synthetic. The upstream monorepo-wide suite, other Node versions, full browser flows, and live-account behavior were not validated. Stock registry alpha.2 remains unfixed; repaired-host results are explicitly labelled and must not be mistaken for stock compatibility. For exact candidate identification (not download URLs): Complete keyless regression fixture (no Codex Connect dependency)Save this as # Original upstream module: proves the child fails on the missing host peer.
node issue211-command-regression.mjs /absolute/path/to/isolated-dsh/package.json --baseline
# Rebuild/install the proposed host patch, then verify all eight cases.
node issue211-command-regression.mjs /absolute/path/to/repaired-isolated-dsh/package.jsonThis fixture calls the real upstream /** Real upstream command/materializer regressions with owned synthetic packages and subprocesses. */
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'
import { lstat, mkdir, mkdtemp, readFile, realpath, rm, writeFile } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join, resolve } from 'node:path'
import { pathToFileURL } from 'node:url'
const fromHost = createRequire(resolve(process.argv[2]))
const { initProfile } = await import(pathToFileURL(fromHost.resolve('@deepseek-ai/dsh-app-boot')).href)
const { runPluginCommand } = await import(pathToFileURL(fromHost.resolve('@deepseek-ai/dsh-plugin-manager/operations')).href)
const baseline = process.argv[3] === '--baseline'
const root = await mkdtemp(join(tmpdir(), 'issue211-command-regression-'))
const cases = []
const peerName = 'issue211-shared-peer'
const exists = async path => { try { await lstat(path); return true } catch (e) { if (e.code === 'ENOENT') return false; throw e } }
const loadJson = async path => JSON.parse(await readFile(path, 'utf8'))
async function packageAt(parent, marker) {
const dir = join(parent, 'node_modules', peerName)
await mkdir(dir, { recursive: true })
await writeFile(join(dir, 'package.json'), JSON.stringify({ name: peerName, version: '1.0.0', type: 'module',
exports: { import: './index.mjs', require: './index.cjs' } }))
await writeFile(join(dir, 'index.mjs'), `export const marker=${JSON.stringify(marker)}; export const identity={};\n`)
await writeFile(join(dir, 'index.cjs'), `exports.marker=${JSON.stringify(marker)}; exports.identity={};\n`)
return dir
}
async function fixture(name, application = false) {
const home = join(root, name)
const installation = join(home, 'installation')
await mkdir(installation, { recursive: true })
const installAnchor = join(installation, 'package.json')
await writeFile(installAnchor, JSON.stringify({ name: 'issue211-host', version: '1.0.0', dependencies: { [peerName]: '1.0.0' } }))
const hostPeer = await packageAt(installation, 'host')
const dir = application ? join(home, 'application-profile') : join(home, 'profiles', 'test')
initProfile(dir, [])
const plugin = join(dir, 'node_modules', 'issue211-plugin')
await mkdir(plugin, { recursive: true })
await writeFile(join(plugin, 'package.json'), JSON.stringify({ name: 'issue211-plugin', version: '1.0.0', type: 'module', peerDependencies: { [peerName]: '1.0.0' } }))
const manifestPath = join(dir, 'package.json')
const manifest = await loadJson(manifestPath)
manifest.dependencies = { 'issue211-plugin': 'file:./node_modules/issue211-plugin' }
await writeFile(manifestPath, JSON.stringify(manifest))
const reportPath = join(home, 'child-result.json')
const child = join(plugin, 'child.mjs')
await writeFile(child, `import {writeFileSync} from 'node:fs';
import {createRequire} from 'node:module';
import {pathToFileURL} from 'node:url';
const req=createRequire(import.meta.url);
try {
const esm=await import(${JSON.stringify(peerName)});const cjs=req(${JSON.stringify(peerName)});
const hostEsm=await import(pathToFileURL(${JSON.stringify(join(hostPeer, 'index.mjs'))}).href);
const hostCjs=req(${JSON.stringify(join(hostPeer, 'index.cjs'))});
writeFileSync(${JSON.stringify(reportPath)},JSON.stringify({ok:true,esm:esm.marker,cjs:cjs.marker,
sameEsm:esm.identity===hostEsm.identity,sameCjs:cjs.identity===hostCjs.identity}));
} catch(error) {writeFileSync(${JSON.stringify(reportPath)},JSON.stringify({ok:false,code:error.code}));process.exitCode=42;}
`)
const context = { profile: 'test', home, installAnchor, cwd: home, ...(application ? { dir } : {}) }
const options = { command: process.execPath, args: [child], execution: 'cli', outputBytes: 1024, activateNewBundles: false,
env: { DSH_HOME: home, DSH_TELEMETRY_MODE: 'DISABLED', OTEL_SDK_DISABLED: 'true' } }
return { home, dir, hostPeer, context, options, reportPath, manifestPath }
}
try {
const first = await fixture('ordinary')
const before = await readFile(first.manifestPath, 'utf8')
const result = await runPluginCommand(first.context, ['exec'], first.options)
if (baseline) {
assert.equal(result.exitCode, 42)
assert.deepEqual(await loadJson(first.reportPath), { ok: false, code: 'ERR_MODULE_NOT_FOUND' })
cases.push('unpatched-cli-exec-fails-on-missing-peer')
} else {
assert.equal(result.exitCode, 0, 'patched cli exec must prepare peers before spawning')
assert.deepEqual(await loadJson(first.reportPath), { ok: true, esm: 'host', cjs: 'host', sameEsm: true, sameCjs: true })
assert.equal(await readFile(first.manifestPath, 'utf8'), before)
assert.equal(await exists(join(first.home, 'profiles', 'node_modules')), false, 'no shared-home fallback')
cases.push('cli-exec-keeps-host-esm-and-cjs-identity')
const projected = await realpath(join(first.dir, 'node_modules', peerName))
assert.equal(projected, await realpath(first.hostPeer))
await rm(first.reportPath)
assert.equal((await runPluginCommand(first.context, ['exec'], first.options)).exitCode, 0)
assert.equal(await realpath(join(first.dir, 'node_modules', peerName)), projected)
cases.push('repeat-exec-is-idempotent')
const local = await fixture('local-precedence')
const localPeer = await packageAt(local.dir, 'local')
assert.equal((await runPluginCommand(local.context, ['exec'], local.options)).exitCode, 0)
assert.deepEqual(await loadJson(local.reportPath), { ok: true, esm: 'local', cjs: 'local', sameEsm: false, sameCjs: false })
assert.equal((await lstat(localPeer)).isSymbolicLink(), false)
cases.push('profile-owned-package-is-not-overwritten')
const broken = await fixture('broken-user-patch')
const patch = join(broken.dir, 'cordis.patch.yml')
await writeFile(patch, ': [ deliberately invalid yaml')
assert.equal((await runPluginCommand(broken.context, ['exec'], broken.options)).exitCode, 0)
assert.equal(await readFile(patch, 'utf8'), ': [ deliberately invalid yaml')
cases.push('diagnostic-does-not-parse-or-rewrite-user-patch')
for (const [name, args, execution] of [['non-exec', ['root'], 'cli'], ['service', ['exec'], 'service']]) {
const target = await fixture(name)
assert.equal((await runPluginCommand(target.context, args, { ...target.options, execution })).exitCode, 42)
assert.equal(await exists(join(target.dir, 'node_modules', peerName)), false)
cases.push(`${name}-does-not-materialize-peers`)
}
const cancelled = await fixture('cancelled')
await assert.rejects(runPluginCommand(cancelled.context, ['exec'], { ...cancelled.options, signal: AbortSignal.abort(new Error('fixture-cancelled')) }), /fixture-cancelled/)
assert.equal(await exists(cancelled.reportPath), false)
assert.equal(await exists(join(cancelled.dir, 'node_modules', peerName)), false)
cases.push('cancelled-command-never-spawns-or-projects')
const app = await fixture('application', true)
assert.equal((await runPluginCommand(app.context, ['exec'], app.options)).exitCode, 0)
assert.equal(await exists(join(app.home, 'profiles')), false)
cases.push('explicit-application-profile-stays-scoped')
}
console.log(JSON.stringify({ status: 'passed', mode: baseline ? 'unpatched-control' : 'repaired', cases, realProviderRequests: 0 }))
} finally { await rm(root, { recursive: true, force: true }) }Would this scoped use of the existing materializer be an acceptable fix for |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
DSH 0.1.2-rc.1 can leave a freshly installed plugin command unable to resolve peer packages supplied by the DSH installation.
Reproduction
@deepseek-ai/schemasteryas a peer.dsh plugin --profile <profile> exec <bin>.The command fails with:
A profile launch first makes the same command succeed.
Cause
Profile launch prepares
$DSH_HOME/profiles/node_modules, the shared fallback containing installation-provided packages. Thedsh pluginpnpm forwarder did not prepare that fallback, so a plugin executable invoked before the first launch could not resolve its DSH-provided peers.Proposed fix
Prepare the installation module fallback after profile initialization and before forwarding every
dsh plugincommand. A self-contained built-bin regression installs a fixture with a Schemastery peer and executes it immediately.Reference implementation: franksong2702@c90ea79
Verification
All reactions