nanocoder icon indicating copy to clipboard operation
nanocoder copied to clipboard

[Bug] The system prompt says the default shell is bash on Windows, but execute_bash always runs cmd.exe

Open addyCooks opened this issue 1 week ago • 2 comments

Description

The prompt's "Default Shell" line uses process.env.SHELL first. When Nanocoder is started from Git Bash, SHELL is set, so the model is told the shell is bash. execute_bash on Windows always runs %ComSpec% (cmd.exe), so bash syntax like "$HOME" is not expanded.

Environment

  • OS: Windows 11 Home 10.0.26300 (started from Git Bash)
  • Node version: v22.22.3
  • Nanocoder version: 1.32.0 (built from main at eb7dee57)
  • Provider: Not provider-specific
  • Model: Not model-specific

Steps to Reproduce

  1. On Windows set SHELL=C:\Program Files\Git\usr\bin\bash.exe.
  2. Call buildSystemPrompt('normal', undefined, ['execute_bash']) and read the "Default Shell" line.
  3. Run bashExecutor.execute('echo "home=$HOME"').

Expected Behavior

The prompt names the shell the tool really uses (%ComSpec% / cmd.exe) on Windows.

Actual Behavior

Default Shell: C:\Program Files\Git\usr\bin\bash.exe

The command prints "home=$HOME" literally (cmd.exe does not expand it).

Additional Context

  • [x] I have searched existing issues to ensure this is not a duplicate
  • [x] I can reproduce this issue consistently
  • [x] This issue occurs with the latest version of nanocoder (main)

Suggested fix:

  • source/conversation/prompt-builder.ts:80 (getDefaultShell): on win32 return process.env.COMSPEC || 'cmd.exe' first, because that is what source/services/bash-executor.ts spawns.
  • Add a Windows test with SHELL set to a bash path.

Related: #1280 (configurable shell for execute_bash), PR #1667 (cmd.exe verbatim arguments).

addyCooks avatar Nov 23 '26 07:11 addyCooks

I'd like to pick this up. I'm on Windows with Git Bash, so I can reproduce it directly. Plan: in getDefaultShell (prompt-builder.ts), check win32 first and return COMSPEC || 'cmd.exe', which is what bash-executor.ts spawns. I'll add a test that sets SHELL to a bash path on win32 and checks that the prompt names cmd.exe, while the non-Windows behaviour stays the same.

Kidkender avatar Nov 23 '26 08:11 Kidkender

sure @Kidkender, just assigned you

akramcodez avatar Nov 24 '26 08:11 akramcodez