Skip to content

Commit ca62804

Browse files
fix: fix incompatibility with NixOS, where /bin/bash does not exist (#187)
* fix: fix incompatibility with NixOS, where /bin/bash does not exist * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 3e087f5 commit ca62804

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/swerex/deployment/modal.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ async def start(
214214
t0 = time.time()
215215
token = self._get_token()
216216
self._sandbox = modal.Sandbox.create(
217-
"/bin/bash",
217+
"/usr/bin/env",
218+
"bash",
218219
"-c",
219220
self._start_swerex_cmd(token),
220221
image=self._image,

src/swerex/runtime/local.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def _strip_control_chars(s: str) -> str:
9999
def _check_bash_command(command: str) -> None:
100100
"""Check if a bash command is valid. Raises BashIncorrectSyntaxError if it's not."""
101101
_unique_string = "SOUNIQUEEOF"
102-
cmd = f"/bin/bash -n << '{_unique_string}'\n{command}\n{_unique_string}"
102+
cmd = f"/usr/bin/env bash -n << '{_unique_string}'\n{command}\n{_unique_string}"
103103
result = subprocess.run(cmd, shell=True, capture_output=True)
104104
if result.returncode == 0:
105105
return
@@ -155,7 +155,7 @@ def _get_reset_commands(self) -> list[str]:
155155
async def start(self) -> CreateBashSessionResponse:
156156
"""Spawn the session, source any startupfiles and set the PS1."""
157157
self._shell = pexpect.spawn(
158-
"/bin/bash",
158+
"/usr/bin/env bash",
159159
encoding="utf-8",
160160
codec_errors="backslashreplace",
161161
echo=False,

tests/test_execution.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ async def test_run_in_shell_bashlex_errors(runtime_with_default_session: RemoteR
241241

242242

243243
async def test_run_shell_check_exit_code(runtime_with_default_session: RemoteRuntime):
244-
r = await runtime_with_default_session.run_in_session(A(command="/bin/bash -n <<'EOF'\necho 'hello world'\nEOF"))
244+
r = await runtime_with_default_session.run_in_session(
245+
A(command="/usr/bin/env bash -n <<'EOF'\necho 'hello world'\nEOF")
246+
)
245247
assert r.exit_code == 0
246248

247249

0 commit comments

Comments
 (0)