launchbadge / sqlx

🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, and SQLite.
Apache License 2.0
12.84k stars 1.23k forks source link

`cargo sqlx prepare` does not work despite being recommended by sqlx error message #3023

Open samuela opened 7 months ago

samuela commented 7 months ago

I forgot to set DATABASE_URL and I'm getting a bunch of errors:

error: set `DATABASE_URL` to use query macros online, or run `cargo sqlx prepare` to update the query cache

but this is misleading since cargo sqlx prepare doesn't actually work, at least not on my system:

❯ cargo sqlx prepare
error: no such command: `sqlx`

        Did you mean `fix`?

        View all installed commands with `cargo --list`
mtbc commented 6 months ago

Try cargo install sqlx-cli.

samuela commented 6 months ago

Apologies for the confusion: The issue I'm raising is that the first error message should include cargo install sqlx-cli.

powerseed commented 6 months ago

I agree with @samuela , the error message is supposed to solve the problem for users, but it doesn't, because it misses one piece of information. Please consider adding a text like To run cargo sqlx prepare, please install sqlx-cli first by running cargo install sqlx-cli.

Hoang-Nguyen-Huy commented 2 months ago

I am in the same situation as you but after i run cargo install sqlx-cli, then i run cargo sqlx prepare and my terminal threw an error warning: virtual workspace defaulting toresolver = "1"despite one or more workspace members being on edition 2021 which impliesresolver = "2" note: to keep the current resolver, specifyworkspace.resolver = "1"in the workspace root's manifest note: to use the edition 2021 resolver, specifyworkspace.resolver = "2"in the workspace root's manifest note: for more details see https://doc.rust-lang.org/cargo/reference/resolver.h tml#resolver-versions

Screen Shot 2024-06-13 at 21 36 46

If you did solve your situation successful. Can you help me plz ...

Ryu-Powderhorn commented 2 months ago

I agree with @samuela , the error message is supposed to solve the problem for users, but it doesn't, because it misses one piece of information. Please consider adding a text like To run cargo sqlx prepare, please install sqlx-cli first by running cargo install sqlx-cli.

Yep, I also just ran into this issue while trying out a simple todo-mvc demo to learn about sqlx and it was definitely a minor pain that could be fixed with a more precise error message.

It's not a huge time kill, but just having to pop a search engine for this issue to figure out how to get 'cargo sqlx prepare' to work when it doesn't come out of the box by default (and the command to install it unfortunately isn't the MOST obvious answer of 'cargo install sqlx', but instead 'cargo install sqlx-cli') would be great to avoid.

Easy on-boarding is important! Thank you for the slick lib. <3