rails`require':无法加载该文件 - 矩阵
在更新了Ruby 3.1.2和Rails 7.0.2.3之后,
在开始Rails应用程序时会出现以下错误:
`require': cannot load such file -- matrix (LoadError)
可能是可能的解决方案,谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在3.1版中,从Ruby的标准库中删除了矩阵。更多信息: https:/ /www.ruby-lang.org/en/news/2021/12/25/ruby-3-1-0-relase/
使用Ruby 3.1,需要将Matrix明确添加到Gemfile中。您可以手动添加它或运行类似的内容:
将其添加到Gemfile之后,捆绑您的应用程序:
然后,您的应用程序应该继续像以前的Ruby版本一样行事。
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:
After it's added to the Gemfile, bundle your application:
Then your application should continue to behave like it did in previous Ruby versions.
同样, Ruby 3.1.2,Rails 7.0.4 在将
大虾
添加到Gemfile之后。我不得不将gem'matrix'
添加到gemfile,并且有效。same here, ruby 3.1.2, rails 7.0.4 after adding
prawn
to gemfile. I had to addgem 'matrix'
to gemfile and it works.当升级 rails 6--> 7 和 Ruby 3.0.0-3.1.2 时,我也介绍了这个问题。
就我的情况而言,问题与Capybara Gem有关。版本
3.35.3
假定它默认使用Ruby安装。当我将Capybara升级到版本
3.37.1
时,也会自动安装矩阵GEM,并解决了问题。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.在添加 RubyStats GEM中,也使用Ruby 3.1.2和Rails 7.0.4添加 RubyStats GEM,就遇到了同一问题。
@siasmj的修复程序对我有用。
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.