40

after updating to ruby 3.1.2 and Rails 7.0.2.3

getting following error while starting rails application:

`require': cannot load such file -- matrix (LoadError)

what could be the possible solution, thanks in advance.

4 Answers 4

63

Matrix was removed from Ruby's standard library in version 3.1. More info: https://www.ruby-lang.org/en/news/2021/12/25/ruby-3-1-0-released/

With Ruby 3.1, matrix needs to be explicitly added to the Gemfile. You can add it manually or run something like:

$ bundle add matrix

After it's added to the Gemfile, bundle your application:

$ bundle install

Then your application should continue to behave like it did in previous Ruby versions.

Sign up to request clarification or add additional context in comments.

2 Comments

Solution for downgrading combine_pdf from 1.0.22 to 1.0.20. github.com/boazsegev/combine_pdf/issues/205
I had the same problem with file statistics. The commands above, with the word statistics instead of matrix solved the problem. Hope this helps.
13

same here, ruby 3.1.2, rails 7.0.4 after adding prawn to gemfile. I had to add gem 'matrix' to gemfile and it works.

1 Comment

Thanks, this works for me too, also prawn and prawn-table specific
10

I came onto this issue as well when upgrading Rails 6->7 and Ruby 3.0.0->3.1.2.

For my case the issue was related to Capybara gem. Version 3.35.3 assumed it is installed by default with Ruby. When I upgraded the Capybara to version 3.37.1 then matrix gem was automatically installed as well and the issue was resolved.

Comments

4

Just ran into the same issue after adding rubystats gem for some seed data, also using ruby 3.1.2 and rails 7.0.4.

@siasmj 's fix worked for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.