Skip to content

fix(env): run local commands through bash - #868

Closed
dannyward630 wants to merge 2 commits into
SWE-agent:mainfrom
dannyward630:codex/local-environment-bash-interpreter
Closed

fix(env): run local commands through bash#868
dannyward630 wants to merge 2 commits into
SWE-agent:mainfrom
dannyward630:codex/local-environment-bash-interpreter

Conversation

@dannyward630

Copy link
Copy Markdown

Summary

Fixes #829.

LocalEnvironment advertised and prompted bash commands, but executed them via subprocess.Popen(..., shell=True). On Debian/Ubuntu, Python uses /bin/sh for shell=True, and /bin/sh is commonly dash, so bash-only syntax such as process substitution fails even though the tool is named bash.

This changes local command execution to use a configurable interpreter, defaulting to bash -lc, matching the Docker backend's default interpreter behavior more closely while preserving the existing timeout/process-group handling.

Validation

  • .venv/bin/python -m pytest tests/environments/test_local.py
  • .venv/bin/ruff check src/minisweagent/environments/local.py tests/environments/test_local.py
  • git diff --check

@dannyward630
dannyward630 marked this pull request as ready for review June 18, 2026 23:03
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the LocalEnvironment “bash” tool to actually execute commands with Bash (instead of /bin/sh via shell=True, which is often dash on Debian/Ubuntu), aligning behavior more closely with the Docker environment and enabling bash-only syntax like process substitution.

Changes:

  • Add a configurable interpreter to LocalEnvironmentConfig, defaulting to ["bash", "-lc"].
  • Switch local command execution from subprocess.Popen(..., shell=True) to invoking the configured interpreter directly.
  • Add test coverage ensuring bash-only syntax works by default (skipped on Windows).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/minisweagent/environments/local.py Introduces a configurable interpreter (default bash -lc) and runs commands through it instead of /bin/sh via shell=True.
tests/environments/test_local.py Extends config default assertions and adds a bash-only syntax test to prevent regressions.

@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/minisweagent/environments/local.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dannyward630

Copy link
Copy Markdown
Author

Closing in favor of #870, which implements the maintainer's shell-agnostic prompt/tool-description approach for #829.

@klieret

klieret commented Jun 19, 2026

Copy link
Copy Markdown
Member

still thinking about this, your PR is also very clean (thx!), I'm just still wondering if just prefixing bash -lc to the Popen is fully equivalent or if there's any edge cases (I guess popen handles all the escaping etc, but is there more that could break)

@klieret

klieret commented Jun 19, 2026

Copy link
Copy Markdown
Member

The one thing I don't like with this, is that this will probably not work out of the box on some systems...

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.

Bash tool launches Dash on Ubuntu environments

3 participants