运行rails new APP
的时候,经常会卡住,或者出现类似以下的提示
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包。
这是因为rails创建的Gemfile里指定被墙了的Rubygems作为源。
解决方法:
首先,用rails new APP --skip-bundle
创建项目,这样创建完成后就不会自动运行bundle install
了。
然后,修改新项目的Gemfile,把
source 'https://rubygems.org'
改成
source 'https://ruby.taobao.org'
最后,手动运行一下bundle install
就可以了。
来源:oschina
链接:https://my.oschina.net/u/1244649/blog/506279