首页 > 代码库 > Mac上RoR环境搭建问题

Mac上RoR环境搭建问题

昨天一晚上折磨的我啊都快疯掉了。

按照http://railstutorial-china.org方法配制,到rvm requirements这个命令执行时就麻烦事来了。

WutekiMacBook-Pro:~ wuxj$ rvm requirementsChecking requirements for osx.Error: No available formula for gcc46 Installing requirements for osx.Updating system.......Error running ‘requirements_osx_brew_update_system ‘,showing last 15 lines of /Users/wuxj/.rvm/log/1409358409/update_system.log    https://github.com/Homebrew/homebrew/wiki/Common-Issuesand make sure `brew update` works before continuing.‘+ rvm_pretty_print stderr+ case "${rvm_pretty_print_flag:=auto}" in+ case "${TERM:-dumb}" in+ case "$1" in+ [[ -t 2 ]]+ return 1+ printf %b ‘Failed to update Homebrew, follow instructions here:    https://github.com/Homebrew/homebrew/wiki/Common-Issuesand make sure `brew update` works before continuing.\n‘Failed to update Homebrew, follow instructions here:    https://github.com/Homebrew/homebrew/wiki/Common-Issuesand make sure `brew update` works before continuing.+ return 1Requirements installation failed with status: 1.

开始以为是Homebrew没更新,所以执行了下brew update,结果:

WutekiMacBook-Pro:~ wuxj$ brew updateerror: The following untracked working tree files would be overwritten by merge:    Library/Formula/ant.rb    Library/Formula/libarchive.rbPlease move or remove them before you can merge.AbortingError: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

执行了下brew doctor

WutekiMacBook-Pro:~ wuxj$ brew doctorWarning: Some directories in your path end in a slash.Directories in your path should not end in a slash. This can break otherdoctor checks. The following directories should be edited:    /Users/wuxj/Downloads/adt-bundle-mac-x86_64-20131030/sdk/platform-tools/Error: Homebrew doesn‘t know what compiler versions ship with your versionof Xcode (5.1.1). Please `brew update` and if that doesn‘t help, filean issue with the output of `brew --config`:  https://github.com/mxcl/homebrew/issuesThanks!

执行bundle

。。。Gem::Ext::BuildError: ERROR: Failed to build gem native extension.    /Users/wuxj/.rvm/rubies/ruby-2.1.2/bin/ruby -r ./siteconf20140830-1163-1hd6znq.rb extconf.rb Building nokogiri using packaged libraries.-----libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.-----*** extconf.rb failed ***Could not create Makefile due to some reason, probably lack of necessarylibraries and/or headers.  Check the mkmf.log file for more details.  You mayneed configuration options.Provided configuration options:    --with-opt-dir    --without-opt-dir    --with-opt-include    --without-opt-include=${opt-dir}/include    --with-opt-lib    --without-opt-lib=${opt-dir}/lib    --with-make-prog    --without-make-prog    --srcdir=.    --curdir    --ruby=/Users/wuxj/.rvm/rubies/ruby-2.1.2/bin/ruby    --help    --clean    --use-system-libraries    --enable-static    --disable-static    --with-zlib-dir    --without-zlib-dir    --with-zlib-include    --without-zlib-include=${zlib-dir}/include    --with-zlib-lib    --without-zlib-lib=${zlib-dir}/lib    --enable-cross-build    --disable-cross-buildextconf failed, exit code 1Gem files will remain installed in /Users/wuxj/.rvm/gems/ruby-2.1.2/gems/nokogiri-1.6.3.1 for inspection.Results logged to /Users/wuxj/.rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.3.1/gem_make.outAn error occurred while installing nokogiri (1.6.3.1), and Bundler cannot continue.Make sure that `gem install nokogiri -v ‘1.6.3.1‘` succeeds before bundling.

依然不行,执行 gem install nokogiri -v ‘1.6.3.1‘ , 还是不行。

WutekiMacBook-Pro:sample_app wuxj$ gem install nokogiriBuilding native extensions.  This could take a while...Building nokogiri using packaged libraries.ERROR:  Error installing nokogiri:    ERROR: Failed to build gem native extension.    /Users/wuxj/.rvm/rubies/ruby-2.1.2/bin/ruby -r ./siteconf20140830-1261-1vvz386.rb extconf.rbBuilding nokogiri using packaged libraries.-----libiconv is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.-----*** extconf.rb failed ***Could not create Makefile due to some reason, probably lack of necessarylibraries and/or headers.  Check the mkmf.log file for more details.  You mayneed configuration options.Provided configuration options:    --with-opt-dir    --without-opt-dir    --with-opt-include    --without-opt-include=${opt-dir}/include    --with-opt-lib    --without-opt-lib=${opt-dir}/lib    --with-make-prog    --without-make-prog    --srcdir=.    --curdir    --ruby=/Users/wuxj/.rvm/rubies/ruby-2.1.2/bin/ruby    --help    --clean    --use-system-libraries    --enable-static    --disable-static    --with-zlib-dir    --without-zlib-dir    --with-zlib-include    --without-zlib-include=${zlib-dir}/include    --with-zlib-lib    --without-zlib-lib=${zlib-dir}/lib    --enable-cross-build    --disable-cross-buildextconf failed, exit code 1Gem files will remain installed in /Users/wuxj/.rvm/gems/ruby-2.1.2/gems/nokogiri-1.6.3.1 for inspection.Results logged to /Users/wuxj/.rvm/gems/ruby-2.1.2/extensions/x86_64-darwin-13/2.1.0-static/nokogiri-1.6.3.1/gem_make.out

最后,在stackoverflow上找到个大神解救了我。就是各种brew安装啊。。。

brew install autoconfbrew install automakebrew install libtoolbrew install ap
ple-gcc42brew install libyamlbrew install libxsltbrew install libksbabrew install openssl

结果

WutekiMacBook-Pro:sample_app wuxj$ rvm requirementsChecking requirements for osx.Updating certificates in ‘/usr/local/etc/openssl/cert.pem‘.Requirements installation successful.

终于解决了。

Mac上RoR环境搭建问题