在将 Mac 升级到 Lion 并从 App Store 安装了新的 Xcode 4.1 后,我尝试通过 RVM 安装最新版本的 Ruby。我在日志中收到此错误:
[2011-07-20 16:57:15] ./configure
--prefix=/Users/justin/.rvm/rubies/ruby-1.9.2-p290 --enable-shared
--disable-install-doc --with-libyaml-dir=/Users/justin/.rvm/usr
configure: WARNING: unrecognized options: --with-libyaml-dir
checking build system type... i386-apple-darwin11.0.0
checking host system type... i386-apple-darwin11.0.0
checking target system type...i386-apple-darwin11.0.0
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/Users/justin/.rvm/src/ruby-1.9.2-p290':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
谁能告诉我出了什么问题?
在终端中:
ruby-1.9.2-p290 - #extracted to /Users/justin/.rvm/src/ruby-1.9.2-p290 (already extracted)
Fetching yaml-0.1.4.tar.gz to /Users/justin/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/justin/.rvm/src
Configuring yaml in /Users/justin/.rvm/src/yaml-0.1.4.
ERROR: Error running ' ./configure --prefix="/Users/justin/.rvm/usr" ', please read /Users/justin/.rvm/log/ruby-1.9.2-p290/yaml/configure.log
Compiling yaml in /Users/justin/.rvm/src/yaml-0.1.4.
ERROR: Error running '/usr/bin/make ', please read /Users/justin/.rvm/log/ruby-1.9.2-p290/yaml/make.log
Installing yaml to /Users/justin/.rvm/usr
ERROR: Error running '/usr/bin/make install', please read /Users/justin/.rvm/log/ruby-1.9.2-p290/yaml/make.install.log
ruby-1.9.2-p290 - #configuring
ERROR: Error running ' ./configure --prefix=/Users/justin/.rvm/rubies/ruby-1.9.2-p290 --enable-shared --disable-install-doc --with-libyaml-dir=/Users/justin/.rvm/usr ', please read /Users/justin/.rvm/log/ruby-1.9.2-p290/configure.log
ERROR: There has been an error while running configure. Halting the installation.
Migrating gems from ruby-1.9.2-p180 to ruby-1.9.2-p290
ERROR: Ruby 'ruby-1.9.2-p290' is not installed - please install it first.
ERROR: Error migrating gems.
我的 $PATH 是:
/opt/local/bin
/opt/local/sbin
/Users/justin/.rvm/gems/ruby-1.9.2-p180/bin
/Users/justin/.rvm/gems/ruby-1.9.2-p180@global/bin
/Users/justin/.rvm/rubies/ruby-1.9.2-p180/bin
/Users/justin/.rvm/bin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin
/usr/X11/bin
/usr/local/mysql/bin
并且没有找到gcc
或。cc
~ $ type gcc
-bash: type: gcc: not found
~ $
~ $ type cc
-bash: type: cc: not found
~ $
答案1
我将在这里发布答案,以方便其他遇到同样问题的人。App Store 似乎终止了我的 Xcode 3.2.2 安装,而实际上并没有安装 4.1(也许安装新版本的 Xcode 或根本不安装任何版本会更好)。App Store 确实下载了一个Install Xcode.app
文件,我用它完成了安装——它默默地完成了这个操作,没有任何通知。
一旦 Xcode 再次启动并正确运行,Ruby 就能顺利执行。
答案2
新的 XCode 4.3 似乎在其偏好设置中有一个下载,可让您安装命令行工具。
答案3
在 Xcode (ver. 4.5.2) 中安装命令行工具(参见“首选项”->“下载”)为我解决了“在 $PATH 中未找到可接受的 C 编译器”问题。
答案4
升级到 OS X 10.7 之后,但在更新到 Xcode 4.1 之前,我在尝试安装 ruby1.9.2-p290 时收到相同的“没有可接受的 C 编译器”错误消息。
尝试PATH
编辑不是帮助解决这个问题。
不过,在 Xcode 4.1 更新之后,一切都运行正常,像往常一样:
cd ruby-1.9.x-pyyy
./configure --enable-shared --enable-pthread CFLAGS=-D_XOPEN_SOURCE=1
make
sudo make install
ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.0]