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 permissi开发者_开发问答ons.
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.
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.
You need to include rubygems
before you include any other gems.
#!/usr/bin/env ruby
require 'rubygems'
require 'cloud'
# code
精彩评论