44

我想知道在 Ubuntu 9.04 上安装最新版本的 Ruby。现在我可以很好地运行这些./configure东西make,但我想知道的是:如何避免与包装系统的冲突?例如,如果我安装的其他一些包依赖于 Ruby,包管理器不会安装(过时的)Ruby 包并在最坏的情况下覆盖我的文件吗?

所以我想我需要一些方法来告诉 Ubuntu 实际上已经安装了 Ruby?

4

8 回答 8

61

省去你的头疼并使用RVMRuby 版本管理器

请记住,Rails 3 最适合 Ruby 1.9.2。Ruby 1.9.2 修复了 1.9.1 中的许多错误,并且比运行 1.9.1 更可取。

使用 RVM 安装 1.9.2 轻而易举。

于 2009-12-03T06:43:12.430 回答
34
sudo apt-get install ruby1.9.1-full

( http://www.ruby-lang.org/en/downloads/ )

于 2010-03-14T22:21:46.520 回答
28

运行后

sudo apt-get install ruby1.9.1-full

它的解决方案是运行以​​下命令:

sudo update-alternatives --config ruby

然后你会得到这个输出:

   There are 2 choices for the alternative ruby (providing /usr/bin/ruby).

     Selection    Path                Priority   Status
   ------------------------------------------------------------
   * 0            /usr/bin/ruby1.8     50        auto mode
     1            /usr/bin/ruby1.8     50        manual mode
     2            /usr/bin/ruby1.9.1   10        manual mode

   Press enter to keep the current choice[*], or type selection number: 2
   update-alternatives: using /usr/bin/ruby1.9.1 to provide /usr/bin/ruby (ruby) in    manual mode.
   $ ruby --version
   ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]

此解决方案的功劳归于回答https://askubuntu.com/questions/91693/how-do-you-uninstall-ruby-1-8-7-and-install-ruby-1-9-2的人。目前 ruby​​1.9.1 包实际上是 ruby​​ 1.9.2。

于 2012-03-24T06:30:04.823 回答
7

The way I did it was to build it using checkinstall which lets you build a deb package. So I downloaded the Ruby 1.9.1 source, did a "configure" and then "make", did a "checkinstall" and made the package name ruby1.9 so it installs as if it were a new version of ruby 1.9 (as it should).

于 2009-07-12T07:08:21.800 回答
4

我从这个站点获得了 Ruby 的特定信息。您可以使用 --prefix=/path 开关将大多数软件安装在不同的目录中。通常安装在 /opt/ 中供您 PC 上的每个人使用,或者安装在 $HOME 中(如果它仅适用于您)。

在 /opt 中安装:

$ ./configure –prefix=/opt/ruby
$ make install

如果你想使用 /opt 安装的 ruby​​,编辑你 ~/.bashrc 并添加

export PATH=/opt/ruby/bin/:$PATH

如果您不想将自定义 Ruby 构建作为默认设置,您可以将其添加到 ~/.bashrc 而不是以前的命令

function setupruby {
     export PATH=/opt/ruby/bin/:$PATH
}
于 2009-07-10T14:07:24.013 回答
4

这是安装 1.9.1 并将其设置为默认值的一种简短方便的方法: http ://michalf.me/blog:make-ruby-1-9-default-on-ubuntu-9-10-karmic-koala

于 2010-03-16T16:45:12.457 回答
1

我为 ruby​​ 1.9.2 创建了一个启动板 ppa。以下链接中的详细信息

http://www.humbug.in/2010/launchpad-ppa-for-ruby-1-9-2-and-some-ruby-bindings/

sudo add-apt-repository ppa:pratikmsinha/ruby192+bindings
cd /etc/apt/sources.list.d/; sudo mv pratikmsinha-ruby192+bindings-lucid.list pratikmsinha-ruby192bindings-lucid.list
sudo aptitude update
sudo aptitude install ruby1.9.2
于 2010-08-02T16:46:10.713 回答
0

纵观 Synaptic,您似乎甚至不必处理 Multiverse 或第三方存储库。但由于sudo apt-get install ruby当前安装了别名ruby1.8,您应该ruby1.9显式安装 - 手动或通过存储库 - 并ruby自己创建别名。

您可能希望将二进制文件放入/usr/bin其中,因为无论如何发行版都会将其放入其中。不过,PATH 上的任何地方都可以。

于 2009-07-10T14:12:14.867 回答