I cant load Ruby Gems - ruby

i am getting this error whenever i try to load a ruby gem
/home/hilarl/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- twit
ter (LoadError)
from /home/hilarl/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from sample.rb:2:in `<main>'
can you please help?

You missed to use a ruby, in normal console first run:
rvm use 1.9.3
If it's in a script then instead use following path to ruby:
$rvm_path/wrappers/ruby-1.9.3-p194/ruby
You should get also the minimal basics of using RVM:
screencast: http://screencasts.org/episodes/how-to-use-rvm
cheatsheet: http://cheat.errtheblog.com/s/rvm/
rvm site: https://rvm.io/

Related

Ruby - Can't require gem properly

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.

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

LoadError when executing ruby code in /etc/rc.d/rc.local

I use CentOS 6.6. I want to execute a Ruby code on startup, so I added the following command to execute the code to /etc/rc.d/rc.local.
ruby /ruby/send_mail.rb
In send_mail.rb, there is require 'mail', but error occurred like the following.
/usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- mail (LoadError)
from /usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /ruby/send_mail:23:in `<main>'
(I got this error by using ruby /ruby/send_mail.rb &> error_output)
I did gem install mail. And "send_mail.rb" works properly when I run this manually. Would you tell me what I should do?
Try running ruby using the RVM wrappers, as described here:
/usr/local/rvm/wrappers/ruby-2.2.2/ruby /ruby/send_mail.rb

Rails Sinatra application not loading Gems. Do I have them in the wrong place?

I hope you can help me.
I am working on a small Sinatra Rails application. I have Ruby installed on Mac OSX using RVM (currently using ruby 1.9.2)
I changed my app to include some new gems and to use bundler/setup but I receive the following error when I start the server:
/Users/Matt/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- bundler/setup (LoadError)
from /Users/Matt/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from application.rb:2:in `<main>'
I am fairly sure I have something going wrong here, I'm just not sure what or how to fix it.
Running the which commands receives the following output:
which ruby: /Users/Matt/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
which bundle: /Users/Matt/.rvm/gems/ruby-1.9.2-p290/bin/bundle
which gem: /Users/Matt/.rvm/rubies/ruby-1.9.2-p290/bin/gem
Please can someone help me as this is starting to drive me a little crazy.
Many thanks in advance for your help.
from the #stephenmurdoch's comment above:
try running gem install bundler followed by bundle install from inside your application.

Problem with RVM and gem that has an executable

I've recently made the plunge to use RVM on Ubuntu.
Everything seems to have gone swimmingly...except for one thing. I'm in the process of developing a gem of mine that has a script placed within its own bin/ directory, all of the gemspec and things were generated by Jeweler.
The bin/mygem file contains the following code: -
#!/usr/bin/env ruby
begin
require 'mygem'
rescue LoadError
require 'rubygems'
require 'mygem'
end
app = MyGem::Application.new
app.run
That was working fine on the system version of Ruby.
Now...recently I've moved to RVM to manage my ruby versions a bit better, except now my gem doesn't appear to be working.
Firstly I do this: -
rvm 1.9.2
Then I do this: -
rvm 1.9.2 gem install mygem
Which installs fine, except...when I try to run the command for mygem
mygem
I just get the following exception: -
daniel#daniel-VirtualBox:~$ mygem
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- mygem (LoadError)
from <internal:lib/rubygems/custom_require>:29:in `require'
from /home/daniel/.rvm/gems/ruby-1.9.2-p136/gems/mygem-0.1.4/bin/mygem:2:in `<top (required)>'
from /home/daniel/.rvm/gems/ruby-1.9.2-p136/bin/mygem:19:in `load'
from /home/daniel/.rvm/gems/ruby-1.9.2-p136/bin/mygem:19:in `<main>'mygem
NOTE: I have a similar RVM setup on MAC OSX and my gem works fine there so I think this might be something to do with Ubuntu?
Using:
rvm 1.9.2 gem install mygem
is different than how I do my installs of gems inside RVM.
Try:
rvm 1.9.2
gem install mygem
You might also want to try doing gem pristine mygem which will tell Gems to remove the executable and recompile it for the current Ruby.
Another thought: Were you previously using Ruby 1.8+, and just changed to Ruby 1.9+? In Ruby 1.9 the require acts differently when loading modules that are relative to the calling code, say, in a child directory, because '.' was removed from the search path. require_relative was added to give us that capability.
Does doing export RUBYOPT=rubygems help?

Resources