container icon indicating copy to clipboard operation
container copied to clipboard

fix(cp): resolve relative host paths against current directory

Open adityabagchi24 opened this issue 5 months ago • 7 comments

Fixes #1738

container cp fails when the host source path is relative (e.g. container cp file foo:/root/), because NSString.standardizingPath only canonicalizes paths but does not make them absolute. The unchanged relative path is then interpreted as /file (root-absolute) by URL(fileURLWithPath:) on the runtime side.

Fixed by resolving relative paths against the current working directory before use, matching the pattern already used by container export, container image save, and container image load.

The same fix was also applied to the copy-out destination path (line 68), which had the same issue.

Type of Change

  • [x] Bug fix
  • [ ] New feature
  • [ ] Breaking change
  • [ ] Documentation update

Motivation and Context

container cp file foo:/root/ fails with "copyIn: source not found '/file'" because the relative path file is never expanded to an absolute path. Using $PWD/file works, but relative paths should work too — every other command in the codebase handles this correctly.

Testing

  • [x] Tested locally — builds and all existing tests pass
  • [ ] Added/updated tests
  • [ ] Added/updated docs

adityabagchi24 avatar Jun 17 '26 12:06 adityabagchi24

@adityabagchi24 Hi! Could you check #1743. Sorry for the duplicate PR, I just saw this one after opening that PR :(

I'm happy to merge this one, but could you add followings:

  1. print destination path on successful copy
  2. add tests for relative source and destination paths.

JaewonHur avatar Jun 17 '26 18:06 JaewonHur

@JaewonHur Thanks for the heads up on #1743. These are great additions and handles exceptions well. Please review mine as well. I've added the print output and integration tests as requested.

adityabagchi24 avatar Jun 18 '26 12:06 adityabagchi24

@JaewonHur I mistakenly forgot to add the commit signatures so should I add them?

adityabagchi24 avatar Jun 18 '26 17:06 adityabagchi24

Yeah please :) Could you sign your commits?

JaewonHur avatar Jun 18 '26 18:06 JaewonHur

@JaewonHur

1)I have signed all my commits. 2)I had accidentally signed one of crosbymichael's commits earlier, but I have removed it. Could you please verify from your end that it has been removed? 3)After making these changes, I encountered a merge conflict in .github/workflows/common.yml. The conflict was resolved after committing the changes.

Could you please review my changes when you have a chance? Thank you.

adityabagchi24 avatar Jun 19 '26 05:06 adityabagchi24

Yeah. Seems fine, but could you just roll back .github/workflows/common.yml?

Just do git checkout main .github/workflows/common.yml and commit.

JaewonHur avatar Jun 20 '26 16:06 JaewonHur

Hi, @JaewonHur, I checked out .github/workflows/common.yml from upstream/main and committed it. The workflow file now matches upstream exactly. Please check now.

adityabagchi24 avatar Jun 20 '26 17:06 adityabagchi24

Thanks. Let me merge once all tests are done.

JaewonHur avatar Jun 22 '26 16:06 JaewonHur

Code Coverage

Tier Line Coverage
Unit 33.35%
Integration 23.02%
Combined 55.52%

github-actions[bot] avatar Jun 22 '26 18:06 github-actions[bot]

@JaewonHur Thank you so much for your cooperation and patience throughout the process of merging my PR. I truly appreciate your support. Please feel free to reach out if there's ever anything I can assist you with in the future.

adityabagchi24 avatar Jun 23 '26 02:06 adityabagchi24