Skip to content

Conversation

joeydewaal
Copy link
Contributor

This PR fixes a regression I created in #3815. Now, environment variables are read or fall back to the .env file instead of mutating them before expanding the query macro's.

Does your PR solve an issue?

fixes #3836

@abonander abonander merged commit 760b395 into launchbadge:main May 19, 2025
84 checks passed
@@ -182,7 +165,7 @@ pub fn expand_input<'a>(

// Check SQLX_OFFLINE_DIR, then local .sqlx, then workspace .sqlx.
let dirs = [
|_: &Metadata| env("SQLX_OFFLINE_DIR").ok().map(PathBuf::from),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line would have made 0.8.5 work. Now that it is not checked, I believe this causes #3961

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you're correct. We only read it from the .env but not the actual process environment:

let config = Config::try_from_crate_or_default()?;

We only actually check the process environment when we go to write the data out:

if let Ok(dir) = env("SQLX_OFFLINE_DIR") {

However, while we should fix this for existing users, I think the offline directory should be configurable in the sqlx.toml (#3383).

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.

Setting SQLX_OFFLINE=true in .env breaks cargo sqlx prepare --workspace
3 participants