1

I have a Rails 4 application. Some time ago, after runing bundle install and bundle update I started to have problems with my application. I find out that the Faraday gem was causing some issues and, as some other gems are dependent on it, I can't uninstall it. Then I found my project backup that was from before I made the bundle install/bundle update commands. At that time my application worked great.

When comparing my old Gemfile.lock with the current one, I saw that some of the gems now have newer versions. I believe there is the cause of the application problems.

These are only the gems that are related in my current Gemfile.lock:

   oauth2 (1.3.1)
      faraday (>= 0.8, < 0.12)
      jwt (~> 1.0)
      multi_json (~> 1.3)
      multi_xml (~> 0.5)
      rack (>= 1.2, < 3)
    omniauth (1.4.2)
      hashie (>= 1.2, < 4)
      rack (>= 1.0, < 3)
    omniauth-oauth2 (1.4.0)
      oauth2 (~> 1.0)
      omniauth (~> 1.2)
    omniauth-yandex (0.0.2)
      omniauth (~> 1.0)
      omniauth-oauth2 (~> 1.0)

My old Gemfile.lock from when the application worked great:

oauth2 (1.3.0)
  faraday (>= 0.8, < 0.11)
  jwt (~> 1.0)
  multi_json (~> 1.3)
  multi_xml (~> 0.5)
  rack (>= 1.2, < 3)
omniauth (1.3.2)
  hashie (>= 1.2, < 4)
  rack (>= 1.0, < 3)
omniauth-oauth2 (1.4.0)
  oauth2 (~> 1.0)
  omniauth (~> 1.2)
omniauth-yandex (0.0.2)
  omniauth (~> 1.0)
  omniauth-oauth2 (~> 1.0

My current and previous Gemfile is the same:

gem 'tinymce-rails'
gem 'mysql2', '~> 0.3.18'
gem 'humanizer'
gem 'globalize', '~> 4.0.3'
gem "paperclip", "~> 4.2"
gem 'remotipart', '~> 1.2'
gem 'mailcatcher', '~> 0.6.1' ,        group: :development
gem 'rufus-scheduler', '~> 3.1.2'
gem "omniauth-yandex"
gem 'friendly_id', '~> 5.1.0'
gem 'devise'
gem 'rest-client', '~> 1.8'
gem "cocoon"

Is it possible to somehow downgrade some of the gems and their dependecies to versions in the old Gemfile.lock?

My app is required to have only omniauth-yandex gem.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Edgars
  • 913
  • 1
  • 19
  • 53
  • 1
    Just change the version specifications in the Gemfile to the required versions for your application, and run `bundle install` again. Bundler will reload the required versions and adjust the Gemfile.lock file. This is in the Bundler documentation. – the Tin Man Apr 17 '17 at 19:09
  • @theTinMan Thanks for help. I added all gems with specified versions and then I run bundle update/install successfully. But the versions still were the same without any change. Why is that? – Edgars Apr 17 '17 at 20:20

4 Answers4

2

You should try adding the specific version for the gems in your file. That way you will have the required dependent versions for a specific gem.

Vineeth
  • 173
  • 11
  • Thanks for help. I added all gems with specified versions and then I run bundle update/install successfully. But the versions still were the same without any change. Why is that? – Edgars Apr 17 '17 at 20:20
  • Try this: After you change the versions in Gemfile, delete your Gemfile.lock. And then run "bundle install" command. – Vineeth Apr 17 '17 at 20:30
1

I've faced this a few times with my Rails apps. Since this is something that you may face often, I'd recommend making sure that your using some sort of version control system like Git. Make sure that before you install gems or update your Gemfile.lock (i.e. Running bundle install or bundle update), you commit your previous changes. That way, if you ever need to revert your project's Gemfile.lock file to a previous state, it's much easier to do. There's another StackOver thread on reverting your commits at How to undo last commit(s) in Git?

If you're not familiar with Git, there's a great free online book at https://git-scm.com/book/en/v2

If you haven't had the chance to commit your changes so that you can go back to the Gemfile and Gemfile.lock you previously had, your best bet is to specify the gem versions you need just like Vineeth mentioned. The Bundler docs go over how to do this if you need a reference http://bundler.io/v1.5/gemfile.html#gemfiles

Be sure that after you specify the versions in your Gemfile, you run:

bundle update

That will update your Gemfile.lock file with the specific versions you need.

Hope that helps! :)

Community
  • 1
  • 1
John
  • 374
  • 2
  • 6
1

You can add a specific version of that gem in gemfile and do bundle install and it should update all the required dependencies.

0

If you're using Github, there is the possibility to run git revert?

This would revert back to an older commit (you choose which commit to revert back to) therefore removing changes made after a commit.

NJBow
  • 1
  • 2