Skip to content

[Bug] macOS packaged node-pty doubles app.asar.unpacked path, terminal posix_spawn ENOENT #615

Description

@lyc10031

Environment

  • DSH Desktop 0.10.0 (macOS arm64, packaged app)
  • Bundled Harness 0.1.7-rc.2
  • Bundled node-pty@1.2.0-beta.15
  • This happened before installing dsh-better-sidebar or dsh-remote-ssh, and also reproduces with those plugins bypassed.

Symptom

Opening the built-in terminal reports:

Terminal error: posix_spawn failed: No such file or directory

Root cause / isolated reproduction

The packaged node-pty/lib/unixTerminal.js computes helperPath from native.dir, then applies:

helperPath = helperPath.replace('app.asar', 'app.asar.unpacked');

In this build, node-pty is already under Resources/app.asar.unpacked/node_modules/. This transforms a valid path containing app.asar.unpacked into app.asar.unpacked.unpacked.

With the same native module, /bin/bash, working directory, and environment, passing the computed path to pty.fork gives posix_spawn failed: No such file or directory; passing the actual existing prebuilds/darwin-arm64/spawn-helper path succeeds and returns a PID and FD. This isolates the error to the helper path, not the shell, cwd, or Remote SSH plugin.

// Run using macOS Node against the packaged DSH Desktop node-pty:
const path = require('node:path');
const fs = require('node:fs');
const root = '/Applications/DSH Desktop.app/Contents/Resources/app.asar.unpacked/node_modules/node-pty';
const native = require(root + '/lib/utils.js').loadNativeModule('pty');
const actual = path.resolve(root + '/lib', native.dir + '/spawn-helper');
const computed = actual.replace('app.asar', 'app.asar.unpacked')
  .replace('node_modules.asar', 'node_modules.asar.unpacked');
console.log(fs.existsSync(actual), fs.existsSync(computed)); // true false
const args = ['/bin/bash', [], ['TERM=xterm-256color', 'HOME=' + process.env.HOME,
  'PATH=/usr/bin:/bin'], process.env.HOME, 80, 24, -1, -1, true];
native.module.fork(...args, computed, () => {}); // ENOENT
// In a separate run: native.module.fork(...args, actual, () => {}) succeeds.

Expected

Opening the native terminal starts a shell. Please avoid re-rewriting app.asar.unpacked (e.g. replace only the exact app.asar/ path segment, or avoid this rewrite when the module is already unpacked), and add a packaged macOS PTY smoke test. No app files were modified during diagnosis.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions