简体   繁体   English

Rails `require':无法加载此类文件 -- 矩阵

[英]Rails `require': cannot load such file -- matrix

after updating to ruby 3.1.2 and Rails 7.0.2.3更新到 ruby 3.1.2 和 Rails 7.0.2.3 后

getting following error while starting rails application:启动 Rails 应用程序时出现以下错误:

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

what could be the possible solution, thanks in advance.可能的解决方案是什么,在此先感谢。

Matrix was removed from Ruby's standard library in version 3.1. Matrix 在 3.1 版中从 Ruby 的标准库中删除。 More info: https://www.ruby-lang.org/en/news/2021/12/25/ruby-3-1-0-released/更多信息: 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.在 Ruby 3.1 中,矩阵需要显式添加到 Gemfile。 You can add it manually or run something like:您可以手动添加它或运行类似的东西:

$ bundle add matrix

After it's added to the Gemfile, bundle your application:将其添加到 Gemfile 后,捆绑您的应用程序:

$ bundle install

Then your application should continue to behave like it did in previous Ruby versions.然后,您的应用程序应该继续像以前的 Ruby 版本一样运行。

I came onto this issue as well when upgrading Rails 6->7 and Ruby 3.0.0->3.1.2 .我在升级Rails 6->7Ruby 3.0.0->3.1.2时也遇到了这个问题。

For my case the issue was related to Capybara gem.就我而言,这个问题与 Capybara gem 有关。 Version 3.35.3 assumed it is installed by default with Ruby.版本3.35.3假定它默认与 Ruby 一起安装。 When I upgraded the Capybara to version 3.37.1 then matrix gem was automatically installed as well and the issue was resolved.当我将 Capybara 升级到3.37.1版时,matrix gem 也被自动安装,问题得到解决。

same here, ruby 3.1.2, rails 7.0.4 after adding prawn to gemfile.同样在这里, ruby 3.1.2,prawn添加到 gemfile 后的 rails 7.0.4。 I had to add gem 'matrix' to gemfile and it works.我必须将gem 'matrix'添加到 gemfile 并且它有效。

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.在为一些种子数据添加rubystats gem 后遇到了同样的问题,同样使用 ruby 3.1.2 和 rails 7.0.4。

@siasmj 's fix worked for me. @siasmj 的修复对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM