Eric Fortis
Eric Fortis

Reputation: 17350

How to run Ruby?

This is my first time using Ruby, I hope you can help me to run this example. I've cloned cloud and cloud_examples in two subdirectories of ~/learnRuby/, and gem install cloud.

ruby -v   // ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
gem list  // cloud(0.0.1), RubyInline (3.8.6), pdf-writer (1.1.8)

I added to the .rb a shebang #!/usr/bin/env ruby and execute permissions.
Edit: Also added require 'rubygems'

Now, when I try to run one of the examples I get:

/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': 
no such file to load -- cloud (LoadError)
    from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from ./gettysburg.rb:4

Please help me to get in the right direction, btw I'm using Ubuntu.

Upvotes: 1

Views: 1786

Answers (2)

Nemo157
Nemo157

Reputation: 3589

I've had problems before when using the default Ubuntu ruby and trying to find installed gems. Best solution I would suggest is using RVM to manage your ruby and gems instead, it takes a bit more to get setup but once done I've not had any problems with finding gems.

Alternatively look at my answer here if you would prefer to stick to the default ruby.

Upvotes: 1

Garrett
Garrett

Reputation: 8070

You need to include rubygems before you include any other gems.

#!/usr/bin/env ruby
require 'rubygems'
require 'cloud'

# code

Upvotes: 1

Related Questions