简体   繁体   English

捆绑器使用不同版本的红宝石

[英]Bundler using different version of ruby

I have installed ruby without using rvm. 我没有使用rvm安装了ruby。 the paths and version for ruby are as follows: 红宝石的路径和版本如下:

在此处输入图片说明

But when i run bundle install, a fatal error occurs. 但是,当我运行捆绑安装时,会发生致命错误。 It seems to use ruby version ruby1.9.1 from /usr/local/lib/ruby1.9.1 instead of usr/local/bin/ruby . 似乎使用/usr/local/lib/ruby1.9.1 ruby版本ruby1.9.1而不是usr/local/bin/ruby Following is the snapshot: 以下是快照:

在此处输入图片说明

How to make bundle install use ruby 1.9.3p0 instead of 1.9.1?? 如何使用ruby 1.9.3p0而不是1.9.1进行捆绑安装? Help! 救命!

Run rvm use ruby 1.9.3 运行rvm use ruby 1.9.3

You have to specify ruby version in gemfile 您必须在gemfile中指定ruby版本

ruby '1.9.3'

Then bundler will automatically detect the ruby version 然后捆绑器将自动检测红宝石版本

Its not using the wrong version of ruby. 它没有使用错误版本的红宝石。 Its just trying to install gems to that directory. 它只是试图将gems安装到该目录。 The real reason you're having problems is because your user doesn't have permission (you can be sure by typing whereis ruby ). 您遇到问题的真正原因是因为您的用户没有权限(您可以通过键入whereis ruby来确定)。 Even if running command with sudo worked you would still find yourself having many problems in the future. 即使使用sudo运行命令也可以,将来您仍然会遇到很多问题。 The reason these issues never occur with RVM is because RVM automatically changes the gem environment variables for your user. RVM永远不会发生这些问题的原因是RVM自动为您的用户更改gem环境变量。 For starters type gem env into your console. 首先,在控制台中输入gem env This will give you very important details about where rubygem searches for executables and paths. 这将为您提供有关rubygem在何处搜索可执行文件和路径的重要信息。

Under the GEM PATH section I see: GEM PATH部分下,我看到:

  • GEM PATHS: 创业板路径:
    • /Users/mike/.rvm/gems/ruby-1.9.3-p194 /用户/麦克/.rvm/gems/ruby-1.9.3-p194
    • /Users/mike/.rvm/gems/ruby-1.9.3-p194@global /Users/mike/.rvm/gems/ruby-1.9.3-p194@global

whereas it appears that your ruby installation is looking in /usr/local/lib, which is probably write protected. 而您的ruby安装似乎在/ usr / local / lib中查找,该位置可能已被写保护。 If you don't want to install RVM then the true fix is to create a directory in your user's root to install gems to. 如果您不想安装RVM,那么真正的解决方法是在用户的根目录中创建一个目录来安装gem。 Follow the first step from this guide to change your gem path. 按照本指南中的第一步更改宝石路径。

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

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