RVM发现系统宝石的可执行文件 [英] RVM finding system gems' executables

查看:179
本文介绍了RVM发现系统宝石的可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了RVM以及ruby版本。但是,如果我启动了控制台并运行命令栏服务器,捆绑安装等,我收到了这个错误消息

  bash:/ usr / bin / rails:/usr/bin/ruby1.8:糟糕的解释器:没有这样的文件或目录



<但是如果我运行 rvm首先使用1.9.2 ,那么一切都可以。我试过使用`rvm use --default 1.9.2',但没有任何改变。这是否意味着它使用与RVM中的不同的ruby?提前感谢!

解决方案

ruby​​gems bin文件夹和PATH的解释

哦。你没有在你的rvm ruby​​中安装rails,但是你在你的系统中使用ruby。

个别宝石,如 rails 可以有一个 bin 包含可执行帮助程序脚本的目录。您的系统默认rubygems正在将系统/ usr / bin / dir中的符号链接插入这些助手可执行文件的gem的 bin 文件夹中。



RVM提供了类似的功能,除了不会污染系统/ usr / bin目录,它只是追加其 〜/ .rvm / gems /#{rvm_gemset_string} / bin 文件夹复制到PATH环境变量。






导入系统Rubygems列表你的新rvm rubies的宝石目录



默认情况下,RVM不会将你的宝石从系统ruby安装导入到你的rvm ruby​​安装中。它使整个ruby系统(包括rubygems(宝石'rubygems')和rubygems的宝石列表)完整整洁。当你 rvm install 1.9.2 就好像你已经做了一个全新的ruby安装。



如果您想将您之前使用的所有系统ruby宝石放入您的首选rvm ruby​​中,请尝试以下操作:

  rvm使用系统
rvm gemset export system.gems
rvm use 1.9.2
rvm gemset import system.gems
#现在您将所有系统宝石重新安装到您的新的ruby版本






原始回答/编辑从@Telemachus



尝试将源代码rvm的行移动到〜/ .bash_profile 或〜/ .bashrc (无论你在哪里):

 '[[-s$ HOME / .rvm / scripts / rvm]]&& 。 $ HOME / .rvm / scripts / rvm#Load RVM function'

  bash:/ usr / bin / rails:/usr/bin/ruby1.8:糟糕的解释器:没有这样的文件... 
| | ^ -------------------------------- \
^ Bash,而不是rvm; ^ / usr / bin / rails,而不是〜/ .rvm / gems / * / bin / rails; |
从前一次安装中剩余的一些ruby到os

您在 / usr / bin ,它可能位于bash echo $ PATH 变量中的rvm ruby​​ bin路径之前,所以它找到系统导轨安装(/ usr / bin / rails,一个ruby脚本),它是这样启动的:

#! / usr / bin / ruby​​18



您必须使冲突停止,最好的方法是确保RVM的bin目录位于PATH的开头。这发生在安装rvm时添加到〜/ .bash_profile 中的 #Load rvm环境脚本中。如果您将rvm作为系统库安装,而不仅仅是针对您的用户,这将会有所不同。



如果您遇到这种情况,请咨询@Telemachus。



然后你需要确保你已经得到了安装在你的新rvm ruby​​中的rails gem。



验收测试:



当您完成 rvm时,您会发现使用1.9.2 ,那么 ruby​​ 会返回类似于〜/ .rvm / rubies / 1.9.2 / bin / ruby​​ ,和,其中rails 应该返回类似于〜/ .rvm / gems / * / bin / rails


I have installed RVM along with ruby versions. However if I fire up the console and run the command rails server, bundle install, etc. I get this error

bash: /usr/bin/rails: /usr/bin/ruby1.8: bad interpreter: No such file or directory

But if I run rvm use 1.9.2 first, then everything is ok. I tried using `rvm use --default 1.9.2' but nothing changed. Does this mean it uses a different ruby from the ones in RVM? Thanks in advance!

解决方案

Explanation of rubygems bin folders and PATH

Oh. You didn't have rails installed in your rvm ruby, but you did in your system ruby.

Individual gems, like rails can have a bin directory that will contain executable helper scripts. Your system default rubygems is making symlinks from your system /usr/bin/ dir into the gem's bin folder for these helper executables.

RVM provides a similar facility, except instead of polluting the system /usr/bin dir, it just appends its ~/.rvm/gems/#{rvm_gemset_string}/bin folder to the PATH environment variable.


Importing system Rubygems list into your new rvm rubies' gem directories

RVM by default will not import your gems from your system ruby installation into your rvm ruby installs. It makes a full clean fork of the entire ruby system including rubygems (the gem 'rubygems') and rubygems' gem list. When you rvm install 1.9.2 it's like you've made a completely new install of everything used with ruby.

If you'd like to get all your system ruby gems that you were previously using into your preferred rvm ruby, try this:

  rvm use system
  rvm gemset export system.gems
  rvm use 1.9.2
  rvm gemset import system.gems
  #You'll now have all your system gems reinstalled to your new ruby version


Original Answer/ Edits from @Telemachus

Try moving the lines that source rvm to the end of your ~/.bash_profile or ~/.bashrc (whichever you have it in):

'[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function'

.

bash: /usr/bin/rails: /usr/bin/ruby1.8: bad interpreter: No such file ...
|                 |                 ^--------------------------------\
^ Bash, not rvm;  ^/usr/bin/rails, not ~/.rvm/gems/*/bin/rails;      |
                       Some ruby leftover from a previous install in the os

You have rails installed in /usr/bin, which is probably before the rvm ruby bin path in your bash echo $PATH variable, so it's finding the system rails install (/usr/bin/rails, a ruby script) which starts like this:

#! /usr/bin/ruby18

You've gotta make the conflict stop happening, the best of all possible ways is making sure that RVM's bin dir is at the beginning of your PATH. This happens in the #Load rvm environment script that you added to your ~/.bash_profile when installing rvm. If you installed rvm as a system library rather than just for your user, this will be different.

If you get to that case, ask @Telemachus.

You'll then need to ensure you've gotten the rails gem installed in your new rvm ruby as above.

Acceptance Test:

You'll find that when you've done rvm use 1.9.2, then which ruby will return something like ~/.rvm/rubies/1.9.2/bin/ruby, and which rails should return something like ~/.rvm/gems/*/bin/rails.

这篇关于RVM发现系统宝石的可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