我正在尝试创建我的第一个 Ruby Rails 应用程序。
- 我使用的操作系统是 Mac OsX(Mavericks)。
- 我已经安装了最新版本的 xCode(我认为是版本 5),以及 命令行工具。
- 我已经安装了 Bitnami 组合 Ruby Stack。
- 我已经添加了 Rails(sudo gem install rails -V)。
直到创建自己的项目的所有步骤都可以正常工作——在这里查看。
在 Ruby 控制台中,我输入:
sudo rails new helloworld
然后它进行一些创建性工作,直到遇到以下几行:
run bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.1.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.8.4)
Using atomic (1.1.14)
Using thread_safe (0.1.3)
Using tzinfo (0.3.38)
Using activesupport (4.0.2)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.2)
Using mime-types (1.25.1)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.2)
Using activemodel (4.0.2)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.1)
Using activerecord (4.0.2)
Using bundler (1.3.5)
Using coffee-script-source (1.7.0)
Using execjs (2.0.2)
Using coffee-script (2.2.0)
Using thor (0.18.1)
Using railties (4.0.2)
Using coffee-rails (4.0.1)
Using hike (1.2.3)
Using jbuilder (1.5.3)
Using jquery-rails (3.1.0)
Installing json (1.8.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Applications/rubystack-1.9.3-19/ruby/bin/ruby extconf.rb
creating Makefile
make
compiling generator.c
sh: line 1: 58350 Trace/BPT trap: 5 /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk / -find gcc 2> /dev/null
gcc: error: unable to find utility "gcc", not a developer tool or in PATH
make: *** [generator.o] Error 72
Gem files will remain installed in /Applications/rubystack-1.9.3-19/ruby/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection.
Results logged to /Applications/rubystack-1.9.3-19/ruby/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.8.1), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.1'` succeeds before bundling.
在rubyconsole中安装json-1.8.1无法正常工作 - 我会得到以下错误:
sudo gem install json -v '1.8.1'
bash-3.2$ sudo gem install json -v '1.8.1'
Password:
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/Applications/rubystack-1.9.3-19/ruby/bin/ruby extconf.rb
creating Makefile
make
compiling generator.c
sh: line 1: 60535 Trace/BPT trap: 5 /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk / -find gcc 2> /dev/null
gcc: error: unable to find utility "gcc", not a developer tool or in PATH
make: *** [generator.o] Error 72
Gem files will remain installed in /Applications/rubystack-1.9.3-19/ruby/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection.
Results logged to /Applications/rubystack-1.9.3-19/ruby/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
在rubyconsole之外它可以工作。然而,这并不能解决上述问题。
我按照以下步骤进行操作:
如何在Mac OS X 10.8 / Xcode 4.4上使用/安装gcc
我还按照这里的步骤进行操作:
http://new-bamboo.co.uk/blog/2013/10/24/3-quick-tips-for-coding-with-os-x-10-9-mavericks
任何帮助都将不胜感激..谢谢,乔治更新:我运行了以下代码:
cd /usr/bin
sudo mv gcc gcc_mavs
sudo ln -s /usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2 gcc
现在我收到了一个不同的错误信息:
Installing json (1.8.1)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Applications/rubystack-1.9.3-19/ruby/bin/ruby extconf.rb
creating Makefile
make
compiling generator.c
sh: line 1: 67709 Trace/BPT trap: 5 /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk / -find as 2> /dev/null
as: error: unable to find utility "as", not a developer tool or in PATH
make: *** [generator.o] Error 2
Gem files will remain installed in /Applications/rubystack-1.9.3-19/ruby/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection.
Results logged to /Applications/rubystack-1.9.3-19/ruby/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
An error occurred while installing json (1.8.1), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.1'` succeeds before bundling.