Repository navigation
Resolve a relative install --path against the current directory - #497
Open
monsterlag wants to merge 1 commit into
Open
monsterlag wants to merge 1 commit into
monsterlag wants to merge 1 commit into
Conversation
Path(_:) returns nil for relative paths, so `xcodes install 14.0 --path Xcode.xip` silently ignored the archive and looked the version up online instead.
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.
Note
AI-generated, not reviewed by a human. This pull request was written by an AI coding agent and then checked by a separate AI review agent, which re-ran the tests described below. No human has reviewed the code. It is submitted by @monsterlag, who runs these agents. If that does not fit how you want to receive contributions, please feel free to close it.
What was wrong
xcodes install <version> --path <xip>only worked with an absolute path.Path(_:)from Path.swift returnsnilfor a relative string, soxcodes install 14.0 --path Xcode-14.0.0-Beta.2.xipdropped the archive without a warning and fell through to a normal version lookup. That lookup then failed with "Could not find Xcode version 14.0", which is the behaviour reported in the issue (and the reason the workaround there is to pass a full path).Fix
The
--pathvalue now goes through a smallxipPath(from:)helper that follows Path.swift's documented pattern for user input:Path(string) ?? Path.cwd/string. Absolute paths and~paths behave as before; relative paths resolve against the current directory. The--directoryoption has the same root cause, but #422 already covers it, so this change does not touchgetDirectory.Fixes #205
How tested
On macOS 26.6 with Swift 6.4:
Tests/xcodesTests/XipPathTests.swift. Before the fix,swift test --filter XipPathTestsfailed:test_xipPath_resolvesRelativePathAgainstCurrentDirectorygotnilfor both relative paths (Executed 3 tests, with 2 failures). After the fix it passes.swift test: all suites pass (Executed 86 tests, with 0 failures).swift build -c release --product xcodes, then in a temp directory holding an emptyXcode-1.0.0.xip, I ranxcodes install 1.0 --path Xcode-1.0.0.xip --no-superuser --directory <tmp>. It went straight to "(2/6) Unarchiving Xcode" on the local file and stopped with the expected "archive is damaged" error, because the file is empty. No online version lookup ran.