You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working with a project using a Cargo workspace and am trying to set it up to use a .env file for each project in the workspace instead of a single .env file at the root of the repository.
Unfortunately, the dotenv_codegen macro is failing when the .env file is not at the root of the workspace.
This seems at odds with the dotenv code and documentation, which says the library "will load environment variables from a file named .env in the current directory or any of its parents".
I started a new project with a workspace holding a single project whose only job is to print the environment variable embedded with the dotenv_codegen macro and was able to reproduce the issue, so I'm fairly certain this is a problem with the macro and not with anything in my existing project.
The text was updated successfully, but these errors were encountered:
Happening the same issue in my setup but with the non macro version. I have multiple projects in a workspace each with a different .env, but dotenv::dotenv() tries to load the (non-existing) one at the workspace root.
@lanesawyer how are you started your app ? if you're running cargo run ... from the root of the projet, then it normal for dotenv to check for a .env file there and not at the crate level. the directory where you run the command starting your app is the "current directory"
I start it different ways depending on what I'm working on.
It's a front-end and a web server, each of which has a ..env file. Things work fine when I run each individually, meaning I'm in the ui or server folder, but fails when I run the entire workspace at the root of the repository.
I believe I got around the issue with the suggestion of the other commenter on this thread, but it has been a few months since I've worked on that project so I'm not entirely sure and I don't currently have access to that project to check.
Hi 👋🏻,
I'm working with a project using a Cargo workspace and am trying to set it up to use a
.env
file for each project in the workspace instead of a single.env
file at the root of the repository.Unfortunately, the
dotenv_codegen
macro is failing when the.env
file is not at the root of the workspace.This seems at odds with the
dotenv
code and documentation, which says the library "will load environment variables from a file named .env in the current directory or any of its parents".I started a new project with a workspace holding a single project whose only job is to print the environment variable embedded with the
dotenv_codegen
macro and was able to reproduce the issue, so I'm fairly certain this is a problem with the macro and not with anything in my existing project.The text was updated successfully, but these errors were encountered: