question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

This has been reported already in #118 but the OP closed it. The reason for this error message in both my case in issue 118’s OP was that the .env-cmd was not valid JSON and could not be parsed correctly which would have been much more helpful error message than this confusing information about env-cmd not being able to find the .rc file. The issue lies here in get-env-var.js inside the catch that is muting all exceptions except EnvironmentError, I added a comment and console.log there to debug locally:

    for (const path of RC_FILE_DEFAULT_LOCATIONS) {
        try {
            const env = await parse_rc_file_1.getRCFileVars({ environments, filePath: path });
            if (verbose === true) {
                console.info(`Found environments: [${environments.join(',')}] for default .rc file at path: ${path}`);
            }
            return env;
        }
        catch (e) {
            // not sure why you want mute exceptions other than "EnvironmentError", add the console.log in the line below to see the true error being muted.
            console.log(`ERROR: ${e}`);
            if (e.name === 'EnvironmentError') {
                const errorText = `Failed to find environments: [${environments.join(',')}] for .rc file at path: ${path}`;
                if (verbose === true) {
                    console.info(errorText);
                }
                throw new Error(errorText);
            }
        }
    }

Maybe you could just rethrow the error below the “if” statement to make sure errors are not muted.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:18
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

10reactions
davegariepycommented, May 27, 2020

thanks, in my case I had a trailing comma

3reactions
echosonusharmacommented, Jan 28, 2022

its most likely a syntax error for me my env-cmdrc had a comma in the last key value pair in the development section.

Read more comments on GitHub >

github_iconTop Results From Across the Web

env-cmd Error: Failed to find .env file at path - Stack Overflow
If you're using .env-cmdrc make sure that you haven't missed any commas and your file structure corresponds to the JSON structure.
Read more >
Failed to find .env file. Error command env-cmd ... - YouTube
Failed to find .env file at default paths : [./.env,./.env. js,./.env. json ].While running the to start the server using the command. cmd:...
Read more >
env-cmd - Bountysource
env-cmdrc syntax error but prompts 'Error: Failed to find .rc file at default paths' $ 0. Created 1 month ago in toddbluhm/env-cmd with...
Read more >
Failed to find .env file at path: .env - Netlify Support Forums
I'm able to leverage the .env file on my local and am able to run my ... refs/heads/staging 9:55:40 AM: Parsing package.json dependencies ......
Read more >
env-cmd: Documentation - Openbase
... [path] Custom rc file path (default path: ./.env-cmdrc(|.js|.json) --silent Ignore any env-cmd errors and only fail on executed program failure.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found