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

Query macros panic if CARGO environment variable is not set #1021

Open
jplatte opened this issue Jan 27, 2021 · 1 comment
Open

Query macros panic if CARGO environment variable is not set #1021

jplatte opened this issue Jan 27, 2021 · 1 comment

Comments

@jplatte
Copy link
Contributor

jplatte commented Jan 27, 2021

It's not guaranteed that Rust projects are compiled with cargo, so it would probably good to replace this .expect() with a fallback:

let cargo = env::var_os("CARGO").expect("`CARGO` must be set");

CC rust-lang/rust-analyzer/issues/7462

@abonander
Copy link
Collaborator

We also require CARGO_MANIFEST_DIR

env::var("CARGO_MANIFEST_DIR").map_err(|_| "`CARGO_MANIFEST_DIR` must be set")?;

which is where we look for .env.

I've been told the working dir that proc macros are executed in is always the workspace root, but assuming that is always the case isn't really any better than requiring these env vars to be set.

We need some way to know the directory to search in for sqlx-data.json (or .sqlx/ later on) and .env. Any suggestions?

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 a pull request may close this issue.

2 participants