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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## [Unreleased]

- Fix(miniswen): run Bash tool commands through `bash -c` in Local, Jail, and Docker; sandbox images must include Bash.

## [1.4.0] - 2026-09-24

- miniswen: add built-in proxy and the `--allow-hosts` switch.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ lemans is a harness for benchmarking coding agents, the Ruby way:
- Ruby 3.4+ is required to run `lemans`
- Daytona account (API token) or Docker (for local sandboxes)
- Some LLM provider/proxy credentials (e.g., OpenRouter)
- Bash in the sandbox image for command execution
- iproute2 in the sandbox image, so a jailed agent keeps loopback while cut off the internet

## Getting started
Expand Down
2 changes: 1 addition & 1 deletion lib/lemans/environments/docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def exec(command, timeout: nil, env: {})
argv = [ "exec" ]
env.each { |key, value| argv += [ "--env", "#{key}=#{value}" ] }
# The in-container timeout is what actually kills the process
argv += [ container, "timeout", timeout.to_i.to_s, "sh", "-c", command ]
argv += [ container, "timeout", timeout.to_i.to_s, "bash", "-c", command ]

exit_code, output = capture("docker", *argv, timeout: timeout + EXEC_SLACK)
ExecResult.new(command:, exit_code:, output:, duration: (now - started).round(3))
Expand Down
2 changes: 1 addition & 1 deletion lib/miniswen/environment/docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def exec(command, timeout: nil, env: nil)
env&.each { |key, value| argv += [ "--env", "#{key}=#{value}" ] }
argv << id
argv += [ "timeout", timeout.ceil.to_s ] if timeout&.positive?
argv += [ "sh", "-c", command ]
argv += [ "bash", "-c", command ]

Open3.popen2e(*argv) do |stdin, pipe, wait|
stdin.close
Expand Down
2 changes: 1 addition & 1 deletion lib/miniswen/jail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def forwarder_command
def spawn_arguments(command, env)
[ command_env(env),
"nsenter", "--target", @holder.pid.to_s, "--net", "--mount", "--pid=/proc/#{@holder.pid}/ns/pid_for_children", "--wd=#{@workdir}",
"--", "setpriv", "--bounding-set=-all", "--inh-caps=-all", "--no-new-privs", "--", "sh", "-c", command ]
"--", "setpriv", "--bounding-set=-all", "--inh-caps=-all", "--no-new-privs", "--", "bash", "-c", command ]
end

def spawn_options = super.merge(unsetenv_others: true)
Expand Down
2 changes: 1 addition & 1 deletion lib/miniswen/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def exec(command, timeout: nil, env: nil)

private

def spawn_arguments(command, env) = [ env || {}, "sh", "-c", command ]
def spawn_arguments(command, env) = [ env || {}, "bash", "-c", command ]

def spawn_options = { pgroup: true }

Expand Down
2 changes: 1 addition & 1 deletion test/lemans/environments/test_docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_exec
result = environment.exec("bundle exec rake", timeout: 90, env: { "RAILS_ENV" => "test" })

argv = calls.last[:argv]
assert_equal [ "timeout", "90", "sh", "-c", "bundle exec rake" ], argv.last(5)
assert_equal [ "timeout", "90", "bash", "-c", "bundle exec rake" ], argv.last(5)
assert_includes argv.each_cons(2).to_a, [ "--env", "RAILS_ENV=test" ]
assert_equal 90 + Lemans::Environments::Docker::EXEC_SLACK, calls.last[:timeout]
assert_equal 3, result.exit_code
Expand Down
12 changes: 12 additions & 0 deletions test/miniswen/local_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ def test_the_environment_reaches_the_command
assert_equal "hi\n", result.output
end

def test_bash_syntax
result = Miniswen::Local.new.exec(<<~'BASH')
printf '%s\n' {one,two}
false | true
printf '%s\n' "${PIPESTATUS[@]}"
cat <(printf '%s\n' substitution)
BASH

assert_equal 0, result.exit_code
assert_equal "one\ntwo\n1\n0\nsubstitution\n", result.output
end

def test_a_command_that_outruns_its_budget_is_killed_and_marked
result = Miniswen::Local.new.exec("sleep 5", timeout: 0.2)

Expand Down
Loading