Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

dotenv-expand' "default" expansion not working #34718

Closed
1 task done
FezVrasta opened this issue Feb 23, 2022 · 0 comments · Fixed by #34765
Closed
1 task done

dotenv-expand' "default" expansion not working #34718

FezVrasta opened this issue Feb 23, 2022 · 0 comments · Fixed by #34765
Labels
bug Issue was opened via the bug report template.

Comments

@FezVrasta
Copy link

FezVrasta commented Feb 23, 2022

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 21.3.0: Wed Jan  5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000
Binaries:
  Node: 16.14.0
  npm: 8.3.1
  Yarn: 3.2.0
  pnpm: N/A
Relevant packages:
  next: 12.1.0
  react: 17.0.2
  react-dom: 17.0.2

warn - Latest canary version not detected, detected: "12.1.0", newest: "12.1.1-canary.1".
Please try the latest canary version (npm install next@canary) to confirm the issue still exists before creating a new issue.
Read more - https://nextjs.org/docs/messages/opening-an-issue

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

If I add a fallback/default value to one of my dotenv variable expansions the operation doesn't succeed.

NEXT_PUBLIC_TEST=${KEY:-default}

Results in:

> console.log(process.env.NEXT_PUBLIC_TEST);
< ":-default}"

Expected Behavior

> console.log(process.env.NEXT_PUBLIC_TEST);
< "default"

This is explained in the dotenv-expand documentation here:
https://github.com/motdotla/dotenv-expand#what-rules-does-the-expansion-engine-follow

To Reproduce

Add the above config to .env and run yarn build.

I noticed that the compiled source of @next/env is missing several parts of the dotenv-expand package (that is for some reason bundled in rather than referenced as external)

@FezVrasta FezVrasta added the bug Issue was opened via the bug report template. label Feb 23, 2022
@vercel vercel locked and limited conversation to collaborators Feb 24, 2022
@balazsorban44 balazsorban44 converted this issue into discussion #34766 Feb 24, 2022
kodiakhq bot pushed a commit that referenced this issue Mar 3, 2022
We currently use `dotenv-expand@5` in `@next/env`, which does not support default expansion. It was added in v6 (motdotla/dotenv-expand#39).

Upgrading to the latest version of `dotenv-expand` and fixing an import, the added test passed.

Fixes #34718

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant