I was having problems of the form:
/usr/local/share/gems/gems/sqlite3-1.3.7/lib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (LoadError)
when trying to run a rails app as root, after running bundle install as root.
An article at http://www.petersens.ws/2012/08/ruby-on-rails-and-sqlite3 helped me figure out the problem. Some of the apps with native extensions don't set GEM_HOME properly as root. The easiest way to fix this is to run gem uninstall on the offending gem, then run the bundle install as a regular user. I also ran into this with
posix_spawn (/usr/local/share/gems/gems/posix-spawn-0.3.6/lib/posix/spawn.rb:2:in `require': cannot load such file -- posix_spawn_ext (LoadError))
charlock_holmes (/usr/local/share/gems/gems/charlock_holmes-0.6.9.1/lib/charlock_holmes.rb:1:in `require': cannot load such file -- charlock_holmes/charlock_holmes (LoadError))
yajl_ruby (/usr/local/share/gems/gems/yajl-ruby-1.1.0/lib/yajl.rb:1:in `require': cannot load such file -- yajl/yajl (LoadError))
redcarpet (/usr/local/share/gems/gems/redcarpet-2.2.2/lib/redcarpet.rb:1:in `require': cannot load such file -- redcarpet.so (LoadError))
nokogiri (/usr/local/share/gems/gems/nokogiri-1.5.6/lib/nokogiri.rb:27:in `require': cannot load such file -- nokogiri/nokogiri (LoadError))
In all cases, uninstalling the gem as root, then running bundle install as a regular user fixed it.
Thursday, April 18, 2013
Friday, April 5, 2013
Getting a ruby gem to load rake tasks
I had a gem (call it foo_bar) which implemented a Bar module. It included and ran fine in my Rails project when I added gem "foo_bar" to the module, but I couldn't get the rake tasks to show when I ran rake -T. After some review, I found that the name of the ruby file that kicked everything off was lib/bar.rb when it should have been lib/foo_bar.rb. Changing the file name to match the name in the gemspec fixed it.
You will want to check your gem to make sure your
require 'bar'
statements are actually
require 'foo_bar'
statements.
You will want to check your gem to make sure your
require 'bar'
statements are actually
require 'foo_bar'
statements.
Subscribe to:
Posts (Atom)