I have found these related issues/pull requests
I've do some search in issues by sqlx prepare failed CARGO and just sqlx prepare and didn't find any relations with existing prepare command in just sqlx and always proposing error with redirecting to cargo sqlx invocation
Description
Title: sqlx prepare listed in help but fails with unclear error
Description:
prepare subcommand is listed in sqlx --help, but running it directly fails:
$ sqlx prepare
error: failed to get value of CARGO; prepare subcommand may only be invoked as cargo sqlx prepare
This is confusing because:
- The command is advertised in help output
- The error message is unclear — it mentions internal
CARGO variable instead of telling the user what to do
Suggested fixes (any one of):
- Remove
prepare from sqlx --help if it only works via cargo sqlx
- Improve error message: suggest using
cargo sqlx prepare explicitly
- Make
sqlx prepare work standalone by locating Cargo.toml automatically
Workaround: Use cargo sqlx prepare instead of sqlx prepare.
Reproduction steps
$ sqlx prepare
error: failed to get value of CARGO; prepare subcommand may only be invoked as cargo sqlx prepare
SQLx version
0.9.0
Enabled SQLx features
"postgres", "runtime-tokio", "tls-native-tls"
Database server and version
Postgres
Operating system
Ubuntu 24.04.4 LTS
Rust version
1.94.1
I have found these related issues/pull requests
I've do some search in issues by
sqlx prepare failed CARGOand justsqlx prepareand didn't find any relations with existing prepare command in justsqlxand always proposing error with redirecting tocargo sqlxinvocationDescription
Title:
sqlx preparelisted in help but fails with unclear errorDescription:
preparesubcommand is listed insqlx --help, but running it directly fails:This is confusing because:
CARGOvariable instead of telling the user what to doSuggested fixes (any one of):
preparefromsqlx --helpif it only works viacargo sqlxcargo sqlx prepareexplicitlysqlx preparework standalone by locatingCargo.tomlautomaticallyWorkaround: Use
cargo sqlx prepareinstead ofsqlx prepare.Reproduction steps
SQLx version
0.9.0
Enabled SQLx features
"postgres", "runtime-tokio", "tls-native-tls"
Database server and version
Postgres
Operating system
Ubuntu 24.04.4 LTS
Rust version
1.94.1