如何从Gemfile.lock文件安装gems? [英] How do you install gems from Gemfile.lock file?

查看:50
本文介绍了如何从Gemfile.lock文件安装gems?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行一个从Github移除的应用程序.

I am trying to run an app taken off Github.

我已经运行bundle installGemfile安装所需的gem.但是,在运行该应用程序时,错误消息告诉我所安装的gems版本错误.

I have run bundle install to install required gems from the Gemfile. However when running the app, an error message tells me the gems installed are the wrong version.

在检查Gemfile.lock时,我注意到版本比所安装的gems旧. (即,我安装了较新版本的gem,并且该应用程序需要较旧的gem.)

On inspecting the Gemfile.lock I note that the versions are older than the gems installed. (i.e. I have newer versions of gems installed and the application requires older gems.)

是否可以按照Gemfile.lock文件中描述的版本快速安装所有gems?或者,有一种方法可以忽略该文件?

宝石文件:

   source 'http://rubygems.org'
   gem 'rails', "3.0.9"
   gem "sass"
   ..

Gemfile.lock:

Gemfile.lock:

 sass (3.1.1)
 ..

在上面的示例中,即使安装了sass,该应用程序也特别需要版本3.1.1.

In the above example, even though sass is installed the app specially requires version 3.1.1.

推荐答案

对于有效的Gemfile.lock文件,仅bundle install就足够了,除非已取消某些特定的gem版本.在这种情况下,您需要寻找一个仍然可用的替代gem版本(通常bundle update name_of_yanked_gem就足够了).

With a valid Gemfile.lock file, bundle install alone should be sufficient, unless some particular gem version has been yanked. In that case you would need to look for an alternative gem version that is still currently available (usually bundle update name_of_yanked_gem would suffice).

关于sass 3.1.1,并不是说应用程序需要特定版本,而是在给定整体版本约束的情况下,上一次生成/更新Gemfile.lock时,这可能是最新的可用版本. Gemfile.如您所列出的,没有为sass本身指定版本范围,但是如果其他gem具有sass作为依赖项,则它们可能会施加进一步的约束.

About the sass 3.1.1, it is not so much that the application requires that particular version, but rather, that was likely the newest version available when the Gemfile.lock was last generated/updated given the overall version constraints as specified in Gemfile. As you have listed, there is no version range specified for sass itself, but other gems may impose further constraints if they have sass as a dependency.

完全忽略Gemfile.lock并不是一个好主意,因为在通常情况下,它将指定最后一个已知仍可用于该应用程序的gem版本.

Outright ignoring Gemfile.lock is not a good idea as under normal circumstances it will be specifying the gem versions that were last known to be still usable with the application.

这篇关于如何从Gemfile.lock文件安装gems?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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