简体   繁体   English

捆绑安装时的Ruby Gem LoadError

[英]Ruby Gem LoadError on bundle install

In my rails project I called 'bundle install' in the terminal to add a gem but received the following error message: 在我的rails项目中,我在终端中调用“捆绑安装”以添加gem,但收到以下错误消息:

Traceback (most recent call last): 3: from /Users/usr/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:in <main>' 2: from /Users/usr/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:in eval' 1: from /Users/usr/.rvm/gems/ruby-2.5.1/bin/bundle:23:in <main>' /Users/usr/.rvm/gems/ruby-2.5.1/bin/bundle:23:in load': cannot load such file -- /Users/usr/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/2.5.0/gems/bundler-> 1.16.5/exe/bundle (LoadError) 追溯(最近一次通话):3:从/Users/usr/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:在<main>' 2: from /Users/usr/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:24:in :from /Users/usr/.rvm/gems/ruby-2.5.1/bin/bundle:23:in <main>' /Users/usr/.rvm/gems/ruby-2.5.1/bin/bundle:23:in load':无法加载此类文件-/Users/usr/.rvm/rubies/ruby-2.5.1/lib/ruby/gems/ 2.5.0 / gems / bundler-> 1.16.5 / exe / bundle(LoadError)

My operating system is macOS High Sierra. 我的操作系统是macOS High Sierra。 Any suggestions on how to overcome this error would be much appreciated. 任何有关如何克服此错误的建议将不胜感激。

the problem is that the path is for another ruby version uninstall the gem then go to your project folder and use this command 问题是路径是另一个红宝石版本,请卸载gem,然后转到您的项目文件夹并使用此命令

rvm use 2.5.1 and then try to bundle again rvm使用2.5.1 ,然后尝试再次捆绑

if that doesn't work because you don't have rvm try to install ruby with rvm because it allows you to switch different versions of ruby at any time 如果由于您没有rvm而无法使用,请尝试使用rvm安装ruby,因为它允许您随时切换不同版本的ruby

Try creating a .ruby-version file in the root of your project with the version of Ruby you want to target eg 2.5.1 . 尝试在项目的根目录中使用您要定位的Ruby .ruby-version创建一个.ruby-version文件,例如2.5.1

This will give RVM - which it seems like you're using based on the file paths in the stacktrace - a firm version to target for every command as opposed to rvm use which is only has a half-life of the duration of the current shell session and less reliable. 这将提供RVM-似乎您正在基于rvm use的文件路径使用-为每个命令定位的固定版本,而不是rvm use ,后者仅具有当前shell持续时间的半衰期会话,不太可靠。

Good Luck! 祝好运!

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

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