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

How to pass environment variables to the cargo run command? #310

Closed
sylvain-bouchard opened this issue Jul 1, 2024 · 3 comments
Closed

Comments

@sylvain-bouchard
Copy link

sylvain-bouchard commented Jul 1, 2024

Environment: Mac OS (Sonoma)
cargo-watch version: 8.5.2

Here is the command I am issuing:

cargo watch -w ./src -x run

For the cargo run command to work, it has to find a lib installed under:

/Library/Frameworks/GStreamer.framework/Versions/1.0/lib

I already have this export in my .zshrc file:

export DYLD_LIBRARY_PATH="/Library/Frameworks/GStreamer.framework/Versions/1.0/lib:$DYLD_LIBRARY_PATH"

It works if I issue a cargo run command directly, but not through a cargo watch -w ./src -x run. The above library path is not explored.

How do I set DYLD_LIBRARY_PATH environment variable so that is it visible to the cargo run command executed through cargo watch? Setting this variable inline to the cargo watch command does not work. I have tried many things, including the -- switch, but nothing works.

@passcod
Copy link
Member

passcod commented Jul 2, 2024

cargo watch -E WHAT=EVER -x run

@passcod
Copy link
Member

passcod commented Jul 2, 2024

Or use --env-file to use a dotenv-style file.

@sylvain-bouchard
Copy link
Author

The -E switch works. Thanks.

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

No branches or pull requests

2 participants