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

Forward environment variables to SPM #6193

Closed
ffittschen opened this issue Apr 15, 2024 · 2 comments
Closed

Forward environment variables to SPM #6193

ffittschen opened this issue Apr 15, 2024 · 2 comments
Labels
type:need/problem Report needs or problems you came across that are not bugs

Comments

@ffittschen
Copy link
Contributor

ffittschen commented Apr 15, 2024

What problem or need do you have?

Some Swift Packages are using environment variables in their Package.swift files to allow some form of configuration before the dependency graph is resolved. E.g. grpc-swift is reading the GRPC_NO_NIO_SSL env variable in their Package.swift. Currently, Tuist doesn't seem to forward environment variables set when invoking tuist to the internal calls to SPM.

So far I did the following:

  1. tuist clean
  2. GRPC_NO_NIO_SSL=1 tuist install
  3. tuist graph SomeTarget

But I still see it in the graph.

Screen Shot 2024-04-12 at 21 15 06@2x

Potential solution

This problem could be resolved by forwarding environment variables from tuist to SPM

macOS version

14.4.1

Tuist version

4.9.0

Xcode version

15.3

@ffittschen ffittschen added the type:need/problem Report needs or problems you came across that are not bugs label Apr 15, 2024
@fortmarek
Copy link
Member

Hey 👋

What happens if you run the same steps but instead of tuist install, you run GRPC_NO_NIO_SSL=1 swift package resolve in the Tuist directory? Does tuist graph include the dependency or not?

A reproducible sample would be appreciated if you want us to look into it. If you want to take a look, that'd be amazing – if the issue is that we're not passing the initial env variables, then I would probably take a look here

@ffittschen
Copy link
Contributor Author

Hi, I just created a reproducible sample project and it turned out that some other 3rd party dependency in my original project depend on swift-nio-ssl as well, so it probably got skipped when resolving grpc-swift, but it was resolved through the others and then the graph command picked it up from there.

To recap, GRPC_NO_NIO_SSL=1 tuist install does seem to work as expected and does forward the env variable. I can't find any mention of swift-nio-ssl in the Package.resolved file of the sample project. And it is important to pass the same environment variable when running the graph command. Otherwise it will fail with an error, as it expects NIOSSL to be present, but it wasn't resolved when running tuist install.

Sample project

tuist-install-with-env-variable.zip

Steps

  1. GRPC_NO_NIO_SSL=1 tuist install
    2a) tuist graph AppKit
    2b) GRPC_NO_NIO_SSL=1 tuist graph AppKit

2a) will fail with the error

NIOSSL is not a valid configured external dependency

2b) will succeed

Closing this issues as tuist is working as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:need/problem Report needs or problems you came across that are not bugs
Projects
None yet
Development

No branches or pull requests

2 participants