Resolve relative host paths in container cp#1749
Closed
uiharu-kazari wants to merge 1 commit into
Closed
Conversation
`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>
Contributor
|
Hi! Thanks for the PR, but we already have a working for this issue: #1741. Sorry! will close now! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 asfilewas resolved to/fileinstead 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
make allbuild passes;swift format lint --strictclean.file,./sub/x,../xnow 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