poetry-plugin-dotenv - is the plugin that automatically loads environment variables from a dotenv file into the environment before poetry commands are run
Originally posted by **brainwo** May 31, 2024
How to use this plugin with `poetry --directory`?
I have to run a project in some directory with `--directory` flag. But it doesn't seem to read the `.env` file relative to the project directory.
I setup the plugin like this:
```toml
[tool.poetry.plugins.dotenv]
ignore = "false"
location = ".env"
```
This works:
```sh
# Inside /path/to/directory
poetry run python3 projectname
```
This doesn't read the `.env` file:
```sh
poetry --directory /path/to/directory run python3 /path/to/directory/projectname
```
Discussed in https://github.com/pivoshenko/poetry-plugin-dotenv/discussions/259
Special thanks to @brainwo for his input 🐱