0

I'm trying to run cargo fix on a project that uses slqx and am getting the following error:

error: proc macro panicked
  --> src/twitter/domain/user.rs:54:5
   |
54 | /     sqlx::query!(
55 | |         r#"
56 | |         INSERT INTO users
57 | |             (id, created_at,
...  |
84 | |         user["public_metrics"]["tweet_count"].as_i64(),
85 | |     )
   | |_____^
   |
   = help: message: Lazy instance has previously been poisoned
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

...for every instance of sqlx macro I have in my code. The weird thing is it used to work just fine, but for some reason doesn't anymore.

The only mention of the error on Google that I found is here, but I don't think it's relevant.

What might be wrong?

ilmoi
  • 1,994
  • 2
  • 21
  • 45
  • Are there any other errors besides this one? That error comes from the [`once_cell`](https://crates.io/crates/once_cell) crate when accessing a `Lazy` whose initialisation function panicked; it almost certainly is in respect of [this `Lazy`](https://docs.rs/sqlx-macros/0.5.5/src/sqlx_macros/query/mod.rs.html#37-101) that is used when expanding the given `sql::query` macro invocation. There are a few places where that `Lazy`'s initialisation function can panic, but you should see some other errors in respect of it? – eggyal Jun 16 '21 at 09:24
  • so I get about 10 errors, one for each sqlx::query! or sqlx::query_as! macro. At first I thought they all were the same but on second look there are 2 of the 10 which say this: `Invalid cargo metadata output: Error("EOF while parsing a value", line: 1, column: 0)`. The other 8 are identical to the one I originally posted. Could this have anything to do with the offline feature (reading the code you linked)? Just in case - I do have a fresh `sqlx-data.json` in the folder (get an error with or without it). – ilmoi Jun 16 '21 at 12:52
  • What happens if you run `cargo metadata --format-version=1` manually? – eggyal Jun 16 '21 at 12:59
  • I get a super long json back that begins with `{"packages":[{"name":"actix-codec","version":"0.4.0",...` and seems to go through every dependency (and potentially subdependency). – ilmoi Jun 16 '21 at 13:03
  • Yes: `"workspace_root":"/Users/ilmoi/Dropbox/rust/solwtf/code/backend"` - looks correct to me. – ilmoi Jun 16 '21 at 13:07
  • Not sure if helpful, but another error related to sqlx I've been recently battling with is this one: https://github.com/launchbadge/sqlx/issues/788. The solution is exactly what the author decsribes in the thread - to run `cargo clean` before running `cargo sqlx prepare`. I just somehow feel maybe the two are related, given both circle around the `offline` feature? Then maybe not. – ilmoi Jun 16 '21 at 13:15
  • Isn't https://github.com/launchbadge/sqlx/issues/1229 your issue ? – eggyal Jun 16 '21 at 13:17
  • 1
    Hi, did you find a solution? – Palmik Jul 10 '21 at 13:38

0 Answers0