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

Using -f is not using a local file, throwing error. #359

Open
dcp3450 opened this issue Apr 13, 2023 · 3 comments
Open

Using -f is not using a local file, throwing error. #359

dcp3450 opened this issue Apr 13, 2023 · 3 comments

Comments

@dcp3450
Copy link

dcp3450 commented Apr 13, 2023

I have env-cmd installed locally on a windows 10 setup. Calling env-cmd -f .env.local returns the error:

Error: Failed to find .env file at default paths: [./.env,./.env.js,./.env.json]

I even installed the library in to my app and run it from the ./node_modules/.bin/env-cmd and got the same error.

@anichols-ht
Copy link

Same, I don't believe the -f flag works at all. Doesn't seem to matter how I do it.

In my case, I'm in a monorepo and running my startup command from a subdirectory (the cwd is a subdirectory that is), and -f ../../.env.js (or any other filename) fails with the same error you're seeing.

@anichols-ht
Copy link

This is why (at least in my case):

{
  envFile: {
    filePath: '/a/path/.env.js',
    fallback: undefined
  },
  rc: { environments: [ 'default', 'local' ], filePath: undefined },
  verbose: false
}

The filePath that gets passed to getRCFile is rc.filePath rather than envFile.filePath.

@anichols-ht
Copy link

Ah, there's a separate option for this: -r, --rc-file [path]. With all due respect, I think that's a confusing implementation. It should just always use the -f flag. I can't see any reason you would need to pass both.

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

2 participants