2

I had an annoying bug in my app which caused static code to apear in my HTML. After a long time of bug hunting and trying things I finally found what caused the error.

The problem lies in the sprocket version. In my Gemfile.lock I have

sprockets 3.2.0)

and then my App works fine. But when I do bundle update the version changes to

sprockets (2.12.4)

and the bug appears. So now I have to manually change the sprocket version to 3.2.0 after I do bundle update.

So why does bundle update change my sprocket version to an older version? I am using the latest version of Bundler.

UPDATE.

I've just added the capistrano gem to my 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"

And tried to do bundle install but now I'm getting another error,

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.

I run bundle update and while the error is fixed the bug with the static HTML is back since bundler downgraded the gem back to sprockets (2.12.4).

Changing the sprocket back to 3.2.0 in the Gemfile.lock fixes the bug. But there has to be an explanation for this behaviour. Right?

Peter Boomsma
  • 8,851
  • 16
  • 93
  • 185
  • Just happened to my sprockets. "Upgraded from from 2.11.0 to 2.8.0. – Mark Bolusmjak Feb 29 '16 at 19:55
  • @z5h I'm not 100% sure but upgrading to sprockets 3.5 works. I've added this to my gemfile `gem 'sprockets', '~> 3.5', '>= 3.5.2'` You might get in trouble with the template if you use rails template, use this `gem 'angular-rails-templates', '>= 1.0.0.beta2'` – Peter Boomsma Mar 01 '16 at 20:34
  • thanks. I got rid of a few gems I no longer needed that were preventing an upgrade of sprockets and that fixed things. Still strange that a downgrade occurred. – Mark Bolusmjak Mar 01 '16 at 20:43

1 Answers1

0

Bundler looks for a version that has dependencies that can be satisfied.

Downgrading a gem might cause others to downgrade too, sure, but upgrading a gem, might also caused another gem to downgrade, if upgrading it is not possible.

If you upgrade Rails, is not uncommon to see gems being downloaded. The downgraded library version might have no dependency to the library that got upgraded (for example active-support, etc).

That's why typically the versions drop to something like 0.0.x.

estani
  • 24,254
  • 2
  • 93
  • 76