I just did a bundle update on my Rails 6 app, and since I have a long warning every time I bundle exec something :
RubyZip 3.0 is coming!
**********************
The public API of some Rubyzip classes has been modernized to use named
parameters for optional arguments. Please check your usage of the
following classes:
* `Zip::File`
* `Zip::Entry`
* `Zip::InputStream`
* `Zip::OutputStream`
Please ensure that your Gemfiles and .gemspecs are suitably restrictive
to avoid an unexpected breakage when 3.0 is released (e.g. ~> 2.3.0).
See https://github.com/rubyzip/rubyzip for details. The Changelog also
lists other enhancements and bugfixes that have been implemented since
version 2.3.0.
I don't have rubyzip in my Gemfile, it's a dependancy of webdrivers and selenium-webdriver, libraries used to get a headless browser for Capybara testing.
What can I do to get rid of this warning ?
This warning was added in rubyzip 2.3.1 to give people time to get ready for the 3.0 release which will have breaking changes. If you don't want to see the warning just lock the rubyzip version to 2.3.0 in the development/test section of your Gemfile
gem 'rubyzip', '2.3.0'
this is what I believe a simple problem I need help with. I'm trying to modify a gem's method so that I can add another argument to it. For this, I've cloned the gem's repo to a local directory and changed the code I needed. Inside my app's Gemfile I'm doing this:
gem 'recommendable', path: "/home/aristizabal95/forked_gems/recommendable"
And running bundle install afterwards. Even though the bundler says it's using my code, when I run the tests I get this error:
ArgumentError: wrong number of arguments (given 4, expected 1..3)
from /var/lib/gems/2.3.0/gems/recommendable-2.2.0/lib/recommendable/rater/recommender.rb:21:in `recommended_for'
which indicates that the app is not running my version of the gem, but the original one. I have no idea why it's not working, and was unable to find any issue related to this.
Thanks in advance
EDIT:
This is what the Gemfile.lock looks like
PATH
remote: /home/aristizabal95/forked_gems/recommendable
specs:
recommendable (2.2.1)
activesupport (>= 3.0.0)
hooks (>= 0.2.1)
redis (>= 2.2.0)
GEM
recommendable!
My guess is that spring still has the gem from the original gem source loaded.
To force spring to reload the gem (from your local source), do:
spring stop
in the console. Then restart your server and you should be using the gem from your local source.
I am trying to build an app in Rails. For my app I need to use the ns-api (dutch railways) in order to get from them the trains timetables. It exists as a gem (https://github.com/zilverline/ns-api) I use the bundler and I get the message that all the gems are ok, but when I am trying to create a controller it gives me the error that it does not recognise NSclient . This happens also when I use "require 'ns_client'" in my controller or in my configuration file. I think that although the bundler seems to work , the gem is not compatible with my Rails (ver 5.0.0) or my ruby version. Any way that I could solve this ?
I have two ruby files where one file is using "require 'zip/zip'" with rubyzip version '0.0.9' and other "require 'zip'" with rubyzip version 1.1.7. If use them separately(alone) its working fine.If i combine i am getting error like "no such file to load — zip/zip". How can i solve this?
My Ruby version : 1.9.3
Rails version : 2.3.14
Thanks.
The zip-zip is gem so you can write it in Gemfile. The zip however is an Array method, so you can use it without having to require.
I'm getting the following error:
Gem::Exception: can't activate hpricot (= 0.6.161, runtime),
already activated hpricot-0.8.3
0.6 is installed locally, 0.8.3 is frozen in my app.
This is my "stacktrace":
Loading production environment (Rails 2.3.10)
/software/ruby-ror-gem-1.3.1/lib/rubygems.rb:149:in `activate':Gem::Exception: can't activate hpricot (= 0.6.161, runtime), already activated hpricot-0.8.3
/e/app/www.example.com/rails/releases/20101117142713/vendor/rails/railties/lib/console_with_helpers.rb:5:NameError: uninitialized constant ApplicationController
How do I figure out which gem or library has a dependency on hpricot 0.6?
I've added the output of user438962's command below:
{"daemons-1.0.9"=>[],
"scgi_dp_rails-0.0.5"=>["preforkdp", "daemons"],
"rails-2.3.10"=>[],
"rwfd-0.1.0"=>[],
"nokogiri-1.3.2"=>["racc", "rexical", "rake-compiler", "hoe"],
"activesupport-2.3.10"=>[],
"rack-1.0.1"=>
["test-spec",
"camping",
"fcgi",
"memcache-client",
"mongrel",
"ruby-openid",
"thin"],
"rack-1.1.0"=>
["test-spec", "camping", "fcgi", "memcache-client", "mongrel", "thin"],
"preforkdp-0.1.2"=>["rwfd"],
"activerecord-2.3.10"=>[],
"hpricot-0.6.161"=>[],
"cgi_multipart_eof_fix-2.5.0"=>[],
"fastthread-1.0.1"=>[],
"gem_plugin-0.2.3"=>[],
"activeresource-2.3.10"=>[],
"ferret-0.11.6"=>["rake"],
"mysql-2.7"=>[],
"actionmailer-2.3.10"=>[],
"actionpack-2.3.10"=>[],
"hpricot-0.8.3"=>[],
"mongrel_upload_progress-0.2.2"=>["mongrel", "gem_plugin"],
"mongrel-1.1.3"=>
["gem_plugin", "daemons", "fastthread", "cgi_multipart_eof_fix"],
"mongrel_cluster-1.0.5"=>["gem_plugin", "mongrel"],
"rake-0.8.4"=>[],
"haml-2.0.9"=>[],
"remvee-mini_magick-1.2.3.4.0"=>[]}
If you use Bundler, you avoid this problem and you have the really great command : bundle viz
This Command generate a graph with all dependencies.
require 'rubygems'
require 'pp'
h = {}
Gem.source_index.each{|g, spec| h[g] = spec.dependencies.map{|d| d.name} }
pp h
I found that rfeedparser is the gem that uses hpricot 0.6.
The problem is that this version (0.6) works with rfeedparser, but emits the warning "Passing no parameters to XML::SaxParser.new is deprecated."
Well, with newer versions of hpricot (at least 0.8.2), this warning seems to have taken effect, because now having that version of hpricot or newer causes "ArgumentError: wrong number of arguments (1 for 0)" when calling FeedParser.parse(url).
Unfortunately, I've found that the only way to make this work with legacy Rails (we have a 2.2.2 app) is to uninstall any hpricot version that's not 0.6.
The issue will be that one of the gems you use depends on hpricot version 0.6.161
and so tries to load it, but that you already have hpricot-0.8.3 loaded. The more recent version might be loaded if you're using hpricot yourself, and have required hpricot for use without specifying a version. If that's the case, you can change your own require to be the same version as the other gem uses (0.6.161).
The other reason the more recent version of hpricot is being loaded, could be that another gem you use depends on that version of hpricot, meaning you can't use the specific versions of those two gems you have because they have clashing requirements for their hpricot version.
Use the methods other users have posted to help you track down the dependencies of the gems you are using.
You could try grepping your load path:
$:.each do |dir|
cmd = %(grep -r hpricot #{dir})
puts cmd
puts `#{cmd}`
end