首页 文章

ruby - bundle install / update太慢了

提问于
浏览
34

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

我只使用标准宝石:

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'

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

Rails版本:Rails 3.2.12

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

Rvm:rvm 1.18.18

捆绑版本:Bundler版本1.3.2

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

7 回答

  • 39

    在我的 Gemfile 中将 https 更改为 http 实现了魔力 . 在我必须使用 rails new APP --skip-bundle 创建项目之前

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

  • 3

    Bundler只是got an update并行处理宝石 .

    gem install bundler --pre
    

    现在将以最好的方式解决问题 .

    Source

  • 13

    Bundler v1.12.x于2016年发布,导致一些用户体验slow bundle install issues .

    在这种情况下,保留v1.11.2是最好的选择(它很快),直到修复发布 .

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

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

    gem list | grep bundler
    
    gem uninstall bundler -v existing-version-number
    
    gem install bundler -v 1.11.2
    
  • 2

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

    bundle install --jobs 8
    

    关于它,这是tutorial

  • 4

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

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

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

    这允许您保持原始 Gemfile 配置,同时仍然使用更快的 http 连接来获取宝石 .

    如果您想切换回 https

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

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

    配置保存到全局 ~/.bundle/config 和本地 .bundle/config .

  • 2

    如果你仍然看到Bundler 1.12.5的这个问题,你可能想要try updating the OpenSSL used by your Ruby .

    对我来说,这是这样的:

    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]
    

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

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

    [...很多 rvm 输出...]

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

    这应该使 bundle 再次更快,而不要求你从 httpshttp .

  • 0

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

    祝好运!

相关问题