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

rspec tests won't after upgrading from rails 7.1.2 to 7.1.3.2: can't modify frozen Array when requiring environment file #51784

Open
jdescelliers opened this issue May 11, 2024 · 4 comments

Comments

@jdescelliers
Copy link

Steps to reproduce

I'm trying to update rails from version7.1.3.2 to 7.1.2 along with it's dependencies.
The Gemfile is as follows:

source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{ repo }.git" }

ruby "3.2.2"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.1.2"

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"

# Use sqlite3 as the database for Active Record
gem "sqlite3", "~> 1.4"

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", "~> 5.0"

# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails]
gem "importmap-rails"

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
gem "jbuilder"

# Use Redis adapter to run Action Cable in production
# gem "redis", "~> 4.0"

# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false

# Use Sass to process CSS
# gem "sassc-rails"

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"
gem "pg"

# Object geocoding (by street or IP address), reverse geocoding (coordinates to street address), distance queries for
# ActiveRecord and Mongoid, result caching, and more. Designed for Rails but works with Sinatra and other Rack
# frameworks too.
gem "geocoder", "~> 1.8", ">= 1.8.1"

# A ruby wrapper for ImageMagick or GraphicsMagick command line.
gem "mini_magick"

# RQRCode is a library for creating and rendering QR codes into various formats. It has a simple interface with all the
# standard QR code options. It was adapted from the Javascript library by Kazuhiko Arase.
gem "rqrcode", "~> 2.0"

group :development, :test do
  # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
  gem "debug", platforms: %i[mri mingw x64_mingw]
  gem "pry"
  gem "pry-byebug"
  gem "rspec-rails", "~> 6.0.0"
  gem "rubocop", require: false
end

group :development do
  # Use console on exceptions pages [https://github.com/rails/web-console]
  gem "web-console"

  gem "better_errors"
  gem "binding_of_caller"

  # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
  # gem "rack-mini-profiler"

  # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
  # gem "spring"
  # RBS is the language for type signatures for Ruby and standard library definitions.
  gem "rbs", "~> 3.0", ">= 3.0.4"
end

group :test do
  # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
  gem "capybara"
  gem "selenium-webdriver", "~> 4.11"
end

To isolate the problem, I tried to do the following:

  1. update only rspec-rails and check if all tests run correctly by running bundle update rspec-rails: all tests run correctly without errors
  • bundle update rspec-rails output:
