-
-
Notifications
You must be signed in to change notification settings - Fork 310
Closed
Description
Describe the bug
When dynaconf is invoked from a non existent current working directory (created and removed afterwards), the dotenv loading mechnism will fail with FileNotFoundError, even if load_dotenv has been disabled.
To Reproduce
Steps to reproduce the behavior:
python3 -m venv venv
source venv/bin/activate
pip install dynaconf
mkdir nonexistent_dir
cd nonexistent_dir
rm -r ../nonexistent_dir
dynaconfExpected behavior
Dynaconf command line should have executed without any issues.
Actual behavior
os.getcwd() fails with FileNotFoundError
Traceback (most recent call last):
File "/home/mtarral/venv/bin/dynaconf", line 5, in <module>
from dynaconf.cli import main
File "/home/mtarral/venv/lib/python3.8/site-packages/dynaconf/__init__.py", line 3, in <module>
from dynaconf.base import LazySettings # noqa
File "/home/mtarral/venv/lib/python3.8/site-packages/dynaconf/base.py", line 17, in <module>
from dynaconf.loaders import env_loader
File "/home/mtarral/venv/lib/python3.8/site-packages/dynaconf/loaders/env_loader.py", line 8, in <module>
from dynaconf.vendor.dotenv import cli as dotenv_cli
File "/home/mtarral/venv/lib/python3.8/site-packages/dynaconf/vendor/dotenv/cli.py", line 16, in <module>
@click.option('-f','--file',default=os.path.join(os.getcwd(),'.env'),type=click.Path(exists=_A),help='Location of the .env file, defaults to .env file in current working directory.')
FileNotFoundError: [Errno 2] No such file or directoryProposed fix
Dynaconf should suppress this FileNotFoundError for os.getcwd()
Environment (please complete the following information):
- OS: Ubuntu 20.04
- Dynaconf Version 3.1.11
Thanks !