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

时间:2021-07-28 00:22:25

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”创建一个新项目时,它会出现以下错误(之前我使用相同的命令成功创建了许多项目): -

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

and the following error occurs when my pc is connected to the internet :-

当我的电脑连接到互联网时出现以下错误: -

run bundle install Fetching source index from https://rubygems.org/

运行bundle install从https://rubygems.org/获取源索引

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 / rake:插入弹簧

  • bin/rails: spring inserted

    bin / rails:插入弹簧

please suggest a solution

请提出解决方案

1 个解决方案

#1


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,并进行捆绑安装以安装您刚刚创建的基本应用程序所需的gem。

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).

你的错误是因为当它试图进行捆绑安装时,它无法到达rubygems下载它想要的宝石(在你的第一个例子中因为你没有连接到互联网而在第二个例子中因为某些原因你的计算机无法连接到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. Adding --verbose should generate some extra logging information which may help to diagnose the problem.

您可以尝试自己调用bundle install,而不是作为rails进程的一部分。添加--verbose应该生成一些额外的日志记录信息,这可能有助于诊断问题。

You can also try install gems manually to see if that works okay. You must have done this yourself at some point to get the rails gem installed.

您也可以尝试手动安装gems以查看是否可行。您必须在某个时候自己完成这项操作才能安装rails gem。

#1


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,并进行捆绑安装以安装您刚刚创建的基本应用程序所需的gem。

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).

你的错误是因为当它试图进行捆绑安装时,它无法到达rubygems下载它想要的宝石(在你的第一个例子中因为你没有连接到互联网而在第二个例子中因为某些原因你的计算机无法连接到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. Adding --verbose should generate some extra logging information which may help to diagnose the problem.

您可以尝试自己调用bundle install,而不是作为rails进程的一部分。添加--verbose应该生成一些额外的日志记录信息,这可能有助于诊断问题。

You can also try install gems manually to see if that works okay. You must have done this yourself at some point to get the rails gem installed.

您也可以尝试手动安装gems以查看是否可行。您必须在某个时候自己完成这项操作才能安装rails gem。