-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.env Support for Repositories with Multiple Crates #267
Comments
Yeah, currently we just rely on the implicit behavior of This is easy to fix if we load relative to However, I can see this being perhaps a breaking change for some people. We should probably try |
Wait... version |
Hah yep apologies, that was a different crate! Updated the issue body. |
This change will attempt to load an .env file from CARGO_MANIFEST_DIR, if it exists. For backwards compatibility, if the .env file does not exist, we will fall back to default dotenv behaviour. Resolves launchbadge#267
This change will attempt to load an .env file from CARGO_MANIFEST_DIR, if it exists. For backwards compatibility, if the .env file does not exist, we will fall back to default dotenv behaviour. Resolves launchbadge#267
This change will attempt to load an .env file from CARGO_MANIFEST_DIR, if it exists. For backwards compatibility, if the .env file does not exist, we will fall back to default dotenv behaviour. Resolves launchbadge#267
This change will attempt to load an .env file from CARGO_MANIFEST_DIR, if it exists. For backwards compatibility, if the .env file does not exist, we will fall back to default dotenv behaviour. Resolves launchbadge#267
As a workaround until this is merged, you can use a small
|
This change will attempt to load an .env file from CARGO_MANIFEST_DIR, if it exists. For backwards compatibility, if the .env file does not exist, we will fall back to default dotenv behaviour. Resolves #267
SQLx version: 0.3.4
Current Behaviour
If I have a repository with multiple crates, and a root
Cargo.toml
file defining each crate as aworkspace
, SQLx won't pick up.env
files for specific crates, it will only pick this up from the project root directory.This is not ideal as if for example, multiple microservices were being developed in a "monorepo", each one using its own database and
.env
file, SQLx will only attempt to use an.env
file defined at the project root directory. For example,Preferred Behaviour
It would be better if SQLx was able to pick up
.env
files from each crate in the project, using the crate specificDATABASE_URL
for compile-time query validation.For example,
The text was updated successfully, but these errors were encountered: