Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tuist generate failing with 'The file “Package.resolved” couldn’t be opened because there is no such file.' #6213

Open
jessetipton opened this issue Apr 19, 2024 · 1 comment
Labels
type:bug Something isn't working

Comments

@jessetipton
Copy link

What happened?

I am encountering a bug wherein the tuist generate command fails sporadically–but often–in a Tuist project with dependencies define in Tuist/Package.swift as well as the native Xcode SPM integration.

The failure message reads:

We received an error that we couldn't handle:
    - Localized description: The file “Package.resolved” couldn’t be opened because there is no such file.
    - Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “Package.resolved” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/jesse/Desktop/TuistBugRepro/TuistBugRepro.xcworkspace/xcshareddata/swiftpm/Package.resolved, NSUnderlyingError=0x6000017d05d0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

If you think it's a legit issue, please file an issue including the reproducible steps: https://github.com/tuist/tuist/issues/new/choose
Consider creating an issue using the following link: https://github.com/tuist/tuist/issues/new/choose

When I see this error, I also notice that the .package.resolved file has been deleted.

This does not happen every time I run tuist generate, but it does happen frequently enough that I encounter it several times a day during development.

How do we reproduce it?

You can reproduce this error with this sample project: TuistBugRepro.zip

You can reproduce the error by running tuist generate repeatedly and waiting for the failure to occur. I've found this tedious, so I included a script in the project (reproduce.sh) that will repeatedly run tuist generate for you. With the script, I'm seeing the error on every 5-10 runs.

Error log

➜  TuistBugRepro git:(main) tuist generate
Loading and constructing the graph
It might take a while if the cache is empty
Using cache binaries for the following targets: 
Generating workspace TuistBugRepro.xcworkspace
Generating project TuistBugRepro
Generating project swift-log
Resolving package dependencies using xcodebuild
We received an error that we couldn't handle:
    - Localized description: The file “Package.resolved” couldn’t be opened because there is no such file.
    - Error: Error Domain=NSCocoaErrorDomain Code=260 "The file “Package.resolved” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/jesse/Desktop/TuistBugRepro/TuistBugRepro.xcworkspace/xcshareddata/swiftpm/Package.resolved, NSUnderlyingError=0x600001648540 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

If you think it's a legit issue, please file an issue including the reproducible steps: https://github.com/tuist/tuist/issues/new/choose
Consider creating an issue using the following link: https://github.com/tuist/tuist/issues/new/choose

If I run git status after receiving this error, I can see it's because the .package.resolved file has been deleted:

➜  TuistBugRepro git:(main) ✗ git status
On branch main
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	deleted:    .package.resolved

no changes added to commit (use "git add" and/or "git commit -a")

macOS version

14.2.1

Tuist version

4.9.0

Xcode version

15.3

@jessetipton jessetipton added the type:bug Something isn't working label Apr 19, 2024
@fortmarek
Copy link
Member

I took a quick look and I can reproduce the issue. The error is coming from here. That being said, I don't understand how that file can be missing when we run xcodebuild -resolvePackageDependencies right before.

You could disable package version locking as a a workaround which is fine as long as all your packages have exact versions.

We'll try to have a look at some point, but can't promise when since our recommended integration is XcodeProj-based. If you wanna take a look, that'd be much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants