Skip to content

fix(cli): make the sandbox download path probe work with busybox realpath - #4912

Closed
viwe-monai wants to merge 1 commit into
NVIDIA:mainfrom
viwe-monai:fix/sandbox-download-busybox-realpath
Closed

viwe-monai wants to merge 1 commit into
NVIDIA:mainfrom
viwe-monai:fix/sandbox-download-busybox-realpath

Conversation

@viwe-monai

Copy link
Copy Markdown

Fixes #4909

Problem

sandbox download resolved the source path with:

pwd -P && realpath -e -- <path>

busybox realpath has no -e flag and treats -e and -- as filenames, so on Alpine-based images (including the official example image ghcr.io/anomalyco/opencode:latest) the probe errors out even for paths that exist:

/sandbox # realpath -e -- /sandbox/probe.txt
realpath: -e: No such file or directory
realpath: --: No such file or directory
/sandbox/probe.txt
/sandbox # echo 0
1

→ failed to resolve sandbox source path ... ssh probe exited with status 1. Upload and sandbox exec are unaffected; only download breaks.

Fix

The POSIX form from the issue's suggested UX, minus -- (which busybox also rejects):

p=<path> && case "$p" in /*) ;; *) p="./$p" ;; esac; pwd -P && test -e "$p" && realpath "$p"
  • Same two-line output contract (workspace root, then the symlink-resolved path) and same non-zero-exit behavior for missing paths, so the surrounding validation is untouched.
  • With -- gone, relative paths get a ./ prefix so a leading-dash name can't be parsed as an option; absolute paths can't start with -.
  • The command is factored into sandbox_source_resolve_command() so it is unit-testable.

Verification

Reproduced the exact busybox failure and fix with busybox sh + busybox realpath (old probe: realpath: -e: No such file or directory, exit 1 → new probe: exit 0, /tmp/probe-env/link/probe.txt → /tmp/probe-env/real/probe.txt).

New test ssh::tests::sandbox_source_resolve_probe_is_posix_and_resolves_symlinks runs the exact command under /bin/sh and asserts: symlink resolution (absolute + relative), a leading-dash relative name, a name with spaces, and missing path → non-zero exit with only the root line.

cargo test -p openshell-cli sandbox_source_resolve  → 1 passed
cargo test -p openshell-cli ssh::tests              → 68 passed, 0 failed

…path

`sandbox download` resolved the source path with `pwd -P && realpath -e --
<path>`. busybox realpath has no `-e` flag and treats `-e` and `--` as
filenames, so on Alpine-based images the probe printed errors and exited 1
('failed to resolve sandbox source path ... ssh probe exited with status 1')
even for paths that exist — breaking the documented upload -> run -> download
workflow on any busybox image, including ghcr.io/anomalyco/opencode:latest.

Replace the GNU-only invocation with the POSIX form `test -e <path> &&
realpath <path>`, keeping the two-line output contract (workspace root,
resolved path) and the non-zero-exit behavior for missing paths. Since `--`
is gone, relative paths are prefixed with ./ so a leading-dash name cannot be
parsed as an option. Factor the command into sandbox_source_resolve_command
so it can be tested, and cover symlink resolution, leading-dash names, names
with spaces, and the missing-path failure under /bin/sh.
@copy-pr-bot

copy-pr-bot Bot commented Oct 25, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

Copy link
Copy Markdown

Thank you for your interest in contributing to OpenShell, @viwe-monai.

This project uses a vouch system for first-time contributors. Before submitting a pull request, you need to be vouched by a maintainer.

To get vouched:

  1. Open a Vouch Request discussion.
  2. Describe what you want to change and why.
  3. Write in your own words — do not have an AI generate the request.
  4. A maintainer will comment /vouch if approved.
  5. Once vouched, open a new PR (preferred) or reopen this one after a few minutes.

See CONTRIBUTING.md for details.

@github-actions github-actions Bot closed this Oct 25, 2026
@github-actions

Copy link
Copy Markdown

Thank you for your submission! We ask that you sign our Developer Certificate of Origin before we can accept your contribution. You can sign the DCO by adding a comment below using this text:


I have read the DCO document and I hereby sign the DCO.


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the DCO Assistant Lite bot.

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.

sandbox download fails on busybox-based images: ssh probe uses GNU-only 'realpath -e'

1 participant