Upgrade ruby sub dependency - ruby-on-rails

I have a rails application that has the following dependency structure:
actionview (6.1.6.1)
rails-html-sanitizer (1.4.3)
loofah (2.18.0)
I'd like to get loofah to 2.19.1 without updating actionview. Is it possible to upgrade just the transitive dependency versions without changing the version of actionview?

I would run
bundle update loofah
to only update the loofah gem without toughing other dependencies if not needed.
See Updating a Gem Without Modifying the Gemfile.

Related

Install Rails 6 - Bundler could not find compatible versions for gem actionpack

We want to prepare our app for Rails 6.
gem 'rails', git: 'https://github.com/rails/rails.git', tag: 'v6.0.0.beta2'
I ran bundle install.
Bundler could not find compatible versions for gem "actionpack":
In Gemfile:
rails was resolved to 6.0.0.beta2, which depends on
actionpack (= 6.0.0.beta2)
rails-controller-testing was resolved to 1.0.4, which depends on
actionpack (>= 5.0.1.x)
rspec-rails was resolved to 3.8.2, which depends on
actionpack (>= 3.0)
sprockets-rails (~> 3.2.1) was resolved to 3.2.1, which depends on
actionpack (>= 4.0)
Not sure how exactly to go forward (should I comment out all gems which are listed as problematic? It seems to me that all dependencies are are using >= operator - doesn't this mean that actionpack (= 6.0.0.beta2) should be OK too? Can I get some guidance?
I invested more time into this and learned how to solve those issues. I am pretty sure that I didn't post most important part of the output about dependencies.
Normally there are gems which are locked to some gem versions. You want to find them manually via output. Be careful about output like this:
gem_xyz was resolved to 3.8.2, which depends on
actionpack (< 3.0)
Then you can check whether there is a fix on specific Github branch for e.g. Rails 6 version and use the gem directly from that branch. Not super easy but you can go forward slowly and prepare you project to be Rails6 a little bit earlier ...
I had the same issue when I was trying to test 6.0.0.rc2. I solved by removing the gem minitest-rails-capybara from the Gemfile and by improving system tests according to
https://edgeguides.rubyonrails.org/testing.html
The issue is not with actionpack but the other gems you are trying to install, the versions are not compactible with actionpack (= 6.0.0.beta2)
rails-controller-testing was resolved to 1.0.4
rspec-rails was resolved to 3.8.2
sprockets-rails (~> 3.2.1) was resolved to 3.2.1
You need to find versions that are compactible with the version of your actionpack. The version of actionpack is determined by the version of rails you are using. I had similar experience with
rspec-rails (~>3.4.2) and,
factory_girl_rails (~>1.0.4)
Upgrading both resolves the issue.

Bundler not able to use gem?

This is what is currently in my terminal. After Successfully setting up a rails app and making sure it worked. I set up the gem react-rails in my gem file. Then committed everything and from there I ran bundle install. Then I got an error stating that it could not find the babel-source-5.8.35 in any of the sources. but clearly its in my bundle ENV
➜ calendaract git:(master) bundle install
Using rake 12.3.1
Using concurrent-ruby 1.0.5
Using i18n 0.9.5
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using builder 3.2.3
Using erubi 1.7.1
Using mini_portile2 2.3.0
Using nokogiri 1.8.2
Using rails-dom-testing 2.0.3
Using crass 1.0.3
Using loofah 2.2.2
Using rails-html-sanitizer 1.0.4
Using actionview 5.1.5
Using rack 2.0.4
Using rack-test 0.8.3
Using actionpack 5.1.5
Using nio4r 2.3.0
Using websocket-extensions 0.1.3
Using websocket-driver 0.6.5
Using actioncable 5.1.5
Using globalid 0.4.1
Using activejob 5.1.5
Using mini_mime 1.0.0
Using mail 2.7.0
Using actionmailer 5.1.5
Using activemodel 5.1.5
Using arel 8.0.0
Using activerecord 5.1.5
Using public_suffix 3.0.2
Using addressable 2.5.2
***Using babel-source 5.8.35***
Using execjs 2.7.0
Using babel-transpiler 0.7.0
Using bindex 0.5.0
Using bundler 1.16.1
Using byebug 10.0.1
Using xpath 3.0.0
Using capybara 2.18.0
Using ffi 1.9.23
Using childprocess 0.9.0
Using coffee-script-source 1.12.2
Using coffee-script 2.4.1
Using method_source 0.9.0
Using thor 0.20.0
Using railties 5.1.5
Using coffee-rails 4.2.2
Using connection_pool 2.2.1
Using multi_json 1.13.1
Using jbuilder 2.7.0
Using rb-fsevent 0.10.3
Using rb-inotify 0.9.10
Using ruby_dep 1.5.0
Using listen 3.1.5
Using pg 1.0.0
Using puma 3.11.3
Using sprockets 3.7.1
Using sprockets-rails 3.2.1
Using rails 5.1.5
Using tilt 2.0.8
Using react-rails 2.4.4
Using rubyzip 1.2.1
Using sass-listen 4.0.0
Using sass 3.5.6
Using sass-rails 5.0.7
Using selenium-webdriver 3.11.0
Using spring 2.0.2
Using spring-watcher-listen 2.0.1
Using turbolinks-source 5.1.0
Using turbolinks 5.1.0
Using uglifier 4.1.8
Using web-console 3.5.1
Bundle complete! 17 Gemfile dependencies, 74 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
➜ calendaract git:(master) rails g react:install
Could not find babel-source-5.8.35 in any of the sources
Run `bundle install` to install missing gems.
So I Run bundle install, and clearly see my gem available locally all my paths and shims are set correctly. But when I run the generate script i get cannot find babel-source 5.8.35 and would love some help on what to do to be able to run?
rails generate react:install
It seems when you trying to do bundle install dependency for react-rails is missing so you need to either add babel-source to the Gemfile file list or install manually.
before starting check if that gem exist in your gem list:
gem list|grep babel-source # grep for ubuntu users you can use other alternative for other OS
and check whether it showing that gem and it is returning correct version or not else retry bundle install again as follows:
At first i suggest you to follow react github doc just make sure you haven't missed anything from it. if you still facing problem after that try adding that dependency gem as follows:
inside your Gemfile you can add this just above react-rails so that it meets the dependency when it tries to install. just make sure to remove Gemfile.lock so that it will be fresh installation.
gem 'babel-source', '~> 5.8.35'
then
bundle install
check whether your log and confirm your facing that error again or not if your facing again try manually you can run this in terminal:
gem install babel-source -v 5.8.35
then
bundle install
if it is successful run generate command for React.
all the above commands are debugging process since i cannot add much details into the comment option i'm posting it here so please let me know the results of it

Multiple versions of same gems on OSX [and how to get rid of them]

When I run gem list from my home directory (not from a project), I get a series of gems I have installed on my Mac. However, there seem to be a lot of gems with different versions that I know I don´t need, like this:
LOCAL GEMS
actionpack (4.2.6, 4.2.4, 4.2.2)
actionview (4.2.6, 4.2.4, 4.2.2)
activemodel (4.2.6, 4.2.4, 4.2.2)
activesupport (4.2.6, 4.2.4, 4.2.2)
bigdecimal (1.2.7, default: 1.2.6)
io-console (0.4.6, default: 0.4.3)
json (1.8.3, default: 1.8.1)
mini_portile2 (2.1.0, 2.0.0)
minitest (5.9.0, 5.8.4)
psych (2.0.17, default: 2.0.8)
rails-dom-testing (2.0.0, 1.0.7)
rake (11.1.2, default: 10.4.2)
rdoc (4.2.2, default: 4.2.0)
slop (4.3.0, 3.6.0)
uglifier (3.0.0, 2.5.3)
There are two (or even three) different versions of the same gem installed. I would guess that this could be that some gems, like Rake, use an older version as the default.
How can I get rid of these outdated gem versions, and how can I set the newer version (e.g. bigdecimal, io-console, rake, etc.) to be the default version of the gem?
You can remove gems globally from your computer by typing this
gem uninstall <gem_name> --version x.x.x
#Removes particular version of the gem
gem cleanup <gem_name>
#will remove all versions except the latest
But its not bad to have different versions, unless you think they are really obsolete and will never be used again.
To use a particular version of gem, I think Gemfile.lock is the best way to go. Or else you can refer this one link . It shows a similar problem to yours.

"Unable to activate" ruby gem: dependencyissue

I'm a noob to run gem dependencies. I get this error when trying to run a ruby program
.rbenv/versions/2.1.5/lib/ruby/2.1.0/rubygems/specification.rb:2064:in `raise_if_conflicts': Unable to activate familysearch-0.4.2, because faraday-0.9.1 conflicts with faraday (~> 0.8.4), multi_json-1.11.2 conflicts with multi_json (~> 1.5.0) (Gem::LoadError)
In trouble shooting, I installed Bundler. Here is what my lock file looks like:
GEM
remote: https://rubygems.org/
specs:
mini_portile (0.6.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
rack (1.6.4)
PLATFORMS
ruby
DEPENDENCIES
faraday (~> 0.9.1)
nokogiri
rack (~> 1.1)
BUNDLED WITH
1.10.5
I found similar stuff over the webs and their solutions. Unfortunately, none of these worked for me. Thank you for looking :)
The gem you're having issues with, familysearch-0.4.2, hasn't been updated since March of 2014. Hence, it's dependent on old gem versions.
I'd recommend submitting an issue to the Gem created, jimmyz, on Github via https://github.com/jimmyz/familysearch-rb/issues/new.
While the VCR tests for the gem aren't working (so I couldn't check my work), try using my forked version of the gem below where I updated the dependencies.
gem "familysearch", git: 'https://github.com/acpk/familysearch-rb.git'

Gem version conflict

I am getting the following error when I run 'bundle install':
Bundler could not find compatible versions for gem "activesupport":
In Gemfile:
google-drive (>= 0) ruby depends on
middleman-core (>= 3.2.2) ruby depends on
activesupport (~> 3.2.6) ruby
rails (= 4.2.0) ruby depends on
activesupport (4.2.0)
I don't specify a version for the google-drive gemfile, but I do specify gem 'rails', '4.2.0'.
If I fail to specify a rails version, I get a really old version.
Try to update google-drive. Run bundle update google-drive.
Well - it looks like I was using the wrong gem. It's google_drive not google-drive.

Resources