Skip to content

Resolve a relative install --path against the current directory - #497

Open
monsterlag wants to merge 1 commit into
XcodesOrg:mainfrom
monsterlag:fix/issue-205-538d
Open

monsterlag wants to merge 1 commit into
XcodesOrg:mainfrom
monsterlag:fix/issue-205-538d

Conversation

@monsterlag

Copy link
Copy Markdown

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 returns nil for a relative string, so xcodes install 14.0 --path Xcode-14.0.0-Beta.2.xip dropped 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 --path value now goes through a small xipPath(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 --directory option has the same root cause, but #422 already covers it, so this change does not touch getDirectory.

Fixes #205

How tested

On macOS 26.6 with Swift 6.4:

  • Added Tests/xcodesTests/XipPathTests.swift. Before the fix, swift test --filter XipPathTests failed: test_xipPath_resolvesRelativePathAgainstCurrentDirectory got nil for 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 empty Xcode-1.0.0.xip, I ran xcodes 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.

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.
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.

install with --path does not work

1 participant