【发布时间】:2015-09-03 20:55:13
【问题描述】:
我的应用程序中有一个烦人的错误,导致静态代码出现在我的 HTML 中。经过长时间的错误搜寻和尝试,我终于找到了导致错误的原因。
问题出在链轮版本上。在我的 Gemfile.lock 我有
sprockets 3.2.0)
然后我的应用程序工作正常。但是当我做bundle update 时,版本更改为
sprockets (2.12.4)
然后出现错误。所以现在我必须在进行捆绑更新后手动将 sprocket 版本更改为 3.2.0。
那么为什么捆绑更新会将我的 sprocket 版本更改为旧版本?我正在使用最新版本的 Bundler。
更新。
我刚刚将 capistrano gem 添加到我的 gemfile 中
gem 'capistrano', '~> 3.1.0'
gem 'capistrano-bundler', '~> 1.1.2'
gem 'capistrano-rails', '~> 1.1.1'
# Add this if you're using rbenv
gem 'capistrano-rbenv', github: "capistrano/rbenv"
并尝试进行捆绑安装,但现在我遇到另一个错误,
Bundler could not find compatible versions for gem "sprockets":
In snapshot (Gemfile.lock):
sprockets (= 3.2.0)
In Gemfile:
sprockets (< 4.0, >= 2.8) ruby
angular-rails-templates (>= 0) ruby depends on
sprockets (~> 2) ruby
Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
我运行bundle update,虽然错误得到修复,但由于捆绑程序将 gem 降级为 sprockets (2.12.4),静态 HTML 的错误又回来了。
在 Gemfile.lock 中将 sprocket 改回 3.2.0 修复了该错误。但必须对这种行为做出解释。对吧?
【问题讨论】:
-
刚刚发生在我的链轮上。 "从 2.11.0 升级到 2.8.0。
-
@z5h 我不是 100% 确定,但升级到 sprockets 3.5 可以。我已将此添加到我的 gemfile
gem 'sprockets', '~> 3.5', '>= 3.5.2'如果您使用 rails 模板,您可能会遇到模板问题,请使用此gem 'angular-rails-templates', '>= 1.0.0.beta2' -
谢谢。我摆脱了一些我不再需要的宝石,这些宝石阻止了链轮升级并修复了一些问题。降级还是很奇怪。