2

I just downloaded Ruby 2.0 and have a serious problem with require when I try to run a simple Sinatra app:

/Users/Kuba/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- sinatra (LoadError)
from /Users/Kuba/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from test.rb:1:in `<main>'

Also, this and other programs I have a problem with now, worked perfectly fine when i was using Ruby 1.8.7.

What should I do?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Leo
  • 2,061
  • 4
  • 30
  • 58

3 Answers3

3

I had this problem today too when upgrading to >= 1.9, I was given this article to read: "Upgrading From REE 1.8.7 to Ruby 1.9.3"

The relevant portion of your question, as mentioned in your comment:

but programs in which i dont use any gems, but just other files made by myself, gives me the same result

From the article1

Load Paths:

In Ruby 1.9.3, LOAD_PATH no longer includes “.” because it was deemed a security risk. You can explicitly add it when requiring files, use absolute paths, or use require_relative.

Community
  • 1
  • 1
Daniël W. Crompton
  • 3,448
  • 25
  • 26
2

Did you also install the gems?

Ruby 2.0 is a complete new installation. Installing ruby 2.0 does not mean you keep the installed gems.

This is not Ruby 2.0 specific. As far as I know each new ruby installation has its own gems.

There are tools to administrate diffferent rubies:

  • rvm (ruby version manager)
  • pik for windows
knut
  • 27,320
  • 6
  • 84
  • 112
  • but programs in which i dont use any gems, but just other files made by myself, gives me the same result – Leo Mar 02 '13 at 21:32
  • [Sinatra](https://rubygems.org/gems/sinatra) is a gem. How do you use ruby? Do you use ruby from shell or from a web application? Maybe you use ruby from a web application, without recognizing you use additional gems. – knut Mar 02 '13 at 21:36
  • ok, but i also tried to run other programs, not just this one using sinatra. some of them had other files attached using requires (some modules and stuff), and they all refused to work. and i know they are written correctly, since i've been using them multiple times before – Leo Mar 02 '13 at 21:39
  • i run those programs using terminal, on mac mountain lion if thats what you want to know – Leo Mar 02 '13 at 21:40
  • Can you take a look to `/Users/Kuba/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/gems/2.0.0/gems`? There you should see all installed gems for your ruby 2.0.0 installation. Is there sinatra (or one of the other missing gems)? – knut Mar 02 '13 at 21:46
  • there are only rake, rdoc and test-unit, but how can it be gem issue, since ruby crushes anytime i use require, not only with gems? – Leo Mar 02 '13 at 21:49
  • `require` needs a source from where to load. And that's in the gems-path. Or in other words: With `gem 'xx'` you have the possibility to define which version of the gem you want like in `gem 'xx', '=1.0.0'`. Without the gem-command, require takes the most actual version of the gem, that contains your required file. – knut Mar 02 '13 at 21:52
  • ok, right now i've installed sinatra again, and it works. but my other programs using require still suck... – Leo Mar 02 '13 at 21:52
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/25437/discussion-between-knut-and-kuba-polaczek) – knut Mar 02 '13 at 21:55
0

Probably the libraries you were using are located under the directory for Ruby 1.8. I think it is a good idea to freshly reinstall the required libraries under Ruby 2.0.

sawa
  • 165,429
  • 45
  • 277
  • 381