documentation icon indicating copy to clipboard operation
documentation copied to clipboard

`.env.development` is not read by `gatstby-config.js`

Open jazzsequence opened this issue 1 year ago • 2 comments

Expected behavior

  • .env.development and .env.production files are read at the top of gatsby-config.js and the npm start process kicks off normally

Actual behavior

  • Those files are not read, and the GITHUB_API value is undefined leading to a Bad Credentials error.

Steps to reproduce the problem

  1. If you have GITHUB_API defined anywhere else (e.g. in a .envrc, .bashrc or .zshrc, remove/comment out that line
  2. Add a valid GitHub API token to .env.development and/or .env.production
  3. Run npm start or npm run develop
  4. Get the error

Screenshot 2024-08-14 at 10 27 17 AM

jazzsequence avatar Aug 14 '24 16:08 jazzsequence

I put console.log around the dotenv processing at the beginning of gatsby-config.js on my local and found that it is being processed. I don't know what the discrepancy is between your machine and my machine. This might be a good excuse to explore GitHub Codespaces for local(ish) developement.

stevector avatar Aug 14 '24 17:08 stevector

Codespaces would at least eliminate the "works/doesn't work on my machine" issue. We can icebox this if no one can reproduce, but...

I put console.log around the dotenv processing at the beginning of gatsby-config.js on my local

Did you also check to see if you have a GITHUB_API variable defined in your .zshrc or relevant Bash .*rc file? That ended up being the fix for me and I already had a GITHUB_TOKEN defined in there for other things.

jazzsequence avatar Aug 15 '24 15:08 jazzsequence

Not resolved, but workarounds achieved so we're opt'ing to close

rachelwhitton avatar Oct 30 '24 15:10 rachelwhitton