Using rake 13.2.1 (was 13.0.6)
Using bigdecimal 3.1.8 (was 3.1.4)
Using concurrent-ruby 1.2.3 (was 1.2.0)
Using connection_pool 2.4.1
Using racc 1.7.3 (was 1.7.1)
Using minitest 5.22.3 (was 5.17.0)
Using mutex_m 0.2.0
Using nio4r 2.5.8
Using builder 3.2.4
Fetching rack 3.0.11 (was 2.2.8)
Using drb 2.2.1 (was 2.2.0)
Using crass 1.0.6
Using marcel 1.0.2
Using date 3.3.4
Using websocket-extensions 0.1.5
Using erubi 1.12.0
Using ast 2.4.2
Using coderay 1.1.3
Using mini_mime 1.1.5
Using bindex 0.8.1
Using base64 0.2.0
Using bundler 2.4.10
Using bcrypt 3.1.18
Using byebug 11.1.3
Using debug_inspector 1.1.0
Using public_suffix 5.0.3
Using msgpack 1.6.0
Using timeout 0.4.1
Using zeitwerk 2.6.13 (was 2.6.6)
Using matrix 0.4.2
Using regexp_parser 2.8.1
Using chunky_png 1.4.0
Using debug 1.7.1
Using json 2.6.3
Using diff-lcs 1.5.1 (was 1.5.0)
Using method_source 1.0.0
Using io-console 0.7.2 (was 0.6.0)
Using webrick 1.8.1
Using thor 1.3.1 (was 1.3.0)
Using geocoder 1.8.1
Using stringio 3.1.0
Using rexml 3.2.6
Using parallel 1.22.1
Using pg 1.4.5
Using rainbow 3.1.1
Using rbs 3.0.4
Using mini_magick 4.12.0
Using websocket 1.2.10
Using i18n 1.14.5 (was 1.12.0)
Using tzinfo 2.0.6
Using rqrcode_core 1.2.0
Using nokogiri 1.16.4 (arm64-darwin) (was 1.15.3)
Using websocket-driver 0.7.6
Using parser 3.2.0.0
Using binding_of_caller 1.0.0
Using addressable 2.8.5
Using bootsnap 1.16.0
Using net-protocol 0.2.2
Using pry 0.14.2
Using unicode-display_width 2.4.2
Using psych 5.1.2 (was 5.1.1.1)
Using activesupport 7.1.2
Using sqlite3 1.6.0 (arm64-darwin)
Using rspec-support 3.13.1 (was 3.12.0)
Fetching reline 0.5.6 (was 0.4.1)
Using loofah 2.22.0
Using rails-dom-testing 2.2.0
Using activemodel 7.1.2
Using ruby-progressbar 1.11.0
Using net-pop 0.1.2
Using puma 5.6.5
Using net-imap 0.4.7
Using rubyzip 2.3.2
Using pry-byebug 3.10.1
Using globalid 1.2.1
Using xpath 3.2.0
Using rdoc 6.6.3.1 (was 6.6.0)
Using net-smtp 0.4.0
Using rspec-expectations 3.13.0 (was 3.12.2)
Using rqrcode 2.2.0
Using activerecord 7.1.2
Using rspec-core 3.13.0 (was 3.12.1)
Using rspec-mocks 3.13.1 (was 3.12.3)
Using mail 2.8.1
Using rails-html-sanitizer 1.6.0
Using selenium-webdriver 4.12.0
Using actionview 7.1.2
Using activejob 7.1.2
Using rubocop-ast 1.24.1
Using jbuilder 2.11.5
Using rubocop 1.44.1
Installing reline 0.5.6 (was 0.4.1)
Using irb 1.13.1 (was 1.9.1)
Installing rack 3.0.11 (was 2.2.8)
Using rack-session 2.0.0 (was 1.0.1)
Using rack-test 2.1.0
Using better_errors 2.9.1
Using rackup 2.1.0 (was 1.0.0)
Using sprockets 4.2.0
Using actionpack 7.1.2
Using capybara 3.39.2
Using actioncable 7.1.2
Using activestorage 7.1.2
Using actionmailer 7.1.2
Using railties 7.1.2
Using sprockets-rails 3.4.2
Using actionmailbox 7.1.2
Using importmap-rails 1.1.5
Using rspec-rails 6.0.4 (was 6.0.1)
Using web-console 4.2.0
Using actiontext 7.1.2
Using rails 7.1.2
Bundle updated!
  1. update rails bundle update rails

Expected behavior

  • my tests should run normally

Actual behavior

  • running rspec wiith or without arguments now return this error:
An error occurred while loading ./spec/requests/home_spec.rb.
Failure/Error: require_relative "../config/environment"

FrozenError:
  can't modify frozen Array: ["/Users/<username>/source/ruby/my_project/app/channels", "/Users/<username>/source/ruby/my_project/app/controllers", "/Users/<username>/source/ruby/my_project/app/controllers/concerns", "/Users/<username>/source/ruby/my_project/app/helpers", "/Users/<username>/source/ruby/my_project/app/jobs", "/Users/<username>/source/ruby/my_project/app/mailers", "/Users/<username>/source/ruby/my_project/app/models", "/Users/<username>/source/ruby/my_project/app/models/concerns", "/Users/<username>/source/ruby/my_project/app/modules", "/Users/<username>/.rvm/gems/ruby-3.2.2/gems/actionmailbox-7.1.3.2/app/controllers", "/Users/<username>/.rvm/gems/ruby-3.2.2/gems/actionmailbox-7.1.3.2/app/jobs", "/Users/<username>/.rvm/gems/ruby-3.2.2/gems/actionmailbox-7.1.3.2/app/models", "/Users/<username>/.rvm/gems/ruby-3.2.2/gems/activestorage-7.1.3.2/app/controllers", "/Users/<username>/.rvm/gems/ruby-3.2.2/gems/activestorage-7.1.3.2/app/controllers/concerns", "/Users/<username>/.rvm/gems/ruby-3.2.2/gems/activestorage-7.1.3.2/app/jobs", "/Users/<username>/.rvm/gems/ruby-3.2.2/gems/activestorage-7.1.3.2/app/models"]
