Ruby - Can't require gem properly - ruby

I'm trying to require the gem 'cerebrum'. I tried requiring it using the irb, and that worked, and also running the program in JRuby worked too. However, Ruby throws a LoadError.
C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- cerebrum (LoadError)
from C:/Ruby23-x64/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
What am I doing wrong? Has anyone had that issue too?

You get the load error when gem is not installed. First check if this gem is installed in this ruby version using gem list cerebrum. It may be installed in your jruby that's why it didn't throw error.

Related

Cannot load libxml_ruby.so for libxml-ruby gem

I installed the libxml-ruby gem, with the --platform=x86_64 flag, and whenever I try to require 'xml' I get an error.
Ruby24-x64/lib/ruby/site_ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require':
126: The specified module could not be found.
- I:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/libxml-ruby-3.0.0/lib/libxml_ruby.so (LoadError)
I checked, and libxml_ruby.so is in that directory. Any ideas on how to fix this?
I am using Ruby version 2.4.1 on Windows 10.

How to fix cannot load such file -- Nokogiri (LoadError) in c9.io?

I'm using Cloud9 IO for Ruby.
I ran bundle install.
Even installed the gems.
But I'm still getting this error.
scarletmclearn:~/workspace/nokogiri_tutorial (master) $ ruby
web_scraper.rb
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in
require': cannot load such file -- Nokogiri (LoadError)
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in
require'
from web_scraper.rb:1:in `'
Do check out my Repository : https://github.com/ScarletMcLearn/ruby_ws_1/tree/master/workspace
a beginner here, so simple instructions on which file or what to change will help.
Thanks for the read!
from your command prompt install nokogiri by running
gem install nokogiri

cannot load such file -- rubygems.rb (LoadError)

I'm new to ruby. I removed ruby 1.9 with sudo apt-get purge ruby and then
I installed ruby 2.3.0 using ruby-install. But I got the following error
<internal:gem_prelude>:4:in `require': cannot load such file -- rubygems.rb (LoadError)
from <internal:gem_prelude>:4:in `<internal:gem_prelude>
when running rspec my_script.rb.
Still can't fix this after googling! Anyone can help me out?
It seems that the rspec binary was only installed for your previous ruby version. Therefore it is found, but not guaranteed to work.
I'd recommend to use something like rvm (https://rvm.io/) or rbenv (https://github.com/rbenv/rbenv). Both of them can easily handle different ruby versions while maintaining dependencies (e.g. different load paths, different gem versions, etc.). I'd even use rvm if there is only one single ruby version installed on a system.

require 'nokogiri' issue with Ruby 1.9.2

I have made a Ruby project (not rails project) in Netbeans, and in main.rb file i have been requiring nokogiri but i am getting the following error.
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- nokogiri (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from /home/nadeem/rails_project/RubyApplication1/lib/main.rb:2:in `<main>'
I have installed nokogiri 1.5.0 and using ruby 1.9.2
Any idea?
Using bundler to manage your gem dependencies is probably a good idea because you can check if things are set up properly using bundle check if you've declared and successfully installed them.
The bundler setup routine can import many gems in the proper order, accounting for dependencies. Otherwise you will need to have at least this:
require 'rubygems'
gem 'nokogiri'
require 'nokogiri'
Make sure that the gems are installed with the same version of Ruby you're trying to run. It's easy to get mixed up when you're using rvm and have inadvertently added the gems to a different version.
Refer to this solution hope this will be helpful, Check your net bean's project properties and try to update path from there.
Require Nokogiri? No such file to load

Including gems in ubuntu 11.04

I've got a problem with running an additional gem under ubuntu 11.04. I installed spiceweasel via gem install - which put it in /var/lib/gems/1.8/gems/spiceweasel. When I try to run it, I get:
`require': no such file to load -- spiceweasel/version (LoadError)
The file is in /var/lib/gems/1.8/gems/spiceweasel-0.7.1/lib/spiceweasel/version.rb but cannot be loaded. This happens both with and without -rubygems.
How do I fix this?
It seems to be the same problem like here: Ruby: require 'irbtools' raises LoadError
The gem author published the gem with wrong permissions. You should contact the gem author.

Resources