开发者

How to run Ruby?

开发者 https://www.devze.com 2023-02-03 22:16 出处:网络
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.

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.

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.


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号