-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[sqlx-cli] prepare unable to find queries if cargo target-dir is set in config.toml #1706
Comments
I've previously run into this as well. This would require a call to |
Hmm, it would be nice to handle it if cargo is available though, or at least give a better error indicating what is wrong. |
Hm yeah, doing it when cargo is available sounds like a good idea. Then the repeated |
I can't say when/if I will have time to pick it up but if you write some instructions I will try to find some time for it 👍 |
Okay so what I would do:
|
I did an attempt at fixing this but it seems to me that it boils down to an issue in the rustc cli (I can't set out-dir in our specific case). I did ask about it on zulip but haven't received a response yet. Created a draft PR here with a, in my opinion, quite ugly workaround. Namely moving the files. I did verify that on Linux it works with and without a custom target directory. |
Here is an example of the error from my debugging session. [sqlx-cli/src/prepare.rs:154] Command::new(&cargo).arg("rustc").args(cargo_args).arg("--").arg("--out-dir").arg(format!("{}",
metadata.target_directory.join("sqlx").display())).arg("--emit").arg("dep-info,metadata").arg("--cfg").arg(format!("__sqlx_recompile_trigger=\"{}\"",
SystemTime :: UNIX_EPOCH.elapsed()
?.as_millis())).env("SQLX_OFFLINE",
"false").env("DATABASE_URL", url) = "/home/sedrik/.cargo/bin/cargo" "rustc" "--lib" "--all-features" "--" "--out-dir" "/home/sedrik/.cargo/target/sqlx" "--emit" "dep-info,metadata" "--cfg" "__sqlx_recompile_trigger=\"1655408768682\""
Compiling data_collection_backend v2.6.1 (/home/sedrik/thefit/data-collection-backend)
error: Option 'out-dir' given more than once |
I generally use the following ~/.cargo/config.toml
But having this setup and a lib crate with binaries in it caused
cargo sqlx prepare -- --lib --all-features
to fail to find any new queries even if I did acargo clean
and removed the target directory. I also noted that sqlx's outputs files into the projects target directory but removing those as well did not help.Removing the config for target-dir made prepare work again.
The text was updated successfully, but these errors were encountered: