ruby - 捆绑安装/更新太慢

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15343771/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 21:37:03  来源:igfitidea点击:

ruby - bundle install/update too slow

ruby-on-railsrubyrubygemsbundler

提问by Robin Wieruch

I just installed RVM, Ruby, Rails etc. on my virtual ubuntu 12.04 32bit running in a virtualbox. Now I encounter the problem that for my first rails project bundle installor bundle updatetakes very long time. Even when I create a new project with rails (which includes bundle install).

我刚刚在我在 virtualbox 中运行的虚拟 ubuntu 12.04 32bit 上安装了 RVM、Ruby、Rails 等。现在我遇到了我的第一个 rails 项目bundle installbundle update需要很长时间的问题。即使我使用 rails 创建一个新项目(包括bundle install)。

I use only the standard gems:

我只使用标准宝石:

source 'https://rubygems.org'

gem 'rails', '3.2.12'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

group :development do
  gem 'sqlite3', '1.3.5'
end


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '3.2.5'
  gem 'coffee-rails', '3.2.2'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

 gem 'uglifier', '1.2.3'
end

gem 'jquery-rails', '2.0.2'

I tried bundle install without any gems but gem 'rails', '3.2.12'. After that I typed again bundle installwith all gems in my gemfile. It took me 10 minutes to check for dependencies. The output of --verbose is a mix of HTTP successand HTTP redirection.

我尝试在没有任何 gem 的情况下进行捆绑安装,但是gem 'rails', '3.2.12'. 之后,我再次输入了bundle install我的 gemfile 中的所有 gem。我花了 10 分钟来检查依赖项。--verbose的输出的混合HTTP successHTTP redirection

Rails version: Rails 3.2.12

Rails 版本:Rails 3.2.12

Ruby version: ruby 1.9.3p392 (2013-02-22 revision 39386)

Ruby 版本:ruby 1.9.3p392(2013-02-22 修订版 39386)

Rvm: rvm 1.18.18

房车:房车 1.18.18

bundle version: Bundler version 1.3.2

捆绑版本:捆绑程序版本 1.3.2

I already searched fot a solution, but nothing helped.

我已经搜索了解决方案,但没有任何帮助。

回答by Robin Wieruch

I want to warn: There is a security purpose for using https over http. Try at first the other answers mentioned in this thread.

我想警告:通过 http 使用 https 有一个安全目的。首先尝试此线程中提到的其他答案。

Changing httpsto httpin my Gemfiledid the magic. Before I have to create the project with rails new APP --skip-bundle

在我的Gemfile 中更改https为神奇。在我必须创建项目之前httprails new APP --skip-bundle

回答by Mohit Jain

Bundler just got an updateof parallel processing of gems.

Bundler 刚刚更新了 gem 的并行处理。

gem install bundler --pre 

will solve the problem in the best possible way for now.

将暂时以最好的方式解决问题。

Source

来源

回答by Red

Bundler v1.12.x was released in 2016 and caused some users to experience slow bundle install issues.

Bundler v1.12.x 于 2016 年发布,导致一些用户遇到包安装缓慢的问题

In this instance staying with v1.11.2 is the best option (it's fast) until a fix is released.

在这种情况下,使用 v1.11.2 是最好的选择(速度很快),直到发布修复程序。

It's worth heading over to Rubygems.orgto try different versions of the bundler gem.

值得前往Rubygems.org尝试不同版本的 bundler gem。

Check existing bundler versions, uninstall existing version, install version 1.11.2 example:

检查现有 bundler 版本,卸载现有版本,安装 1.11.2 版本示例:

gem list | grep bundler

gem uninstall bundler -v existing-version-number

gem install bundler -v 1.11.2

回答by duykhoa

You can also use multiple jobs, it may improve a little bit

您也可以使用多个作业,它可能会有所改善

  bundle install --jobs 8

Here is a tutorialabout it

这是一个关于它的教程

回答by Reza Hashemi

A developer friendly method is to override the gem server with a faster alternative.

开发人员友好的方法是使用更快的替代方案覆盖 gem 服务器。

In our case, we can configure httpas a mirror to address slow httpsconnections:

在我们的例子中,我们可以配置http为镜像来解决慢速https连接:

bundle config mirror.https://rubygems.org http://rubygems.org

This allows you to keep original Gemfileconfiguration while still using faster httpconnections to fetch gems.

这允许您保留原始Gemfile配置,同时仍然使用更快的http连接来获取 gem。

If you wanted to switch back to https:

如果您想切换回https

bundle config --delete mirror.https://rubygems.org

bundle confighas a default --globaloption. You can specify --localto limit configurations to local application folder.

bundle config有一个默认--global选项。您可以指定--local将配置限制为本地应用程序文件夹。

Configuration is saved into global ~/.bundle/configand local .bundle/config.

配置保存到 global~/.bundle/config和 local .bundle/config

回答by pjmorse

If you're still seeing this issue with Bundler 1.12.5, you may want to try updating the OpenSSL used by your Ruby.

如果您在 Bundler 1.12.5 中仍然看到此问题,您可能需要尝试更新 Ruby 使用的 OpenSSL

For me this went like so:

对我来说,事情是这样的:

pmorse$ bundle --version
Bundler version 1.12.5
pmorse$ ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
OpenSSL 1.0.1j 15 Oct 2014
pmorse$ openssl version
OpenSSL 0.9.8zg 14 July 2015
pmorse$ brew info openssl
openssl: stable 1.0.2h (bottled) [keg-only]

[... more brewoutput ...]

[...更多brew输出...]

pmorse$ rvm reinstall ruby-2.2.2 --with-openssl-dir=`brew --prefix openssl`

[... lots of rvmoutput ...]

[...大量rvm输出...]

pmorse$ ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
OpenSSL 1.0.2h  3 May 2016

This should make bundlequicker again without requiring you to go from httpsto http.

这应该会bundle再次变得更快,而无需您从httpshttp

回答by Adamosch

I know this may be basic answer but try to install developer tools from the main Ruby site. I have had a similar problem and it did work. Sometimes simple solutions are the best!

我知道这可能是基本答案,但请尝试从主要 Ruby 站点安装开发人员工具。我有一个类似的问题,它确实有效。有时简单的解决方案是最好的!

Good luck!

祝你好运!