-
Notifications
You must be signed in to change notification settings - Fork 502
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
autorestore: can't modify frozen Hash #482
Comments
We're hitting this issue in a Rails 7 app for all specs using climate_control to modify ENV. |
@dbackeus thanks, I'll work up a PR to disable autorestore if using climate_control or ice_age. In the mean time, do you have any idea how |
I can confirm that your PR makes our specs green. But no idea about the frozen issue. |
We're not using Climate Control, but we are using We're using
in (but it's better to just set the |
Hi @bkeepers 👋 I wasn't able to fully figure out the exact chain of events but by trial and error it seems that the issue is caused by this bit https://github.com/bkeepers/dotenv/blob/main/lib/dotenv/diff.rb#L53. When Dotenv is used together with rspec's |
Upgrading to version 3 of the dotenv-rails gem causes tests in zendesk_sender_spec to fail with the error `FrozenError: can't modify frozen Hash: [...]`. This is because the latest version of dotenv-rails introduces an Autorestore feature which automatically restores the state of ENV between rspec tests. In zendesk_sender_spec we stub the value of ENV['ENV'] using `stub_const`, which also resets between tests and leads to a conflict: bkeepers/dotenv#482. This is resolved by replacing the use of `stub_const` with the `Dotenv.modify` method (also introduced in v3), which makes dotenv-rails fully responsible for the stubbing of environment variables and avoids conflict.
@bkeepers as others have already mentioned this issue is not exclusive to certain CI environments, but rather to the fact that using rspec's stub_const messes with the autorestore functionality. Would it be possible to reopen this issue and provide guidelines on the impact of disabling autorestore? |
@rgarner, @kajetanowicz and @sk-, thanks for the The problem is happens when you replace This should be fixed in 3.1.2, which will be out shortly. |
After perusing dependabot updates to dotenv 3.0, I'm seeing a handful of builds breaking with this error:
This is caused by autorestore and is happening because
ENV
is somehow frozen, but the head scratcher is thatENV.freeze
raisescannot freeze ENV (TypeError)
.Examples:
Bump dotenv-rails from 2.8.1 to 3.0.0 ministryofjustice/laa-assess-crime-forms#269
The text was updated successfully, but these errors were encountered: