I have installed two versions of devise gem on my local machine namely devise(3.5.1) and devise(3.5.2).
In my gemfile i have included devise gem with pessimistic version constraint as shown below.
gem 'devise' , '~> 3.4'
dependencies for devise gem:
devise-encryptable-0.2.0 (devise (>= 2.1.0))
devise_invitable-1.4.0 (devise (>= 3.2.0))
devise_invitable-1.3.6 (devise (>= 3.2.0))
devise_security_extension-0.8.4 (devise (>= 2.0.0))
devise_security_extension-0.8.3 (devise (>= 2.0.0))
devise_security_extension-0.8.1 (devise (>= 2.0.0))
devise_security_extension-0.8.0 (devise (>= 2.0.0))
As per my research the meaning of this operator(~>) is that it will look for devise version >= 3.4 but <4.0 . But whenever i do bundle show in my project home directory it gives me error as "Could not find devise-3.4.1 in any of the sources".
My question is why bundle show command is giving an error if there is devise gem version >= 3.4 is available and installed on my machine(in my case devise version 3.5.2).
Your Gemfile is locked on this version thats why your bundle install command will not look for a different version try run bundle update devise then Rails will try to look for a newer version of devise gem and update your dependency.
understand the operator ~>:
when you add new gem into your Gemfile bundler have to take in account that you have dependency then the operator ~> come into action it will try to find the completable version for all the gems listed in your Gemfile and will not be locked to specific version it will be locked to a range of version lower then the first digit.
understand bundle install:
bundle install command look for gems listed in Gemfile.lock and will not update OR change any gem version no matter which operator is in your Gemfile.
Related
I'm attempting to install devise_token_auth. The instructions say to add gem 'devise_token_auth'
to my Gemfile, then run bundle install. I created a brand new API only Rails app, follow the instructions, and get the following:
Bundler could not find compatible versions for gem "rails":
In Gemfile:
rails (~> 6.1.1) x86_64-darwin-20
devise_token_auth x86_64-darwin-20 was resolved to 0.1.21.alpha2, which depends on
rails (~> 4.1.4)
What is x86_64-darwin-20? That's not in the Gemfile, but I'm working on MacOS. What's going on?
Credit to Rockwell Rice:
https://rubygems.org/gems/devise_token_auth/versions/1.1.4 shows you the dependencies.
devise_token_auth depends on rails >= 4.2.0, < 6.1. So I just recreated a new rails app with version 6.0.
I am new to rails and building my first web application using version 4.2.4.
I am trying to install the activeadmin gem using
gem 'activeadmin', '~> 0.6.6'
However, when I run bundle install I get an error which says:
Bundler could not find compatible versions for gem "rails":
In snapshot (Gemfile.lock):
rails (= 4.2.4)
In Gemfile:
activeadmin (~> 0.6.6) ruby depends on
rails (< 4, >= 3.0.0) ruby
rails (= 4.2.4) ruby
Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
Is this suggesting that I need to go down a version of rails in order to make this gem work or can I keep 4.2.4 and use the suggested bundle update method without causing any issues with my app and other gems?
The version of activeadmin that your Gemfile specifies does not support Rails 4. From the readme:
We're currently working on 1.0.0, which as far as dependencies, moves
us from meta_search to Ransack and adds Rails 4 & 5 support.
You can get it by tracking master:
gem 'activeadmin', github: 'activeadmin'
Or you can using rubygems:
gem 'activeadmin', '~> 1.0.0.pre2'
Change your Gemfile as shown, and then run bundle install
When developing rails 4.1 engine module_infox, there include gem authentify which is developed in rails 3.2 in module_infox's gemfile:
gem 'authentify', :path => '../authentify'
Gem authentify sits locally and its gemfile.lock was deleted to remove the version lock.
When bundle install under module_infox, there is an error:
$ bundle install
Fetching gem metadata from http://rubygems.org/.........
Fetching gem metadata from http://rubygems.org/..
Resolving dependencies...
Bundler could not find compatible versions for gem "rails":
In Gemfile:
authentify (>= 0) x86-mingw32 depends on
rails (= 3.2.12) x86-mingw32
module_infox (>= 0) x86-mingw32 depends on
rails (4.1.0.beta1)
Based on our reading, old version gem can be used in newer version gem. Both gemfile.lock in authentify and module_infox were deleted before bundle install. But there is the same error. What's right way to do so?
I think the specific dependency on Rails 3.2.12 on authentify gem is the reason of conflict.
Solution 1: Direct fix
The most intuitive solution would be changing this hard dependency. Say, revise the gemspec as rails, '> 3.2'.
However, your authentify gem itself may not be ready for Rails 4 yet. So using this would be a bit aggressive.
Solution 2: Use git brach
The better alternative is to add a branch in authentify gem say "rails-4", then change the gemspec as above.
Then you need to specify this git branch in Gemfile.
If you use Github to host this gem
gem 'authentify', git: 'git://github.com/username/authentify', branch: 'rails-4'
If you are not going to opensource this gem, you can still use local path. But you need to setup Bundle to recognize it.
$ bundle config local.authentify ~/Work/git/authentify
Then set it in Gemfile
# gem 'authentify', :github => 'authentify/authentify', :branch => 'master'
I commented out the last line of code because I just copied it from Bundle doc but not verified that before. You can check the doc and experiment by yourself. http://bundler.io/v1.2/git.html
I am currently running one of my Rails applications on version 3.1.3. My gemfile always listed:
gem 'rails', '3.1.3'
This worked just fine. In an effort to move to 3.1.10, I changed my Gemfile to the following:
gem 'rails', '~> 3.1.10'
Surprisingly, things break when I run bundle update rails after that change:
Bundler could not find compatible versions for gem "multi_json":
In Gemfile:
twitter (>= 0) ruby depends on
multi_json (~> 1.3) ruby
fnordmetric (>= 0) ruby depends on
multi_json (1.2.0)
Just as a test, I tried changing the gem version to '>= 3.1.0' and that installed without any quims, albeit it went to 3.2, which I'm not ready for just yet on this particular application.
Any suggestions for getting this thing running on 3.1.10 which was released today to address a security vulnerability?
Also an update:
I am having absolutely no trouble stashing Gemfile.lock away and starting from Rails 3.1.4. As soon as I try to go to 3.1.5+, this is where all the trouble begins.
Make the change in your Gemfile to
gem 'rails', '3.1.10'
Then try running
bundle update
instead of
bundle install
I can't see your Gemfile but this should will allow the bundler to try and find compatible Gem matches. If you have hard code a Gem revision you might have to relax it and repeat the update. Good luck!
Looking at the gems, it appears that oauth2 lists "multi_json ~> 1.0" and ActiveSupport 3.1.10 lists "multi_json < 1.3, >= 1.0" as the dependencies, so that should resolve. I've run into strangeness like this and fixed it by running
gem uninstall <relevant gems>
then running bundle install again. So maybe try
gem uninstall oauth2 multi_json activesupport
then bundle install
Edit
gem uninstall twitter multi_json fnordmetric
While trying to install Rails admin, I added it to my gem file as instructed. I deleted the gemfile.lock
Then I ran bundle install. I got this message:
Bundler could not find compatible versions for gem "rails":
In Gemfile:
rails_admin depends on
rails (~> 3.0.3)
rails (3.0.1)
I am using rails 3.0.1, not really sure I understand the issue? But its obviously stopping me from installing.
Also, if I put rails_admin in the gem file like so:
gem 'rails_admin'
instead of:
gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
that seems to install it a version 0.0.0 and then doesn't proceed to do anything (so clearly thats not right either).
Is there a version I can specify that might work?
Thanks!
The issue is that the gem now required rails 3.0.3 and you are using 3.0.1
~> means at least this tiny revision or greater.
E.G. ~> 3.0.3 means 3.0.x where x >= 3
As for what gem version will work on 3.0.1 I do not know.