sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

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

Open samuela opened this issue 2 years ago • 5 comments

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`

samuela avatar Jan 27 '24 23:01 samuela

Try cargo install sqlx-cli.

mtbc avatar Feb 08 '24 13:02 mtbc

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

samuela avatar Feb 08 '24 13:02 samuela

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.

powerseed avatar Feb 29 '24 05:02 powerseed

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 to resolver = "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 ...

Hoang-Nguyen-Huy avatar Jun 13 '24 14:06 Hoang-Nguyen-Huy

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

Ryu-Powderhorn avatar Jun 27 '24 01:06 Ryu-Powderhorn