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
-
👋 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)
ENV
will be automatically restored between tests in Rails apps using bothActiveSupport::TestCase
andRspec
. This means you can modifyENV
in your tests without fear of leaking state to other tests.You can also manually modify and restore
ENV
using themodify
method and passing a block:See
Dotenv.save
,Dotenv.restore
, andDotenv.modify(hash) { ... }
for manual usage.To disable autorestore, set
config.dotenv.autorestore = false
inconfig/application.rb
orconfig/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.0
if you are using an outdated Ruby or Rails version.Shell compatability (#423 by @nitsujri)
\n
is no longer expanded into a newline in quoted strings. Use multi-line strings with real line breaks, or setDOTENV_LINEBREAK_MODE=legacy
to preserve the old behavior.Logging (#473)
All changes that dotenv performs to ENV will now be logged in Rails apps.
Other niceties
-i
/--ignore
option todotenv
CLI to optionally ignore missing files. @stevenharman Optionally ignore missing files from cli #463Dotenv::Rails.files
. Include Rails integration indotenv
gem and refactor #468Bug Fixes
Here's a few other important fixes:
Dotenv::Rails.overload
. So now.env.development.local
will overwrite.env.local
, which will overwrite.env.development
, which will overwrite.env
. @eriklovmo - fix: always respect file importance order #460rake
loaded development files (.env*development
) for test-related tasks. Fix environment run runningrake test
#470"Deprecations"
Dotenv::Railtie
has been renamed toDotenv::Rails
. Include Rails integration indotenv
gem and refactor #468dotenv-rails
gem is now superfluous. It's not technically deprecated yet and will continue to work, but thedotenv
gem does the same thing. Include Rails integration indotenv
gem and refactor #468Dotenv.overload
has been replaced withoverwrite
.overload
will still work and is not technically deprecated, but documentation refers toDotenv.overwrite
now. 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