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

.env.development is not read by gatstby-config.js #9175

Closed
jazzsequence opened this issue Aug 14, 2024 · 3 comments
Closed

.env.development is not read by gatstby-config.js #9175

jazzsequence opened this issue Aug 14, 2024 · 3 comments
Labels
Site: Site Structure Issue or PR with the docs app stack and/or live site

Comments

@jazzsequence
Copy link
Contributor

jazzsequence commented Aug 14, 2024

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 jazzsequence added the Site: Site Structure Issue or PR with the docs app stack and/or live site label Aug 14, 2024
@stevector
Copy link
Contributor

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.

@jazzsequence
Copy link
Contributor Author

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.

@rachelwhitton
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Site: Site Structure Issue or PR with the docs app stack and/or live site
Projects
None yet
Development

No branches or pull requests

3 participants