如何在 Fedora 上升级 Ruby

发布于 2024-12-23 08:31:30 字数 1821 浏览 1 评论 0原文

我正在尝试使用 rvm< 在 Fedora 13 上将 Ruby 升级到 1.8.7(是的,我知道它很旧) /a>.我对 Ruby 世界有点陌生,但这就是我到目前为止所做的:

~$ yum -y install rubygem-rvm
...
~$ rvm-install
...
~$ rvm install 1.8.7
/usr/local/rvm/rubies/ruby-1.8.7-p302, this may take a while depending on your cpu(s)...

ruby-1.8.7-p302 - #fetching 
ruby-1.8.7-p302 - #extracted to /usr/local/rvm/src/ruby-1.8.7-p302 (already extracted)
ruby-1.8.7-p302 - #configuring 
ruby-1.8.7-p302 - #compiling 
ruby-1.8.7-p302 - #installing 
ruby-1.8.7-p302 - #rubygems installing to ruby-1.8.7-p302
ruby-1.8.7-p302 - adjusting #shebangs for (gem).
ruby-1.8.7-p302 - #importing default gemsets (/usr/local/rvm/gemsets/)
Install of ruby-1.8.7-p302 - #complete 
~$ rvm use 1.8.7 --default
Using /usr/local/rvm/gems/ruby-1.8.7-p302
~$ ruby -v
ruby 1.8.6 (2010-09-02 patchlevel 420) [x86_64-linux]
~$ rvm use 1.8.7
Using /usr/local/rvm/gems/ruby-1.8.7-p302
~$ ruby -v
ruby 1.8.6 (2010-09-02 patchlevel 420) [x86_64-linux]

一切似乎都运行良好,除了 Ruby 1.8.6 仍然是默认版本。

将默认 Ruby 版本切换到 1.8.7 时我还缺少哪些其他步骤?

编辑:rvm 中似乎有一些非常不直观的行为。如果您不安装某些软件包,那么当您使用 rvm 安装特定的 Ruby 版本时,rvm 不仅不会构建或安装该 Ruby 版本,甚至不会告诉您它没有构建 Ruby。我注意到 /usr/local/rvm/gems/ruby-1.8.7-p302 中没有 bin 目录...这很不寻常,因为 Ruby 是一个二进制文件。因此,我仔细检查了文档,找到了要安装的 Fedora 软件包列表:

yum install -y bash curl git
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel
yum install -y iconv-devel

安装这些软件包后,运行 rvm install 1.8.7 正确构建了一个 Ruby 二进制文件。奇怪的是,运行 rvm use 1.8.7 --default 仍然不会更新默认的 Ruby 版本,所以我这样做了:

cp /usr/bin/ruby /usr/bin/ruby-1.8.6
rm -f /usr/bin/ruby
ln -s /usr/local/rvm/rubies/ruby-1.8.7-p302/bin/ruby /usr/bin/ruby

I'm trying to upgrade Ruby to 1.8.7 on Fedora 13 (yes I know it's old) using rvm. I'm a little new to the Ruby world, but this is what I've done so far:

~$ yum -y install rubygem-rvm
...
~$ rvm-install
...
~$ rvm install 1.8.7
/usr/local/rvm/rubies/ruby-1.8.7-p302, this may take a while depending on your cpu(s)...

ruby-1.8.7-p302 - #fetching 
ruby-1.8.7-p302 - #extracted to /usr/local/rvm/src/ruby-1.8.7-p302 (already extracted)
ruby-1.8.7-p302 - #configuring 
ruby-1.8.7-p302 - #compiling 
ruby-1.8.7-p302 - #installing 
ruby-1.8.7-p302 - #rubygems installing to ruby-1.8.7-p302
ruby-1.8.7-p302 - adjusting #shebangs for (gem).
ruby-1.8.7-p302 - #importing default gemsets (/usr/local/rvm/gemsets/)
Install of ruby-1.8.7-p302 - #complete 
~$ rvm use 1.8.7 --default
Using /usr/local/rvm/gems/ruby-1.8.7-p302
~$ ruby -v
ruby 1.8.6 (2010-09-02 patchlevel 420) [x86_64-linux]
~$ rvm use 1.8.7
Using /usr/local/rvm/gems/ruby-1.8.7-p302
~$ ruby -v
ruby 1.8.6 (2010-09-02 patchlevel 420) [x86_64-linux]

Everything seems to run fine, except Ruby 1.8.6 is still the default version.

What other steps am I missing to switch the default Ruby version to 1.8.7?

EDIT: It seems there's some really unintuitive behavior in rvm. If you don't install certain packages, then when you use rvm to install a specific Ruby version, rvm not only won't build or install that Ruby version, it won't even tell you it's not building Ruby. I noticed there was no bin directory in /usr/local/rvm/gems/ruby-1.8.7-p302...which was unusually, being that Ruby is a binary and all. So I double checked the docs, and found a list of Fedora packages to install:

yum install -y bash curl git
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel
yum install -y iconv-devel

After those were installed, running rvm install 1.8.7 correctly built a Ruby binary. Oddly, running rvm use 1.8.7 --default still doesn't update the default Ruby version, so I did:

cp /usr/bin/ruby /usr/bin/ruby-1.8.6
rm -f /usr/bin/ruby
ln -s /usr/local/rvm/rubies/ruby-1.8.7-p302/bin/ruby /usr/bin/ruby

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

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

发布评论

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

评论(2

倒数 2024-12-30 08:31:30

请务必在运行 rvm use 1.8.7 的同一 shell 中运行 ruby -v。我不确定 --default 选项的作用,所以尝试将其关闭。

Be sure to run ruby -v in the same shell where you ran rvm use 1.8.7. I'm not sure what the --default option does so try leaving it off.

孤云独去闲 2024-12-30 08:31:30

情况并不乐观,这可能有几件事。我的猜测是这样的。

您可能需要切换链接器以指向新安装(/usr/bin/ 中的“快捷方式”文件)。查找新版本 ruby​​ 的安装位置。如果 /usr/bin/ 中的“ruby”链接器未指向此新安装,请通过右键单击 ruby​​ 可执行文件并创建一个链接来创建新链接,并将其放在 /usr/bin/ 中。

这是我唯一的猜测,当我安装新版本的 python 时遇到了这个问题。

Not positive, this could be a few things. My guess is this though.

You might need to switch the linker to point at your new installation (the "shortcut" file in /usr/bin/). Find where you installed your new version of ruby. If the "ruby" linker in /usr/bin/ does not point to this new installation, make a new link by right-clicking on the ruby executable and make a link, put it /usr/bin/.

That's my only guess, I had this problem when I installed a new version of python.

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