I'm writing an app that accesses and edits google sheets. I have the same code working in a ruby test file, but when I copy the code line for line to the rails model it throws an error: cannot load such file -- google/apis/sheets_v4 (LoadError)
I have made sure to require google/apis/sheets_v4 and that I'm up to date on 'google-api-client' Both of my files are in the same folder, so they should have access to the same libraries.
The only potential source of error that I have so far is that some part of the app relies on a legacy version of google-api-client, so both 0.4.7 and 0.23.3 are installed. Is there a way to force utilization of one over the other?
The app was developed before my arrival at the company, so I don't know the reasoning for the use of a legacy api (yet).
Try the solution from this github forum to use the version you want:
I had to do
gem 'google-api-client', '~> 0.7.1'
then bundle update google-api-client addressable faraday and that let
me figure out which other gems to update for me to be able to use that
newer gem version. Because of dependencies by default bundle was
installing older version for me.
I'm trying to run bundle install on my rails project (I've just added Nokogiri) but I ran into a permission error. I installed rbenv (which seems like the right way to go) to get around that problem but now I'm getting
Could not find gem 'open-uri (>= 0) ruby' in the gems available on this machine.
I know that open-uri is part of ruby though so why am I getting this error?
OpenURI is part of the Ruby Standard library, it is not a gem. You therefor do not need to include it in your Gemfile, just require it in your code.
require 'open-uri'
open('http://stackoverflow.com/')
I'm trying to use Friendly ID to handle slugs in my Rails app. When I run "rails generate friendly_id", I get the following error:
/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require': no such file to load -- babosa (LoadError)
However, the babosa gem is definitely installed.
How can I even begin to solve this?
I was able to fix the problem by installing Bundler and adding the following lines to "Gemfile" in the root of my app:
gem 'babosa'
gem 'friendly_id'
I've not seen this problem myself, but have you tried the Google Group for the gem? It looks like that's the author's preferred communication method, and he looks to be fairly responsive there.
http://groups.google.com/group/friendly_id
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
I have a library that I'm trying to get working with rails 3 (specifically feedzirra) which I can require ok in irb but it breaks the console in my app with the following error:
http://pastie.org/855976
Found a bit of info on using feedzirra with rails 3. It looks like your problem might be with the Loofah library feedzira uses. It uses the deprecated config.framework.
Here's a link with some more info http://www.mythoughtpot.com/2010/02/10/feedzirra-on-rails3/
Rails3 modifies the $LOAD_PATH so it only contains gems listed in the Gemfile.
($LOAD_PATH is an array of directories where Ruby searches for libraries).
So you must add the Gem to the Gemfile and run bundle install.
You can check if the gem is in your path by typing puts $LOAD_PATH.grep(/feedzirra/) in the rails console.
For more information on using Bundler in Rails3 check out these:
http://railsdispatch.com/posts/bundler
http://railscasts.com/episodes/201-bundler