Skip to content
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

[Bug]: Can't use sqlx compile time macros #1509

Open
1 task done
dev-ardi opened this issue Jan 7, 2024 · 2 comments
Open
1 task done

[Bug]: Can't use sqlx compile time macros #1509

dev-ardi opened this issue Jan 7, 2024 · 2 comments
Labels
S-Triage Awaiting decision for what to do T-Bug Something isn't working

Comments

@dev-ardi
Copy link

dev-ardi commented Jan 7, 2024

What happened?

Sqlx refuses to build because it can't connect to a database and shuttle refuses to provision a database because the code doesn't build!

For people experiencing this issue
My workaround is to delete all code except

async fn axum(#[shuttle_shared_db::Postgres] pool: PgPool) -> shuttle_axum::ShuttleAxum {
    sqlx::migrate!().run(&pool).await.expect("Migration failed");

and then git reset --hard

Version

cargo-shuttle 0.35.2

Which operating system(s) are you seeing the problem on?

Linux

Which CPU architectures are you seeing the problem on?

x86_64

Relevant log output

No response

Duplicate declaration

  • I have searched the issues and there are none like this.
@dev-ardi dev-ardi added S-Triage Awaiting decision for what to do T-Bug Something isn't working labels Jan 7, 2024
@oddgrd
Copy link
Contributor

oddgrd commented Jan 9, 2024

Hey @dev-ardi! This is due to using the sqlx query macros that run compile-time checks against a database. I believe you can resolve this by using sqlx offline mode. Let me know how it goes, and if it works out we'll update our docs.

@SymenTimmermans
Copy link

I experienced the same thing, although while using Actix-web. I resolved it by using the hello world example from the repo, with the shuttle-annotations in the main function kept in place. After it built, I could revert back, and it worked fine from there.

I don't run the docker systemd service by default, so it might not have been running when I first tried to run the project. I started the service soon afterwards, but I had to resort to rewriting main.rs to get the project to build again.

@jonaro00 jonaro00 changed the title [Bug]: Error with SQLx: Can't provision a database with shuttle [Bug]: Can't use sqlx compile time macros Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-Triage Awaiting decision for what to do T-Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants