Skip to content
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

Doesn't accept any pathnames nor show errors on python 3.9.2 / raspberry pi #427

Open
tonimelisma opened this issue Sep 18, 2022 · 2 comments

Comments

@tonimelisma
Copy link

tonimelisma commented Sep 18, 2022

Either running from a script, or from the command line, it doesn't accept any pathnames as valid arguments

toni@rpi:~/temp $ pwd
/home/toni/temp
toni@rpi:~/temp $ dotenv list
ENV1=value1
ENV2=value2
toni@rpi:~/temp $ dotenv -f /home/toni/temp list
Usage: dotenv list [OPTIONS]
Try 'dotenv list --help' for help.

Error: Invalid value: Path "/home/toni/temp" does not exist.
toni@rpi:~/temp $ dotenv -f . list
Usage: dotenv list [OPTIONS]
Try 'dotenv list --help' for help.

Error: Invalid value: Path "." does not exist.
toni@rpi:~/temp $ dotenv -f / list
Usage: dotenv list [OPTIONS]
Try 'dotenv list --help' for help.

Error: Invalid value: Path "/" does not exist.
toni@rpi:~/temp $ 

In a script, load_dotenv() works if I'm in the correct directory. However, load_dotenv(dotenv_path="/home/toni/temp", verbose=True) or any other directory falls silently without populating the relevant environment variables.

The environment:

toni@rpi:~/temp $ python -V
Python 3.9.2
toni@rpi:~/temp $ cat /etc/issue
Debian GNU/Linux 11 \n \l

toni@rpi:~/temp $ uname -a
Linux rpi 5.15.61-v8+ #1579 SMP PREEMPT Fri Aug 26 11:16:44 BST 2022 aarch64 GNU/Linux
toni@rpi:~/temp $

Happy to provide further debugging information as needed. Your contribution guidelines don't provide any guidance on what's useful. Perhaps that could be something to add, too, to make issue submissions easier to look at.

@bbc2
Copy link
Collaborator

bbc2 commented Nov 12, 2022

Either running from a script, or from the command line, it doesn't accept any pathnames as valid arguments

I think dotenv list is right in refusing to work with the path of a directory, however, the error message is super confusing. I've attempted to fix this in #441. If you want you can try it before I merge it.

However, load_dotenv(dotenv_path="/home/toni/temp", verbose=True) or any other directory falls silently without populating the relevant environment variables.

I'll need more time to fix that one. The behavior of load_dotenv is not very well defined at the moment and it's not obvious what the right behavior would be.

Happy to provide further debugging information as needed. Your contribution guidelines don't provide any guidance on what's useful. Perhaps that could be something to add, too, to make issue submissions easier to look at.

Your submission is very good, thanks! It's true that some short guidelines could help.

@paanvaannd
Copy link

However, load_dotenv(dotenv_path="/home/toni/temp", verbose=True) or any other directory falls silently without populating the relevant environment variables.

I'm having the same issue on Python 3.10.9: load_dotenv() works perfectly fine, but providing either a relative or absolute filepath or directory path in which a .env file exists silently fails all the time, even with verbose=True.

Examples of solutions I tried:

  • using pathlib and casting the PosixPath object to a String:
from pathlib import Path
from dotenv import load_dotenv

dotenv_path = str(Path.cwd().absolute)
load_dotenv(dotenv_path=dotenv_path, verbose=True)
  • hard-coding the file name/path directory
from dotenv import load_dotenv

load_dotenv(dotenv_path=".env", verbose=True)

Alas, neither approach listed here (nor any others I tried) worked. I'm happy to list them all out and provide more information if needed, and potentially try looking into contributing a PR if time/skill allow (but I don't want to make any promise I can't keep on that front).

For reference, this may be related to #104 and #171.

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

No branches or pull requests

3 participants