Skip to content

Resolve relative host paths in container cp#1749

Closed
uiharu-kazari wants to merge 1 commit into
apple:mainfrom
uiharu-kazari:fix/cp-relative-host-path
Closed

Resolve relative host paths in container cp#1749
uiharu-kazari wants to merge 1 commit into
apple:mainfrom
uiharu-kazari:fix/cp-relative-host-path

Conversation

@uiharu-kazari

Copy link
Copy Markdown

Summary

container cp <relative-path> <id>:<dest> failed with "source not found" because the local path was passed to the API server unmodified. The server runs with a working directory of /, so a relative path such as file was resolved to /file instead of the user's intended file. Only absolute host paths worked.

This resolves local paths to absolute, standardized paths before handing them to the API server: it expands a leading tilde and joins relative paths to the caller's current working directory. Applied to both the copy-in source and the copy-out destination so the two directions behave consistently.

Fixes

Fixes #1738

Testing

  • Full make all build passes; swift format lint --strict clean.
  • Verified the resolution logic: file, ./sub/x, ../x now resolve to absolute paths against the cwd, while absolute paths (/etc/hosts) and tilde paths (~/z) are preserved; the previous code left relative paths relative.

🤖 Generated with Claude Code

`container cp <relative-path> <id>:<dest>` failed with "source not found"
because the local path was passed to the API server unmodified. The server
runs with a working directory of `/`, so a relative path such as `file` was
resolved to `/file` instead of the user's intended file. Only absolute host
paths worked.

Resolve local paths to absolute, standardized paths before handing them to
the API server: expand a leading tilde and join relative paths to the
caller's current working directory. Applied to both the copy-in source and
the copy-out destination so the two directions behave consistently.

Fixes apple#1738

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JaewonHur

Copy link
Copy Markdown
Contributor

Hi! Thanks for the PR, but we already have a working for this issue: #1741. Sorry! will close now!

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.

[Bug]: Container copy doesn't expand host path correctly.

2 participants