Skip to content

fix(developer): run shell tool under bash/sh regardless of login shell#8658

Closed
jh-block wants to merge 1 commit into
mainfrom
jhugo/shell-fix
Closed

fix(developer): run shell tool under bash/sh regardless of login shell#8658
jh-block wants to merge 1 commit into
mainfrom
jhugo/shell-fix

Conversation

@jh-block
Copy link
Copy Markdown
Collaborator

Problem

The developer extension's shell tool previously fell back to the user's $SHELL when /bin/bash wasn't present. Users with a non-POSIX login shell (fish, csh, tcsh, nu, ...) would then see failures whenever the model emitted common idioms like heredoc redirection (cat <<EOF > file), which those shells don't support.

Fixes #7348.

Fix

  • Always run commands under bash (when on PATH) or sh; GOOSE_SHELL still overrides.
  • Include the selected shell's name in the shell tool description so the model tailors syntax accordingly (and GOOSE_SHELL users get the dialect they asked for).
  • Tidy-up: use which to probe for bash instead of hard-coded paths, drop a redundant Flatpak short-circuit (the flatpak-spawn --host wrapping is unchanged), store shells as basenames so PATH resolution does the work, and factor Windows/Unix basename handling behind a shared helper.

Before, the developer extension's shell tool ran commands under the
user's $SHELL when /bin/bash wasn't present. Users with a non-POSIX
login shell (fish, csh, tcsh, nu, ...) would then see failures whenever
the model emitted common shell idioms like heredoc redirection
(`cat <<EOF > file`), since those shells don't support that syntax.

Now we always run commands under bash (when it's on PATH) or fall back
to sh. GOOSE_SHELL still overrides. The tool description also tells the
model which shell it's writing for, so it can tailor syntax (and so
GOOSE_SHELL users get the dialect they asked for).

Along the way, simplify the shell-selection logic: use `which` to
probe for bash instead of hard-coded paths, drop the redundant Flatpak
short-circuit (the `flatpak-spawn --host` wrapping is still there),
always store shells as basenames so PATH resolution does the work, and
factor the Windows/Unix basename handling behind a shared helper.

Fixes #7348

Signed-off-by: jh-block <jhugo@block.xyz>
@jh-block jh-block requested review from DOsinga and jamadeo April 20, 2026 08:34
@jh-block jh-block closed this Apr 20, 2026
@jh-block
Copy link
Copy Markdown
Collaborator Author

superseded by #8659

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e2a0832d20

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +107 to +110
if which::which("bash").is_ok() {
"bash".to_string()
} else {
std::path::Path::new(shell)
.file_name()
.and_then(|s| s.to_str())
.unwrap_or("bash")
"sh".to_string()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use absolute shell path for PATH bootstrap

Returning bare command names ("bash"/"sh") here introduces a bootstrap failure when Goose starts with a restricted PATH that does not include the shell binary locations (common in GUI/service launches): resolve_login_shell_path() calls Command::new(&shell) before the login-path recovery has run, so it can no longer start the shell to recover PATH, and later shell execution fails for the same reason. The previous absolute /bin/bash fallback avoided this class of failure. Consider keeping an absolute fallback (or storing which::which("bash")’s resolved path) for non-Flatpak execution.

Useful? React with 👍 / 👎.

@jh-block jh-block deleted the jhugo/shell-fix branch April 20, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI is incompatible to fish

1 participant