angular-simple-format bower dependencies different from rails-assets dependencies - ruby-on-rails

In my Gemfile I'm using rails-assets to load angular and a number of other bower packages:
gem 'rails-assets-angular', '~> 1.3.5'
#... others
gem 'rails-assets-angular-simple-format', '~> 0.9.2'
angular-simple-format seems to be happy with any version of angular and any version of angular-sanitize:
"dependencies": {
"angular": "*",
"angular-sanitize": "*"
}
Why does bundle update --source rails-assets-angular-simple-format give me this error:
Bundler could not find compatible versions for gem "rails-assets-angular":
In Gemfile:
rails-assets-angular-simple-format (~> 0.9.2) ruby depends on
rails-assets-angular (= 1.2.21) ruby
rails-assets-angular (1.3.5)
Is there another layer of dependency management that rails-assets imposes between the bower package and bundler? How do I see what it is?

Although angular-simple-format accepts any version of angular or angular-sanitize, if you check the dependencies for angular-sanitize it requires angular 1.21 which is causing a conflict.
You would have to force rails-assets-angular to version 1.2.21 on the first line of your Gemfile.

It turns out that rails-assets does mess with dependencies. The rails-assets-angular-simple-format gem specifies the version of angularjs more strictly than the original bower project. From rails-assets-angular-simple-format.gemspec:
spec.add_dependency "rails-assets-angular", "1.2.21"
To solve I copied the original bower project into vendor/assets/javascripts and removed the rails-assets gem from the Gemfile.

Related

How does one upgrade a specific ruby gem to a specific (or the latest) version?

I am trying to upgrade a gem (hydra-derivatives) to version 3.3.2 to see if it solves a bug we are having.
hydra-derivatives is not a Gemfile gem; it's bundled as a dependency of another gem, called hydra-works.
What I've Tried
bundle update --conservative
hydra-derivatives but that only upgraded hydra-derivatives to
3.2.2 (& we want 3.3.2) and its dependency mini_magick from 4.5.1 to 4.8.0
adding gem 'hydra-derivatives', '~> 3.3.2' but that gave me:
You have requested:
hydra-derivatives ~> 3.3.2
The bundle currently has hydra-derivatives locked at 3.2.1.
Try running `bundle update hydra-derivatives`
If you are updating multiple gems in your Gemfile at once,
try passing them all to `bundle update`
I don't want to run bundle update hydra-derivatives because I don't want it to update a bunch of unnecessary gems and cause problems, hence why I read about --conservative
a. I ran this anyway to test it, and it upgraded target gem to only 3.2.2 and 15 gems in total!
hydra-derivatives is not a Gemfile gem; it's bundled as a dependency of another gem, called hydra-works.
You can still add this as an explicit dependency in your Gemfile:
# only restrict the version if you know of an incompatibility
gem 'hydra-derivatives' , '~> 3.3'
then run
bundle update hydra-derivatives --conservative
or
bundle update hydra-works --conservative
Remove the hydra-works gem from your Gemfile.
Either remove the gem and its dependencies by hand from the installed gem location or if you have the application in its own Ruby environment using rbenv or rvm run bundle clean --force.
Beware bundle clean --force will remove all of the gems in the Ruby version other than those specified in your Gemfile. If you have other applications that use the same version of Ruby you'll have to reinstall the gems for that application if they are different than what you are using in this application.
Add this to your Gemfile
gem 'hydra-derivatives', '~> 3.3.2'
gem 'hydra-works'
And run bundle install
You should see the correct dependency version now in your Gemfile.lock

Force Bundler to install gems supported by the local Ruby version

Is there a way of installing the latest supported version of a dependency without specifying it?
I'm having issues with the activesupport gem. The latest version (5.0.0.1) supports Ruby >= 2.2.2. If I'm specifying that I require the gem like this '~> 4.2' Bundler will try to install version 5 even if I'm on Ruby 2.0. Specifying the exact version 4.2.7.1 or setting a maximum '~> 4.2', '< 5' works, except when using the gem with Rails 5.
Is there a way to manage gem versions based on the current Ruby version?
Apparently the new version of Bundler will do this for you automatically.
I found this comment from André Arko that mentions this is already included in the latest RC version.
I specified Ruby '2.0' in my Gemfile, installed Bundler with gem install bundler --pre (it installed bundler-1.13.0.rc.2) and bundle install successfully installed activesupport 4.2.7.1.
With Bundler 1.12.5 I was getting the following error:
An error occurred while installing activesupport (5.0.0.1), and Bundler cannot continue.
Note that while a bit more manual, you can also include logic in your Gemfiles:
if RUBY_VERSION < "2.2.2"
gem "activesupport", "4.2.7.1"
else
gem "activesupport", "5.0.0.1"
end

