系統爲mac os 10.11,command tool什麼的都安裝了html
在執行bundle install時出現下面錯誤:ruby
An error occurred while installing nokogiri (1.6.2.1), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.6.2.1'` succeeds before bundling.ide
往前翻了下,錯誤詳細爲:ui
Installing nokogiri 1.6.2.1 with native extensions Building nokogiri using packaged libraries. Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /usr/local/bin/ruby 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 necessary libraries and/or headers. Check the mkmf.log file for more details. You may need 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=/usr/local/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-build Gem files will remain installed in /Users/sophia/ashelf/vendor/bundle/gems/nokogiri-1.6.2.1 for inspection. Results logged to /Users/sophia/ashelf/vendor/bundle/gems/nokogiri-1.6.2.1/ext/nokogiri/gem_make.out
裏面有一句:「libiconv is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.」spa
試了一下這個方法:code
brew install libiconvhtm
brew link libiconvblog
而後看到輸出的連接地址爲「/usr/local/Cellar/libiconv/1.14/」ci
執行命令:rem
gem install nokogiri -v '1.6.2.1' -- --with-iconv-dir=/usr/local/Cellar/libiconv/1.14/
再bundle install仍是不行,最後找到一個方法:
bundle config build.nokogiri -v '1.6.2.1' \ --with-iconv-lib=/usr/local/lib \ --with-iconv-include=/usr/local/include
而後再bundle install 就能夠了。
上面的命令每次執行都沒有加 -v '1.6.2.1' ,因此一直裝的1.6.7.2,致使bundle install總失敗,好二啊/(ㄒoㄒ)/~~