sqlx-macros-core: allow not calling cargo from a proc-macro#4315
Draft
lf- wants to merge 2 commits into
Draft
Conversation
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.
2a540ae to
0f4f93b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.