当您的Gemfile需要较旧版本的捆绑程序时,如何“捆绑安装”? [英] How to `bundle install` when your Gemfile requires an older version of bundler?

查看:96
本文介绍了当您的Gemfile需要较旧版本的捆绑程序时,如何“捆绑安装”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个具有Gemfile的较旧的Rails项目中。我尝试将宝石添加到Gemfile并<捆绑安装 ,但出现错误:

I am in an older Rails project that has a Gemfile. I tried to add a gem to the Gemfile and bundle install but got an error:

Bundler could not find compatible versions for gem "bundler":
  In Gemfile:
    rails (= 3.0.0) ruby depends on
      bundler (~> 1.0.0) ruby

  Current Bundler version:
    bundler (1.1.5)

This Gemfile requires a different version of Bundler.

使用的Rails版本需要捆绑器〜> 1.0.0,但我安装了1.1.5,正在将其用于其他项目。通常,我会使用 bundle exec ... ,但是由于我们正在谈论的是捆绑器,因此它要复杂得多。如何在使用Gemfile所需的捆绑程序版本的同时,将Gem文件添加到我的Gemfile中并运行 bundle install

The version of Rails it's using requires bundler ~>1.0.0 but I have 1.1.5 installed and am using it for my other projects. Usually I would use bundle exec ... but since this is bundler we are talking about, it's a little more complicated than that. How can I add a gem to my Gemfile and run bundle install while using the version of bundler that it requires?

推荐答案

首先,您需要安装捆绑软件的适当版本:

First you need to install the appropriate version of bundler:

% gem install bundler -v '~> 1.0.0'
Successfully installed bundler-1.0.22

然后强制rubygems使用所需的版本(请参阅此帖子):

Then force rubygems to use the version you want (see this post):

% bundle _1.0.22_ install

这篇关于当您的Gemfile需要较旧版本的捆绑程序时,如何“捆绑安装”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