rails new APP出错的解决方法

江枫思渺然 提交于 2019-12-06 16:58:47

运行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就可以了。

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!