sass-rails depends on sass v3.2, I need sass v3.4. What is sass-rails' "gemfiles" directory for, and will it help me use sass v3.4?

I have a project that requires sass v3.4, but sass-rails currently has this in its sass-rails.gemspec:
s.add_dependency 'sass', '~> 3.2.0'
The latest version (master branch) has gone backwards even more:
s.add_dependency 'sass', '~> 3.1'
From github, I can see that sass-rails works with sass v3.4 and has testing for it. It also has a curious "gemfiles" directory with a bunch of files like this Gemfile-sass-3-4:
source "https://rubygems.org"
# Specify your gem"s dependencies in sass-rails.gemspec
gemspec path: ".."
gem "rails"
gem "sass", "~> 3.4.0"
How to make use of this file? Or how do I make use of sass 3.4 without forking the sass-rails git repo and just changing it? Is this even possible?
The best I can find to do is put this in my Gemfile:
gem 'sass', '~> 3.4'
But bundle update gives me this error:
$ bundle update sass
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies.......
Bundler could not find compatible versions for gem "sass":
In Gemfile:
sass-rails (~> 4.0.3) ruby depends on
sass (~> 3.2.2) ruby
sass (~> 3.4) ruby
And a sort of side (related) question... Why is sass-rails using such an old version of sass?
The version specifier '~> 3.1' means the same as '>= 3.1' AND '< 4.0', so the latest version has gone forward not backward. Make sure you remove any version specifier from sass-rails in your Gemfile and then run:
bundle update sass-rails sass
If you don't have any other gems tied to older version of sass, it should upgrade it. If that does not do the trick, post the contents of your Gemfile.lock so we can see what other gems might be conflicting.
PS. The gemfiles directory in the sass-rails repository is there to support automated testing against multiple versions of sass on travis-ci.org.

Source does not contain any versions of 'rails-assets-lodash (~> 2.4)

I'm trying to help debug a project. I'm getting a really weird error when I try to run the server. I tried to google the gem but no luck. Anyone have any ideas? I tried bundle install and bundle update.
Here is the actual block of code I'm trying to run.
source 'https://rails-assets.org' do
# Assets via Bower
gem 'rails-assets-lodash', '~> 2.4'
gem 'rails-assets-angular', '~> 1.2'
gem 'rails-assets-angular-spree', '= 0.0.2'
end
error: Source does not contain any versions of 'rails-assets-lodash (~> 2.4) ruby' Run bundle install to install missing gems.
If I comment out the first gem I get similar error with the gem proceeding it. When I comment out the block it does work though, but I was instructed not to change the environment.
If you are using Bundler 1.8.0-1.8.2, you are probably hitting this bug: https://github.com/bundler/bundler/issues/3414
This should be fixed in Bundler 1.8.3 (released today).

Conflicting dependency

I have a conflicting dependency:
Gem A depends on Gem B 2.0
But
Gem C depends on Gem B 1.5
Should I force like this:
gem 'B', '~> 1.5'
All of my other gems are using Gem B 2.5 (the latet version) without problem though, so can I do something like this in my Gemfile?:
gem 'B' # 2.5
gem 'A', dependency: 'b 2.0'
gem 'C', dependency: 'b 1.5'
# gems happily use B 2.5
Update, my exact problem:
rails-observers(>=0) ruby
activemodel(~> 4.0)
jquery-scrollto-rails(>=) ruby
activemodel(~> 3.1.0)
My gemfile isn't enfocring any dependencies at all. No version number option.
bundle install
completes okay but
bundle update
results in the error above
Fork jquery-scrollto-rails on github and upgrade the version. Run it's testsuite. If it runs make a pull request and until it's accepted use your version from github.
If it's not running, then -
Don't complain, fix ;)
Edit
They have a newer version which supports railties 3 < 5
Add this to your Gemfile
gem 'jquery-scrollto-rails', '~> 1.4.3'
Then run $ bundle install
See rubygems
NOTE:
I recommend always using version specifications in your Gemfile. The most optimistic strategy is just by fixing them to the minor version e.g gem 'jquery-scrollto-rails', '~> 1.4'. This is a tremendious help for bundler, which has an np-complete problem to solve. In theory according to Semver there should be no incompatible changes on minor version updates and you could have fixed your problem just by running $ bundle update. A lot of gems do follow this convention, but there are blacksheeps

Resources