# /Users/<username>/.rvm/gems/ruby-3.2.2/gems/railties-7.1.3.2/lib/rails/engine.rb:580:in `unshift'
# /Users/<username>/.rvm/gems/ruby-3.2.2/gems/railties-7.1.3.2/lib/rails/engine.rb:580:in `block in <class:Engine>'
# /Users/<username>/.rvm/gems/ruby-3.2.2/gems/railties-7.1.3.2/lib/rails/initializable.rb:32:in `instance_exec'
# /Users/<username>/.rvm/gems/ruby-3.2.2/gems/railties-7.1.3.2/lib/rails/initializable.rb:32:in `run'
# /Users/<username>/.rvm/gems/ruby-3.2.2/gems/railties-7.1.3.2/lib/rails/initializable.rb:61:in `block in run_initializers'
# /Users/<username>/.rvm/gems/ruby-3.2.2/gems/railties-7.1.3.2/lib/rails/initializable.rb:50:in `each'
# /Users/<username>/.rvm/gems/ruby-3.2.2/gems/railties-7.1.3.2/lib/rails/initializable.rb:50:in `tsort_each_child'
# /Users/<username>/.rvm/gems/ruby-3.2.2/gems/railties-7.1.3.2/lib/rails/initializable.rb:50:in `each'
# /Users/<username>/.rvm/gems/ruby-3.2.2/gems/railties-7.1.3.2/lib/rails/initializable.rb:50:in `tsort_each_child'
# /Users/<username>/.rvm/gems/ruby-3.2.2/gems/railties-7.1.3.2/lib/rails/initializable.rb:60:in `run_initializers'
# /Users/<username>/.rvm/gems/ruby-3.2.2/gems/railties-7.1.3.2/lib/rails/application.rb:426:in `initialize!'
# ./config/environment.rb:5:in `<main>'
# ./spec/rails_helper.rb:4:in `require_relative'
# ./spec/rails_helper.rb:4:in `<main>'
# /Users/<username>/.rvm/gems/ruby-3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /Users/<username>/.rvm/gems/ruby-3.2.2/gems/zeitwerk-2.6.13/lib/zeitwerk/kernel.rb:34:in `require'
# ./spec/requests/home_spec.rb:1:in `<main>'
No examples found.

System configuration

Rails version: 7.1.3.2 upgraded to 7.1.2
OS: MacOS 14.4.1 on Apple Silicon (M1 chip)
-Bundler version: 2.4.10

Ruby version: 3.2.2

Anyone has an idea on what went wrong? As noted before, I tried updating only rspec-rails and all tests ran without issues, its the rails update that caused this error. I purposely only updated only rails to isolate the issue here.

@fatkodima
Copy link
Member

You can clone rails locally, point your app to the local copy of rails via gem 'rails', path: '/my/path/to/rails' and try to run git bisect on the rails directory to identify which commit caused that behaviour.

@eileencodes
Copy link
Member

7.1.3.2 upgraded to 7.1.2

I'm confused. Are you upgrading to 7.1.3.2? Because going from 7.1.3.2 to 7.1.2 is a downgrade, not an upgrade. 7.1.3.2 is a security release which means 7.1.2 is vulnerable to the security issues we fixed in 7.1.3.2.

@jdescelliers
Copy link
Author

7.1.3.2 upgraded to 7.1.2

I'm confused. Are you upgrading to 7.1.3.2? Because going from 7.1.3.2 to 7.1.2 is a downgrade, not an upgrade. 7.1.3.2 is a security release which means 7.1.2 is vulnerable to the security issues we fixed in 7.1.3.2.

No, I'm upgrading from 7.1.2 to 7.1.3.2.

@jdescelliers
Copy link
Author

Apparently it's linked to some routing modifications. Bisect gave me this commit: 0821d25

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

No branches or pull requests

3 participants