Skip to content

sqlx-macros-core: allow not calling cargo from a proc-macro#4315

Draft
lf- wants to merge 2 commits into
transact-rs:mainfrom
MercuryTechnologies:jade/push-vwoyvrqvxpvz
Draft

sqlx-macros-core: allow not calling cargo from a proc-macro#4315
lf- wants to merge 2 commits into
transact-rs:mainfrom
MercuryTechnologies:jade/push-vwoyvrqvxpvz

Conversation

@lf-

@lf- lf- commented Jun 19, 2026

Copy link
Copy Markdown

Problem:
We're trying to build
https://github.com/MercuryTechnologies/locally-euclidean with buck2, and we're finding that sqlx is trying to call Cargo to find the workspace root and snoop outside of its build directory.

This is trouble for us because we want to be able to cache build actions. Thus, we want to be able to run sqlx in an extra offline mode which never calls cargo.

Solution: check if all the env-vars are set (which requires that you put nonsense in the database url, but that's ok for us as it ensures we cannot possibly regress any existing users).

Problem: If a query is missed in .sqlx/, sqlx calls cargo unconditionally to find the workspace root.

Solution: accept SQLX_WORKSPACE_DIR to give the fallback directory. You could make it /var/empty if you want to suppress it altogether.

Does your PR solve an issue?

Not one I've written. Related Bazel usage: #3555, related env-var shenanigans in the CLI #3963.

Is this a breaking change?

No. This will not be observable to external consumers except by calling cargo pointlessly fewer times.

lf- added 2 commits June 18, 2026 17:05
Problem:
We're trying to build
https://github.com/MercuryTechnologies/locally-euclidean with buck2, and
we're finding that sqlx is trying to call Cargo to find the workspace
root and snoop outside of its build directory.

This is trouble for us because we want to be able to cache build
actions. Thus, we want to be able to run sqlx in an *extra* offline mode
which never calls cargo.

Solution: check if all the env-vars are set (which requires that you put
nonsense in the database url, but that's ok for us as it ensures we
cannot possibly regress any existing users).

Problem: If a query is missed in .sqlx/, sqlx calls cargo
unconditionally to find the workspace root.

Solution: accept SQLX_WORKSPACE_DIR to give the fallback directory. You
could make it /var/empty if you want to suppress it altogether.

### Does your PR solve an issue?

Not one that either I nor an agent can find.
Related Bazel usage: transact-rs#3555, related env-var shenanigans in the CLI transact-rs#3963, but neither are solved by this.
@lf- lf- force-pushed the jade/push-vwoyvrqvxpvz branch from 2a540ae to 0f4f93b Compare June 19, 2026 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant