Why is Bundler version lookup selecting pre-release version here? - ruby-on-rails

We have a gem which as development dependencies relies on sass-rails (specifically in version 5.0.4) which in turn depends on railties >4.0.0 and <5.0.
Now we don't check our Gemfile.lock into the repo to keep it as flexible as possible (it's our 'universal' gem after all), and during the travis build, installing sass-rails resolves its dependency railties to version 5.0.0.beta1, which I'd say intuitively isn't <5.0 and now causes problems when running the tests on ruby < 2.2.2 (due to rack).
Now, am I misunderstanding something or is this a bug, that bundler installs 5.0.0.beta1 for <5.0?

This is not a bug but expected behaviour. Prerelease versions are expected to be released before the actual release, hence they are considered smaller.
See http://ruby-doc.org/stdlib-2.0.0/libdoc/rubygems/rdoc/Gem/Version.html for more detail.
You can add a runtime dependency to railties '~> 4.0' to your gemspec to solve this problem.

Related

Why does Bundler refuse to accept a gem with no version specified?

The command:
bundle update
The error:
Bundler could not find compatible versions for gem "fog-core":
In Gemfile:
fog was resolved to 2.0.0, which depends on
fog-google (<= 0.1.0) was resolved to 0.1.0, which depends on
fog-core
fog was resolved to 2.0.0, which depends on
fog-internet-archive was resolved to 0.0.1, which depends on
fog-core (~> 1.45)
Bundler keeps finding that fog-core with no version specified is incompatible with fog-core (~> 1.45). I would think that no version in the .gemspec file means that any version is acceptable, but that doesn't seem to be the case.
This is happening with Bundler version 1.16.1 on a very large project, after attempting to upgrade the version of fog-aws.
My solution so far has been to fork every dependency, making the following change:
--- a/foo.gemspec
+++ b/foo.gemspec
- spec.add_dependency "fog-core"
+ spec.add_dependency "fog-core", "~> 1.45"
...but that's a stupid thing to have to do. There's got to be a better way.
After a day and a half of single-stepping through Bundler, I have arrived at an answer:
If both of the following things happen:
Bundler looks at a conflicting version of a package (such as librato-metrics) before finding the right version.
Another error of any kind happens, either before or after #1.
...Bundler will show the resolved conflict error along with all the other errors, even though the conflict was actually resolved and doesn't need to be addressed.

How to fix 'could not find compatible version for gem "rails"'?

Im literaly bumping my head into a wall and I can not find a solution by myself about this problem.
I'm starting a project with Solidus , a Spree commerce fork. I played around with the gem for a litle while and now that I am ready to get serious and start to develop , I create a new project ad I'm bumping into this nasty error :
Bundler could not find compatible versions for gem "rails":
In snapshot (Gemfile.lock):
rails (= 5.1.2)
In Gemfile:
rails (~> 5.1.2)
solidus was resolved to 1.0.0, which depends on
solidus_core (= 1.0.0) was resolved to 1.0.0, which depends on
rails (~> 4.2.0)
Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
and bundle update is not solving my problem... I am running out of solution and will appreciate some hands in help in how to fix this problem.
Thanks
Bundler is doing you a favor here by showing you that you have incompatible version requirements for the rails gem.
You have rails (~> 5.1.2) listed in your gemfile and the solidus gem has a dependency on rails (~> 4.2.0), so there is a conflict about which version of rails your app should use.
Is there a reason you are using solidus version 1.0.0? It looks like the latest version of solidus is 2.0.2 at present. Later versions of solidus will have a more recent dependency listed for rails, which will allow your application to use rails 5+.
Update the version of solidus in your gemfile to something more recent and see if that allows bundler to install successfully.

How to override gem dependency?

I have 2 gems that depend on conflicting versions of hashie (one requires ~> 1.2.0 and the other requires 3.3.1):
Bundler could not find compatible versions for gem "hashie":
In Gemfile:
restforce (>= 0) ruby depends on
hashie (~> 1.2.0) ruby
omniauth (>= 0) ruby depends on
hashie (3.3.1)
I'd like to keep both gems and use the higher version of hashie. Is there a way for me override one of the gem dependencies?
The standard advise is to use the higher version compatible.
I do this way, but I think bundler has a defined command for it.
First remove the line of gem 'omniauth' at your Gemfile. Run bundle install, then you must add again the line with gem 'omniauth' to your Gemfile, run bundle install again.
If you look at Gemfile.lock, this install hashie 2.0.5, the higher compatible.
Edit: why does this work?
First I check omniauth dependencies with hashie: hashie < 4, >= 1.2, then the same with restforce: hashie < 2.1, >= 1.2.0. At this point, I know that any version of hashie between 1.2 and 2.0.x must work. Then we must to remove the constraint at Gemfile.lock of continue using hassie 3.3.1, removing 'omniauth' from Gemfile it's done. After that, when install restforce, the bundler find the new version compatible with restforce '2.0.5'. And when you add again omniauth bundler don't update dependencies that are accomplished.
I think bundle update is actually what you were after. That sorts out dependencies and installs different versions of gems if required, giving you the most up-to-date gems possible.
Be careful however, as updating gems can introduce compatibility issues.

Error on Updating RefineryCMS

I am trying to update from refinery 1.0.9 to 2.0.9 on ruby 1.9.3. I am getting this error:
Bundler could not find compatible versions for gem "refinerycms-core":
In Gemfile:
refinerycms-news (~> 1.2) ruby depends on
refinerycms-core (~> 1.0.0) ruby
refinerycms (~> 2.0.9) ruby depends on
refinerycms-core (2.0.9)
Can you help me understand the error and what to do about it?
Bundler attempts to make sure that all of the dependencies of all gems (other gems, that is) are installed and meet version requirements specified by the gem designers.
In your Gemfile, you can specify versions of Gems in several ways, the ~> method says the version can be greater than or equal to the number specified, but not so great that a major release can get installed without you knowing.
So it looks like you'll need to relax the restriction on version on the refinery-news gem which likely has a later version available than the 1.2 currently allowed (That version depends on refinerycms-core 1.0.0, but refinerycms needs a later version of the same gem).

Omnisocial depends on gem bcrypt-ruby 2.1, but Rails 3.1 depends on bcrypt 3.0.0 - what do I do?

Trying to test out this awesome looking gem - http://icelab.com.au/articles/welcome-to-the-omnisocial/ - that promises easy integration of Twitter & FB login to my app.
But, when I run bundle install I see this:
Bundler could not find compatible versions for gem "bcrypt-ruby":
In Gemfile:
omnisocial depends on
bcrypt-ruby (~> 2.1)
bcrypt-ruby (3.0.0)
When I specify that I want Bundler to use version 2.1, I get this:
Bundler could not find compatible versions for gem "bcrypt-ruby":
In Gemfile:
bcrypt-ruby (~> 2.1)
rails (= 3.1.0) depends on
bcrypt-ruby (3.0.0)
So now I have to choose between either Omnisocial or Rails 3.1. Seems like such a crappy choice.
What do I do to get it to work?
I've pushed released a new version of the gem (which I've had to rename to omnipopulus for legal reasons). This new release doesn't depend on any particular version of the bcrypt-ruby gem, so you should be fine to run it with Rails 3.1.
Add this to your Gemfile to get going:
gem 'omnipopulus'
Then run bundle and follow the instructions in the README at https://github.com/icelab/omnipopulus
Make sure that you've removed any references to omnisocial in your app.
The current github version of omnisocial requires no particular version of bcrypt. See here.
But they added a dependency to a RC version of Rails...
What I often do in these cases:
clone the github repository
change what I need
run the gem's test suite
if ok, add my own version to the Rails app
if a new version of the gem is released an fit my needs, I use the official version again

Resources