Skip to content

[Bug]: Building project with apalis-postgres dependency needs active database #24

Description

@maxclaey

What happened?

Hi! First of all, thanks a lot for your amazing work, I'm really looking forward to the 1.0.0 release!
I'm currently testing out the 1.0.0-beta.2 version and notice that compiling doesn't work out of the box. When running cargo build on my project, the build fails with the below error:

   Compiling apalis-postgres v1.0.0-beta.2
error: set `DATABASE_URL` to use query macros online, or run `cargo sqlx prepare` to update the query cache
  --> ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/apalis-postgres-1.0.0-beta.2/src/ack.rs:79:5
   |
79 |     sqlx::query_file!("queries/task/lock_by_id.sql", &task_id, &worker_id,)
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `$crate::sqlx_macros::expand_query` which comes from the expansion of the macro `sqlx::query_file` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `apalis-postgres` (lib) due to 1 previous error

I tried to work around it by triggering offline mode for sqlx (SQLX_OFFLINE=true cargo build), but then the following similar error pops up:

   Compiling apalis-postgres v1.0.0-beta.2
error: `SQLX_OFFLINE=true` but there is no cached data for this query, run `cargo sqlx prepare` to update the query cache or unset `SQLX_OFFLINE`
  --> ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/apalis-postgres-1.0.0-beta.2/src/ack.rs:79:5
   |
79 |     sqlx::query_file!("queries/task/lock_by_id.sql", &task_id, &worker_id,)
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the macro `$crate::sqlx_macros::expand_query` which comes from the expansion of the macro `sqlx::query_file` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `apalis-postgres` (lib) due to 1 previous error

I can try to unblock myself by running the prepare commands, but as this doesn't feel like intended devx I wanted to report it.

Thanks in advance for having a look!

Expected behavior

A cargo build works out of the box

Steps to reproduce

  1. Create a project with a dependency on apalis-postgres
  2. Try to build the project

Minimal code example

Version

1.0.0-beta.x

Environment

  • OS: Ubuntu 24.04
  • Rust version: rustc 1.91.0 (f8297e351 2025-10-28)
  • Cargo version: cargo 1.91.0 (ea2d97820 2025-10-10)

Relevant log output

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions