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

Variable substitution using real environment variable fallbacks #74

Closed
nick-jones opened this issue Apr 24, 2019 · 12 comments · Fixed by #227
Closed

Variable substitution using real environment variable fallbacks #74

nick-jones opened this issue Apr 24, 2019 · 12 comments · Fixed by #227

Comments

@nick-jones
Copy link

#54 introduced a change that meant substitution of variables from the real environment (i.e. not that derived from .env itself) was possible.

It looks like #58 removed this behaviour, in particular the deletion of os.LookupEnv - https://github.com/joho/godotenv/pull/58/files#diff-224f281bd0a4cfe0e7dcb394e8c7a585L299. Unfortunately it isn't clear from the PR if that was intended. Any chance someone can clarify?

@andrewmclagan
Copy link

Also needing this functionality back..

@fabriciojs
Copy link

fabriciojs commented May 26, 2020

@nick-jones @andrewmclagan well 1 year later, I had the same need in my project.

I created #102.

For now I am using https://github.com/fireworkweb/godotenv (my fork) where I returned the behaviour.

Just registering this here in case someone stumbles upon this issue and then can check the latest on this.

@nick-jones
Copy link
Author

@fabriciojs 👍 there is also #72 and #88. Unfortunately no word from @joho on this.

@evandam
Copy link

evandam commented Apr 14, 2022

Hey @fabriciojs we're looking for similar functionality, but where it is able to read environment variables from os.Getenv if the variable in the file has not been defined, like https://github.com/fireproofsocks/dotenvy/blob/main/docs/dotenv-file-format.md#interpolation-aka-variable-substitution.

Is this something that you would be able to update in your fork? (or @joho)

Thanks!

@luisdavim
Copy link

luisdavim commented May 15, 2022

#135 and #149 also relate to this.

This is clearly an issue users care about, with so many issues and PRs open regarding it.

@joho any specific reason for this not to be addressed?

@Envek
Copy link
Contributor

Envek commented Mar 6, 2024

Also made #227 as all other pull requests got stale due to parser rewrite in version 1.5.

@silverwind
Copy link

silverwind commented Oct 28, 2024

Is there a fork of this module with env substitution added back? According to #182, the autor sees the module as "complete", I'm not sure on their stance regarding this issue.

Edit: I forked, applied #227 and tagged it as github.com/silverwind/[email protected], works perfectly.

@Envek
Copy link
Contributor

Envek commented Oct 30, 2024

But also according to #182:

Exceptions will be made to:

  • maintain compatibility with env file formats of other mainstream "dotenv" libraries, primarily the OG Ruby dotenv and the Node.js dotenv

And OG Ruby dotenv has variable substitution using real environment variables, so we can hope that @joho will finally notice #227 one day.

@silverwind
Copy link

But also according to #182:

Exceptions will be made to:

  • maintain compatibility with env file formats of other mainstream "dotenv" libraries, primarily the OG Ruby dotenv and the Node.js dotenv

And OG Ruby dotenv has variable substitution using real environment variables, so we can hope that @joho will finally notice #227 one day.

Yes, expansion from environment also is a feature in JS dotenv, specifically with the dotenv-expand module that enables expansion:

https://github.com/motdotla/dotenv-expand/blob/ff7e2efd0d9925c7da82c167ae77d22a6c76e878/tests/main.js#L50-L64

@joho
Copy link
Owner

joho commented Oct 31, 2024

I'll give #227 a review and merge if I'm confident on backwards compatibility

@joho joho closed this as completed in #227 Oct 31, 2024
@joho
Copy link
Owner

joho commented Oct 31, 2024

I've done a pre-release at https://github.com/joho/godotenv/releases/tag/v1.6.0-pre.1

I've set something in my calendar to do the full release on nov 15th (AU time) to give time for bug reports to come in and remediate if needed.

@silverwind
Copy link

pre.1 works fine for me, haven't noticed any regressions so far.

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

Successfully merging a pull request may close this issue.

8 participants