globe icon indicating copy to clipboard operation
globe copied to clipboard

Workaround [dotenv] Load failed: file not found: File: '.env'

Open lesnitsky opened this issue 2 years ago • 0 comments

For future readers:

package:dotenv tries to read .env file form the file system, but we only deploy dart executable without any files. If you deploy from CLI, it will pick up your .env and prompt you to create env vars on Globe. You could also go to Project > Settings > Environment variables and create env vars there manually.

To workaround this issue, you could do something like this:

var env = Platform.environment['GLOBE'] == 'true' ? Platform.environment : DotEnv().load();

We're working on fixing this issue and this workaround is temporary.

lesnitsky avatar Mar 04 '24 18:03 lesnitsky