我尝试在我的 mac 10.6.8 上安装 ruby 版本 1.9.3:
$ \curl -L https://get.rvm.io | bash -s stable --ruby
Oskar-Niburskis-MacBook-Pro:~ oskarniburski$ rvm install ruby-1.9.3-p362
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.6/i386/ruby-1.9.3-p362.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Installing requirements for osx.
Updating system.............................................
Installing required packages: autoconf, automake, libtool, pkgconfig, libiconv, libyaml, libffi, readline, libksba, openssl, curl-ca-bundle, sqlite3, zlib, gdbm, ncurses...
Error running 'requirements_osx_port_libs_install autoconf automake libtool pkgconfig libiconv libyaml libffi readline libksba openssl curl-ca-bundle sqlite3 zlib gdbm ncurses',
please read /Users/oskarniburski/.rvm/log/1380238189_ruby-1.9.3-p362/package_install_autoconf_automake_libtool_pkgconfig_libiconv_libyaml_libffi_readline_libksba_openssl_curl-ca-bundle_sqlite3_zlib_gdbm_ncurses.log
Requirements installation failed with status: 1.
我的版本:
Oskar-Niburskis-MacBook-Pro:~ oskarniburski$ ruby --version
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin10.0]
日志文件的输出:
Oskar-Niburskis-MacBook-Pro:~ oskarniburski$ cat /Users/oskarniburski/.rvm/log/1380238189_ruby-1.9.3-p362/package_install_autoconf_automake_libtool_pkgconfig_libiconv_libyaml_libffi_readline_libksba_openssl_curl-ca-bundle_sqlite3_zlib_gdbm_ncurses.log
[2013-09-26 19:30:17] requirements_osx_port_libs_install
requirements_osx_port_libs_install ()
{
__rvm_try_sudo port install "$@" || {
typeset ret=$?;
rvm_warn "There were package installation errors, make sure to read the log.";
return $ret
}
}
current path: /Users/oskarniburski
command(16): requirements_osx_port_libs_install autoconf automake libtool pkgconfig libiconv libyaml libffi readline libksba openssl curl-ca-bundle sqlite3 zlib gdbm ncurses
Warning: Xcode does not appear to be installed; most ports will likely fail to build.
---> Computing dependencies for autoconfError: Unable to execute port: can't read "build.cmd": Failed to locate 'make' in path: '/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' or at its MacPorts configuration time location, did you move it?
There were package installation errors, make sure to read the log.
然后尝试使用MacPorts进行安装,但仍然无法正常工作。有任何想法吗?
Oskar-Niburskis-MacBook-Pro:~ oskarniburski$ sudo port install ruby19
Warning: Xcode does not appear to be installed; most ports will likely fail to build.
---> Computing dependencies for ruby19Error: Unable to execute port: can't read "build.cmd": Failed to locate 'make' in path: '/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' or at its MacPorts configuration time location, did you move it?
这是我现在的路径:
/opt/local/bin:/opt/local/sbin:/usr/local/git/bin:/usr/X11/bin:/Users/oskarniburski/.rvm/bin:/usr/X11R6/bin:/Library/ Frameworks/Python.framework/Versions/3.3/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/bin: /usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:/Users/oskarniburski/.rvm/bin
'which -a make' 和locate -b '\make' 都不是。第一个没有找到哪个命令,而后者则为locate:illegal option --b
答案1
问题1:make
第一个问题是 ruby 需要编译,这通常是通过make
它将从 a 读取设置Makefile
,然后调用编译器。在 OSX 上make
安装时Xcode
将其工具安装在/Developer/usr/bin
而不是/usr/bin
人们期望的位置。该目录不是默认目录,$PATH
因此 shell 找不到其中的任何可执行文件。
您可以通过将此行添加到您的用户中来修复此问题~/.bash_profile
(确保export $PATH
在行之前添加它):
PATH="/Developer/usr/bin:$PATH"
sudo
但是,以 root 身份运行的任何命令(例如)仍然无法访问该命令。我建议您将此目录添加到默认路径。打开/etc/profile
,找到定义路径的行并将目录添加到其中。我使用的是 Linux 系统,但它应该看起来像这样:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
只需将目录添加到该目录的末尾,如下所示:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/Developer/usr/bin"
如果您不想更改默认值,可以链接make
到默认值中的目录$PATH
:
sudo ln -s /Developer/usr/bin/make /usr/bin
您必须对其中的所有内容执行此操作,/Developer/usr/bin
因此我强烈建议您更改默认值。
问题2:寻找新版本
此时您应该能够安装 ruby
$ sudo port install ruby19
正确退出,但您的 ruby 版本似乎没有更新:
$ ruby --version
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin10.0]
这是因为,默认情况下,port
将其文件安装到/opt/local
并将您的 ruby 可执行文件安装为/opt/local/bin/ruby1.9
.还有一个目录不在您的$PATH
.因此,您可以重复上述过程并将其添加/opt/local/bin
到您的文件中$PATH
,也可以将ruby1.9
可执行文件链接到您路径中的目录。如果添加/opt/local/bin
到您的$PATH
,您将能够运行 v1.8ruby
和 v1.9 ruby1.9
。如果您希望所有现有脚本切换到 v1.9,我建议您选择/usr/bin/ruby
新版本。
旧版本/usr/bin
实际上是一个符号链接:
$ ls -l /usr/bin/ruby
rwxr-xr-x 1 root wheel 76 25 Jun 2010 /usr/bin/ruby -> ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby
这意味着您可以安全地删除它并将其替换为新版本的链接:
$ sudo rm /usr/bin/ruby; sudo ln -s /opt/local/bin/ruby1.9 /usr/bin/ruby
如果您想恢复并运行ruby
v1.8,只需运行相反的命令:
$ sudo rm /usr/bin/ruby; sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby /usr/bin/ruby
如果一切顺利,您的默认值ruby
现在是 v1.9:
$ ruby --version
ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin10]
答案2
看看这个要点。展示如何为 Mountain Lion 安装它。
重点介绍如何使用 MacPorts 或 Homebrew。一旦你明白了这一点,它就会显示如何使用 进行安装rvm
。