无法在OS X Mavericks上降级Ruby

Ale*_*oul 6 ruby macos xcode rvm osx-mavericks

OS X 10.9附带ruby 2.0.0p195,但我需要安装Ruby 1.8.7.我一直遇到错误.我有Xcode5-DP安装,我相信也安装了命令行工具.

在终端:

sudo rvm install 1.8.7
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10/x86_64/ruby-1.8.7-p371.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies.
Installing requirements for osx, might require sudo password.
Certificates in '/usr/local/etc/openssl/cert.pem' already are up to date.
Installing Ruby from source to: /Users/alextoul/.rvm/rubies/ruby-1.8.7-p371, this may take a while depending on your cpu(s)...
ruby-1.8.7-p371 - #downloading ruby-1.8.7-p371, this may take a while depending on your connection...
ruby-1.8.7-p371 - #extracted to /Users/alextoul/.rvm/src/ruby-1.8.7-p371 (already extracted)
Patch stdout-rouge-fix was already applied.
Patch no_sslv2 was already applied.
ruby-1.8.7-p371 - #configuring...
Error running 'env CFLAGS=-O3 -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libxml2/include -I/usr/local/opt/libxslt/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl098/include LDFLAGS=-L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libxml2/lib -L/usr/local/opt/libxslt/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl098/lib ./configure --prefix=/Users/alextoul/.rvm/rubies/ruby-1.8.7-p371 --disable-install-doc --without-tcl --without-tk --enable-shared',
please read /Users/alextoul/.rvm/log/ruby-1.8.7-p371/1371228839_configure.log
There has been an error while running configure. Halting the installation.
Run Code Online (Sandbox Code Playgroud)

1371228839_configure.log说:

./configure
configure: WARNING: unrecognized options: --without-tcl, --without-tk
checking build system type... i686-apple-darwin13.0.0
checking host system type... i686-apple-darwin13.0.0
checking target system type... i686-apple-darwin13.0.0
checking whether the C compiler works... no
configure: error: in `/Users/alextoul/.rvm/src/ruby-1.8.7-p371':
configure: error: C compiler cannot create executables
See `config.log' for more details
Run Code Online (Sandbox Code Playgroud)

其他(有用的)信息:

ruby -v
> ruby 2.0.0p195 (2013-05-14 revision 40734) [universal.x86_64-darwin13]
brew update
> Already up-to-date.
gcc --version
> Configured with: --prefix=/Applications/Xcode5-DP.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode5-DP.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1
> Apple LLVM version 5.0 (clang-500.1.58) (based on LLVM 3.3svn)
> Target: x86_64-apple-darwin13.0.0
> Thread model: posix
sudo rvm requirements
> Installing requirements for osx, might require sudo password.
> Certificates in '/usr/local/etc/openssl/cert.pem' already are up to date.
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助.

Rya*_*cox 13

10.9是OS的早期beta版本.[ 编辑:请注意2013年7月的答案日期 ]如果我运行10.9我会假设我必须从头开始重新安装操作系统至少2次.(至少在测试周期期间一次,因为,它是测试版,一旦10.9在一般发布时出现,因为,好吧,测试版).

鉴于此,我建议采取四种行动方案(选择1个或多个):

  • 与RVM人员合作,深入研究10.9可能改变的编译器环境并获得Ruby 1.8.7编译.这比较棘手,因为技术上这些东西都在NDA之下.
  • 相反,设置VM并在VM上运行Ruby 1.8.7.使用Vagrant和Chef/Puppet的加分点,因为您甚至可能需要重建VM.(只需将Vagrantfile和Puppet或Chef配置文件保存在Github/Dropbox /中,这样您就可以克隆它们并从头开始重新生成VM.)
  • 或者只需重新启动到10.8即可完成生产工作.10.8是生产级操作系统,10.9应该谨慎对待 - 它可能会吃掉你的工作.它实际上不应该用于生产目的(又名:日常编写Ruby代码).如果你在Cocoa/Objective-C中编写一个仅有10.9的应用程序(或者更新RubyMotion或其他东西),这可能是另一回事(但我仍然保持良好的备份并轻轻地对待它).
  • 努力更新Ruby 2.0的代码库,因为Ruby 1.8.7不再正式支持.

编辑(2013年10月24日):如果您因为刚安装了Mavericks(2013年10月22日发布)而来到这里,那么想在本版本发布后的几天内让Ruby 1.8.7正常运行,并且RVM不适合您(因为你不耐烦而且等不及了),这就是你可以做的事情(虽然我不是rbenv用户,但应该可以工作):

  1. 使用macports安装port install ruby.这是Ruby 1.8.7.这个编译在我的Mavericks机器上适用于我(虽然你需要在编写时从源代码安装Macports 安装命令行开发人员工具,即使你安装了XCode 5.是的,真的).
  2. 现在,安装rbenv.
  3. 符号链接/opt/local/bin/ruby1.8~/.rbenv/versions/的文件夹.特别~/.rbenv/versions/ruby-1.8.7-p374
  4. 阅读rbenv文档,但它现在应该工作!(至少从文档中看.再次,不是rbenv用户,而是在电视上播放)

我相信你也可以用自制软件做到这一点,但我知道Ruby 1.8.7可以正确安装最新的Macports,因为这就是我使用的(它只是为我安装干净).


kon*_*rad 10

当您看到此错误消息时:

configure:error:C编译器无法创建可执行文件:

首先,确保已升级命令行工具:

$ xcode-select --install
Run Code Online (Sandbox Code Playgroud)

现在Apple希望您在使用这些工具之前同意他们的许可证:

$ gcc
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.

$ sudo gcc
You have not agreed to the Xcode license agreements. You must agree to both license agreements below in order to use Xcode.
[...]
Run Code Online (Sandbox Code Playgroud)

接受后,命令行工具将按预期工作.


Dav*_*las 8

如果您已在OS X Mavericks上安装了开发人员工具,则已经安装了Ruby 1.8和2.0.所以你需要做的就是切换'Current'符号链接指向1.8目录.

#Install Xcode Developer tools
xcode-select --install

#Delete Current symbolic link to Ruby 2.0
sudo rm /System/Library/Frameworks/Ruby.framework/Versions/Current

#Create new Current symbolic link to Ruby 1.8
sudo ln -s /System/Library/Frameworks/Ruby.framework/Versions/1.8 /System/Library/Frameworks/Ruby.framework/Versions/Current

#Check Ruby version is 1.8.7
ruby -v
Run Code Online (Sandbox Code Playgroud)