简体   繁体   English

使用命令rails new myapp在rails项目上创建新的ruby时出错

[英]error while creating a new ruby on rails project using command rails new myapp

When i try to create a new project using command "rails new myapp" it gives the following error (earlier i successfully created many projects using same command):- 当我尝试使用命令“ rails new myapp”创建新项目时,出现以下错误(之前我使用同一命令成功创建了许多项目):

在此处输入图片说明在此处输入图片说明

and the following error occurs when my pc is connected to the internet :- 当我的电脑连接到互联网时,发生以下错误:-

run bundle install Fetching source index from https://rubygems.org/ https://rubygems.org/运行bundle install获取源索引

Retrying source fetch due to error (2/3): Bundler::HTTPError Could not fetch specs from https://rubygems.org/ 由于错误(2/3),重试源获取:Bundler :: HTTPError无法从https://rubygems.org/获取规范

Retrying source fetch due to error (3/3): Bundler::HTTPError Could not fetch specs from https://rubygems.org/ 由于错误(3/3),重试源获取:Bundler :: HTTPError无法从https://rubygems.org/获取规范

Could not fetch specs from https://rubygems.org/ 无法从https://rubygems.org/获取规范

     run  bundle exec spring binstub --all 
  • bin/rake: spring inserted 仓/耙:弹簧插入

  • bin/rails: spring inserted 垃圾桶/导轨:弹簧插入

please suggest a solution 请提出解决方案

As part of creating a new rails application rails sets up a Gemfile for you and does bundle install to install the gems required for the basic application you have just created. 作为创建新的Rails应用程序的一部分,rails为您设置了一个Gemfile并进行bundle install以安装刚创建的基本应用程序所需的gems。

Your errors are because when it tries to do bundle install it cannot reach the rubygems to download the gems it wants to (in your first example because you are not connected to the internet and in the second because for some reason your computer cannot connect to rubygems.org). 您的错误是因为当它尝试进行bundle install它无法到达rubygems来下载所需的宝石(在您的第一个示例中,因为您没有连接到Internet,而在第二个示例中,由于某种原因,您的计算机无法连接到rubygems .ORG)。

As for the specific reason why you can't connect that could be for many reasons. 至于导致无法连接的特定原因,可能有多种原因。 Are you behind a firewall? 您在防火墙后面吗? Is https available? https可用吗?

You can try calling bundle install yourself rather than as part of the rails process. 您可以尝试自己调用bundle install而不是在rails过程中进行。 Adding --verbose should generate some extra logging information which may help to diagnose the problem. 添加--verbose应该会生成一些额外的日志记录信息,这可能有助于诊断问题。

You can also try install gems manually to see if that works okay. 您也可以尝试手动安装gems,以查看是否可以正常运行。 You must have done this yourself at some point to get the rails gem installed. 您必须在某个时候完成此操作才能安装rails gem。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM