以 root 身份在不使用 rvm 的情况下使用 ruby​​ 的显式版本安装 Gems

发布于 2024-12-08 14:52:35 字数 579 浏览 5 评论 0原文

我决定放弃 rvm,但我在使用新版本的 ruby​​ 1.9.2 编译 gem 时遇到了麻烦。 gem 需要 1.9.2,我有它,但说没有它就无法安装,所以错误消息没有意义。

我如何明确告诉 gem 使用所述版本的 ruby​​ 进行编译?

Gem::InstallError: linecache19 requires Ruby version >= 1.9.2.
An error occured while installing linecache19 (0.5.12), and Bundler cannot continue.
Make sure that `gem install linecache19 -v '0.5.12'` succeeds before bundling.
 apps2 ~/projects/sms/apps2/apps2_admin $ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.8.0]
 apps2 ~/projects/sms/apps2/apps2_admin $ which ruby
/usr/local/bin/ruby

I've decided to get rid of rvm, and I'm having trouble compiling a gem with my new version of ruby 1.9.2. The gem requires 1.9.2, I have it, yet says it can't install without, so the error messages makes no sense.

How can I explicitly tell the gem to compile with said version of ruby?

Gem::InstallError: linecache19 requires Ruby version >= 1.9.2.
An error occured while installing linecache19 (0.5.12), and Bundler cannot continue.
Make sure that `gem install linecache19 -v '0.5.12'` succeeds before bundling.
 apps2 ~/projects/sms/apps2/apps2_admin $ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.8.0]
 apps2 ~/projects/sms/apps2/apps2_admin $ which ruby
/usr/local/bin/ruby

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心在旅行 2024-12-15 14:52:35

我遇到了类似的问题,并追溯到该问题并解决如下:

问题的根源是在 gem installer.rb 文件中,从 linecache19 传递的所需 ruby​​ 版本是 1.9.2,而 Gem.ruby_version 类似于 1.9 .2.dev.30909,并且 ("1.9.2" >= "1.9.2.dev.30909") 为假。

所以首先要确保 ruby​​ 版本是 1.9.2:

ruby -v

然后手动使用 --force 绕过版本检查:

gem install ruby_core_source
gem install linecache19 --force

如果您遇到以以下行开头的另一个错误:

checking for vm_core.h... no
*** extconf.rb failed ***

您必须显式地将源路径设置为 vm_core.h

在我的情况下:

$ which ruby
/Users/Reza/.rvm/rubies/ruby-1.9.2-rc2/bin/ruby
$ echo $rvm_path
/Users/Reza/.rvm/

所以要安装 linecache19 :

gem install ruby_core_source
gem install linecache19 --force -- --with-ruby-include=$rvm_path/src/ruby-1.9.2-rc2/

ruby​​-debug19 有类似的问题:

gem install ruby-debug19 --force -- --with-ruby-include=$rvm_path/src/ruby-1.9.2-rc2/

仅此而已!

I had a similar issue and traced back the issue and solved it as follows:

The root of the issue is that in the gem installer.rb file the passed required ruby version from linecache19 is 1.9.2 while the Gem.ruby_version is something like 1.9.2.dev.30909, and ("1.9.2" >= "1.9.2.dev.30909") is false.

so first become sure that ruby version is 1.9.2:

ruby -v

then manually use --force to bypass version check:

gem install ruby_core_source
gem install linecache19 --force

if you faced with another error starting with following lines:

checking for vm_core.h... no
*** extconf.rb failed ***

You have to explicitly set the source path to vm_core.h

In my case:

$ which ruby
/Users/Reza/.rvm/rubies/ruby-1.9.2-rc2/bin/ruby
$ echo $rvm_path
/Users/Reza/.rvm/

so to install linecache19 :

gem install ruby_core_source
gem install linecache19 --force -- --with-ruby-include=$rvm_path/src/ruby-1.9.2-rc2/

ruby-debug19 has a similar issue:

gem install ruby-debug19 --force -- --with-ruby-include=$rvm_path/src/ruby-1.9.2-rc2/

That's all!

冰之心 2024-12-15 14:52:35

在 OS X Lion 上使用 rbenv 时,我遇到了同样的问题(linecache19 永远/无限期地挂起)。我发现解决方案是使用 OpenSSL 选项安装 Ruby,如下所示:

rbenv install 1.9.2-p290 --with-openssl-dir=/usr/local
rbenv rehash
rbenv global 1.9.2-p290

现在,您可以运行或捆绑它,它会安装得很好:

gem install ruby-debug19

希望对某人有所帮助。

I had the same issue (linecache19 hangs forever/indefinitely) when using rbenv on OS X Lion. I found the solution was to install Ruby with OpenSSL option, like this:

rbenv install 1.9.2-p290 --with-openssl-dir=/usr/local
rbenv rehash
rbenv global 1.9.2-p290

Now, you can run or bundle this and it'll install fine:

gem install ruby-debug19

Hope that helps someone.

眉黛浅 2024-12-15 14:52:35

这就是 Ubuntu 上的工作原理:

在遇到这个问题之前,我遇到了同样的问题并尝试了很多选择:
http://beginrescueend.com/packages/openssl/

$ rvm pkg install openssl
$ rvm remove 1.9.2
$ rvm install 1.9.2 --with-openssl-dir=$rvm_path/usr

这解决了 linecache19 ruby​​debug-19 和openssl:

*** extconf.rb failed ***
custom_require.rb:36:in `require': no such file to load -- openssl (LoadError)

那么你可以做

gem install ruby-debug19

This is what worked on Ubuntu:

I had the same problems and tried so many options before I came across this:
http://beginrescueend.com/packages/openssl/

$ rvm pkg install openssl
$ rvm remove 1.9.2
$ rvm install 1.9.2 --with-openssl-dir=$rvm_path/usr

This resolves the issue with linecache19 rubydebug-19 and openssl:

*** extconf.rb failed ***
custom_require.rb:36:in `require': no such file to load -- openssl (LoadError)

then you can do

gem install ruby-debug19
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文