運行rails new APP
的時候,常常會卡住,或者出現相似如下的提示spring
Gem::RemoteFetcher::FetchError: Errno::EINVAL: Invalid argument - setsockopt(2) (https://rubygems.org/gems/json-1.8.3.gem) An error occurred while installing json (1.8.3), and Bundler cannot continue. Make sure that `gem install json -v '1.8.3'` succeeds before bundling. run bundle exec spring binstub --all bundler: command not found: spring Install missing gem executables with `bundle install`
換上淘寶源仍是不能解決,只好按照提示手動安裝缺失的gem包。json
這是由於rails建立的Gemfile裏指定被牆了的Rubygems做爲源。ruby
解決方法: 首先,用rails new APP --skip-bundle
建立項目,這樣建立完成後就不會自動運行bundle install
了。 而後,修改新項目的Gemfile,把code
source 'https://rubygems.org'
改爲ip
source 'https://ruby.taobao.org'
最後,手動運行一下bundle install
就能夠了。it