Dotenv 3.0 #476
bkeepers
announced in
Announcements
Dotenv 3.0
#476
Replies: 3 comments 2 replies
This comment was marked as off-topic.
This comment was marked as off-topic.
-
|
Thanks for this! I'm using 3.0.0.beta in production for a couple projects; so far, so good. |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
I'm having a problem when using dotenv with a gem that implements a Rails engine and uses a dummy Rails app for testing: The dotenv paths are now fixed before Rails.root is set in the dummy application, so dotenv can't find the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
👋 after years of minimal changes, Dotenv 3.0 introduces several updates and improvements.
Read the full 3.0.0 changelog, but I'll summarize a few of the more important or exciting parts.
Autorestore ENV (#472, #475)
ENVwill be automatically restored between tests in Rails apps using bothActiveSupport::TestCaseandRspec. This means you can modifyENVin your tests without fear of leaking state to other tests.You can also manually modify and restore
ENVusing themodifymethod and passing a block:See
Dotenv.save,Dotenv.restore, andDotenv.modify(hash) { ... }for manual usage.To disable autorestore, set
config.dotenv.autorestore = falseinconfig/application.rborconfig/environments/test.rb. To use this behavior outside of a Rails app, justrequire "dotenv/autorestore"in your test suite.Ruby >= 3.0 and Rails >= 6.1 are now required. (#466, #471)
Going forward, the latest release of dotenv will drop support for EOL versions of Ruby and Rails. Lock dotenv to
~> 2.0if you are using an outdated Ruby or Rails version.Shell compatability (#423 by @nitsujri)
\nis no longer expanded into a newline in quoted strings. Use multi-line strings with real line breaks, or setDOTENV_LINEBREAK_MODE=legacyto preserve the old behavior.Logging (#473)
All changes that dotenv performs to ENV will now be logged in Rails apps.
Other niceties
-i/--ignoreoption todotenvCLI to optionally ignore missing files. @stevenharman Optionally ignore missing files from cli #463Dotenv::Rails.files. Include Rails integration indotenvgem and refactor #468Bug Fixes
Here's a few other important fixes:
Dotenv::Rails.overload. So now.env.development.localwill overwrite.env.local, which will overwrite.env.development, which will overwrite.env. @eriklovmo - fix: always respect file importance order #460rakeloaded development files (.env*development) for test-related tasks. Fix environment run runningrake test#470"Deprecations"
Dotenv::Railtiehas been renamed toDotenv::Rails. Include Rails integration indotenvgem and refactor #468dotenv-railsgem is now superfluous. It's not technically deprecated yet and will continue to work, but thedotenvgem does the same thing. Include Rails integration indotenvgem and refactor #468Dotenv.overloadhas been replaced withoverwrite.overloadwill still work and is not technically deprecated, but documentation refers toDotenv.overwritenow. Consistently use "overwrite" in place of "overload" and "override" #469New Contributors
Thanks to these fine folks who made their first contribution:
Full Changelog: v2.8.1...v3.0.0.beta
Beta Was this translation helpful? Give feedback.
All reactions