cpp-dotenv icon indicating copy to clipboard operation
cpp-dotenv copied to clipboard

No error given for missing .env file

Open arnholm opened this issue 3 years ago • 2 comments

Thanks for a great library!

I noticed that if the .env file does not exist, it is silently ignored and there is no way to check if the file was actually found. I think the dotenv class should keep a status value to indicate if the file was found & parsed or not. There should be a way to query the status, for example:

env.load_dotenv();
if(!env.good()) throw std::runtime_error(".env file was not found"):

arnholm avatar Dec 31 '21 16:12 arnholm

+1

vansoest avatar Jul 15 '22 13:07 vansoest

I think if added it should be more like env.file_found() some setups like docker compose, might pass all the settings through system enviroment, so you can have a valid config with no .env file

GaeaKat avatar Apr 10 '23 19:04 GaeaKat