Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RAILS 5: Bundler could not find compatible versions for gem “actionpack”:

Could anyone please help me for upgrading the rails 4.2 to rails 5.1.4 after run the bundle update got the compatible versions error

Bundler could not find compatible versions for gem "actionpack": In Gemfile: active_link_to (~> 1.0.0) was resolved to 1.0.5, which depends on actionpack

active_model_serializers (~> 0.10.6) was resolved to 0.10.7, which depends on
  actionpack (< 6, >= 4.1)

hamlit-rails (~> 0.2.0) was resolved to 0.2.0, which depends on
  actionpack (>= 4.0.1)

meta-tags (~> 2.4.1) was resolved to 2.4.1, which depends on
  actionpack (< 5.2, >= 3.2.0)

rails (~> 5.1.4) was resolved to 5.1.4, which depends on
  actionpack (= 5.1.4)

ransack (~> 1.6.6) was resolved to 1.6.6, which depends on
  actionpack (>= 3.0)

rspec-rails (~> 3.4.2) was resolved to 3.4.2, which depends on
  actionpack (< 4.3, >= 3.0)

simple_form (~> 3.5.1) was resolved to 3.5.1, which depends on
  actionpack (< 5.2, > 4)

stream_rails (>= 2.5.2, ~> 2.5) was resolved to 2.6.1, which depends on
  actionpack (>= 3.0.0)

twitter-typeahead-rails (~> 0.10.5) was resolved to 0.10.5, which depends on
  actionpack (>= 3.1)
like image 341
djadam Avatar asked Apr 30 '18 10:04

djadam


4 Answers

your rspec-rails blocks the upgrade. That bundler output shows this part:

actionpack (< 4.3, >= 3.0)

So rspec-rails blocks anything bigger that 4.2.

Release the rspec-rails contraint ~> 3.4.2 to something more relaxed like ~> 3.5 and try again

bundle update rails rspec-rails

In general, when upgrading Rails, try bundle update rails together with all the Gems that have specific version requirements for Rails or that are mentioned from bundler.

like image 156
stwienert Avatar answered Nov 09 '22 09:11

stwienert


That happened to me when I was trying to update to rails 6. here is my workaround.

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.6.3'


gem 'rails', '6.0.0.rc1'
gem 'sqlite3'
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
gem 'activerecord-import'
gem 'bootsnap'
gem "rspec"


group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

platforms :rbx do
  gem 'rubysl', '~> 2.0'
  gem 'rubinius-developer_tools'
end
like image 1
SotoArmando Avatar answered Nov 09 '22 07:11

SotoArmando


Remove your Gemfile.lock and add this to your Gemfile:

source 'https://rubygems.org'

and don't forget to update your other gems.

like image 1
wehdi Avatar answered Nov 09 '22 07:11

wehdi


I have faced this issue when I used these gems with versions:

  • gem 'rspec-rails', '~> 3.4.2'
  • gem 'factory_girl_rails', '~> 4.7.0'

It worked for me after removing gem version from specified gem.

  • gem 'rspec-rails'
  • gem 'factory_girl_rails'
like image 1
L Makwana Avatar answered Nov 09 '22 09:11

L Makwana