Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cargo sqlx prepare produces stub file -- even with 'offline' feature enabled

Tags:

rust

rust-sqlx

I am using some sqlx::query! and sqlx::query_as! and my project compiles fine. But when I run cargo sqlx prepare I get first and error:

$ cargo sqlx prepare
error: extra arguments to `rustc` can only be passed to one target, consider filtering
the package by passing, e.g., `--lib` or `--bin NAME` to specify a single target
error: `cargo check` failed with status: exit status: 101

Then when I run it with "-- --lib" I get:

$ cargo sqlx prepare -- --lib
   Compiling crate v0.1.0 (/Users/ryan/Documents/crate)
    Finished dev [unoptimized + debuginfo] target(s) in 5.78s
warning: no queries found; please ensure that the `offline` feature is enabled in sqlx
query data written to `sqlx-data.json` in the current directory; please check this into version control

I get similar output with --bin.

What am I doing wrong here?

like image 793
ryan Avatar asked Oct 11 '25 10:10

ryan


1 Answers

Same case had before, but could find usefull information in their documentation. Rather than running only cargo sqlx prepare -- --lib, first reinstall sqlx-cli, like below:

cargo install sqlx-cli && cargo sqlx prepare -- --lib
like image 162
Eziz Hudayberdiyev Avatar answered Oct 16 '25 04:10

Eziz Hudayberdiyev