Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion standalone/sidecar/pty-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ function resolveSpawnConfig(options, runtime = {}) {
const defaultCwd = resolveDefaultCwd(platform, env, osModule);
const missingExplicitCwd = Boolean(cwd) && !directoryExists(cwd, fsModule);
const shell = explicitShell || resolveDefaultShell(platform, env);
const shellArgs = explicitArgs || resolveLoginArg(shell, platform);
// An empty array means "no override," not "no args" β€” fall through to the
// login-flag default so `~/.zprofile` runs and PATH includes Homebrew/asdf.
const shellArgs = explicitArgs && explicitArgs.length > 0
? explicitArgs
: resolveLoginArg(shell, platform);

return {
cols,
Expand Down
36 changes: 28 additions & 8 deletions standalone/sidecar/pty-core.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,27 @@ test('resolveSpawnConfig falls back to the default directory when explicit cwd i
assert.equal(config.rows, 40);
});

test('resolveSpawnConfig treats empty args array as no-override and applies -l', () => {
// Regression: detectAvailableShells returns args:[] on Unix, which used to
// suppress the -l fallback (empty array is truthy). That caused the login
// shell to skip ~/.zprofile, leaving Homebrew/asdf off PATH and producing
// "asdf_update_java_home: command not found: asdf" on every prompt.
const config = resolveSpawnConfig(
{ args: [] },
{
platform: 'darwin',
env: { SHELL: '/bin/zsh' },
osModule: {
homedir: () => '/Users/tester',
tmpdir: () => '/tmp/fallback',
},
},
);

assert.equal(config.shell, '/bin/zsh');
assert.deepEqual(config.shellArgs, ['-l']);
});

test('resolveSpawnConfig skips -l for csh', () => {
const config = resolveSpawnConfig(undefined, {
platform: 'darwin',
Expand Down Expand Up @@ -223,21 +244,20 @@ test('resolveSpawnConfig uses explicit shell with default args fallback', () =>
assert.deepEqual(config.shellArgs, ['-l']);
});

test('resolveSpawnConfig uses explicit args with empty array', () => {
test('resolveSpawnConfig honors non-empty explicit args (e.g. WSL distro flags)', () => {
const config = resolveSpawnConfig(
{ args: [] },
{ args: ['-d', 'Ubuntu'] },
{
platform: 'linux',
env: { SHELL: '/bin/bash' },
platform: 'win32',
env: {},
osModule: {
homedir: () => '/home/tester',
tmpdir: () => '/tmp/fallback',
homedir: () => 'C:\\Users\\tester',
tmpdir: () => 'C:\\Temp',
},
},
);

assert.equal(config.shell, '/bin/bash');
assert.deepEqual(config.shellArgs, []);
assert.deepEqual(config.shellArgs, ['-d', 'Ubuntu']);
});

// ── detectAvailableShells ───────────────────────────────────────────────
Expand Down
Loading