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

generate_swift_deps_for_workspace = False still requires a swift_deps.bzl file #686

Closed
luispadron opened this issue Oct 25, 2023 · 4 comments · Fixed by #698
Closed

generate_swift_deps_for_workspace = False still requires a swift_deps.bzl file #686

luispadron opened this issue Oct 25, 2023 · 4 comments · Fixed by #698
Assignees
Labels
bug Something isn't working

Comments

@luispadron
Copy link
Collaborator

Given this setup:

# Ignore the Swift build folder
# gazelle:exclude .build
swift_update_packages(
    name = "update_packages",
    gazelle = ":rules_swift_package_manager_gazelle",
    generate_swift_deps_for_workspace = False,
    package_manifest = "ThirdParty/SPM/Package.swift",
    swift_deps_index = "ThirdParty/SPM/swift_packages_index.json",
    update_bzlmod_stanzas = True,
    update_bzlmod_use_repo_names = True,
)

When I run the update packages command in Bzlmod without a ThirdParty/SPM/swift_packages.bzl, I get this error:

gazelle: loading WORKSPACE file: failed to load /Users/lpadron/Development/cash-ios/ThirdParty/SPM/swift_packages.bzl in repoRoot /Users/lpadron/Development/cash-ios: open /Users/lpadron/Development/cash-ios/ThirdParty/SPM/swift_packages.bzl: no such file or directory

If I add an empty file the update works and the file remains empty.

Should the expected behavior be that this file is no longer required and thus can be deleted? If so, we should fix this such that we dont try to write to this file if generate_swift_deps_for_workspace == False

@cgrindel
Copy link
Owner

You want to set generate_swift_deps_for_workspace to False. Here is an example.

@cgrindel
Copy link
Owner

Sorry. I missed that you had that attribute specified. 👀

@cgrindel
Copy link
Owner

I ran across this previously. I updated gazelle so that the WORKSPACE would not be updated when the -bzlmod flag is set. I failed to update swift_update_packages to set the flag. I believe that should fix the issue.

@luispadron
Copy link
Collaborator Author

I can take a look at this

@luispadron luispadron self-assigned this Oct 25, 2023
@luispadron luispadron changed the title Using with bzlmod only still requires an empty deps.bzl file generate_swift_deps_for_workspace == False still requires a swift_deps.bzl file Oct 30, 2023
@luispadron luispadron changed the title generate_swift_deps_for_workspace == False still requires a swift_deps.bzl file generate_swift_deps_for_workspace = False still requires a swift_deps.bzl file Oct 30, 2023
@cgrindel cgrindel added the bug Something isn't working label Oct 30, 2023
cgrindel pushed a commit that referenced this issue Oct 30, 2023
Fixes #686

In `swift_update_packages.bzl` we need to detect if `bzlmod` is enabled
to forward the `-bzlmod` flag to the gazelle generator.

This should stop gazelle from requiring a `swift_deps.bzl` file when
bzlmod is enabled and `generate_swift_deps_for_workspace == False`

Signed-off-by: Luis Padron <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants