简体   繁体   中英

Sinatra LoadError

While working on a Sinatra App, I came about a peculiar problem, hopefully which someone could help me out with. I'm running ruby 1.9.3 and when I run my app using ruby myapp.rb It runs on the localhost with an error. However when I tried sudo ruby myapp.rb It gives me an error that Sinatra could not be loaded and when it shows me the library from which it pulls sinatra, it is /usr/lib/ruby/1.9.1

I think thats where my problem is, but I don't know how to change this path. Do I do it in my app, or terminal to change the path for ruby, any help?

If you're using RVM for 1.9.3, you can just do

rvmsudo ruby myapp.rb

If you've set up 1.9.3 some other way, figure out the location of your 1.9.3 binary by doing:

$ which ruby
/whatever/path/ruby-1.9.3-p125/bin/ruby
$ sudo /whatever/path/ruby-1.9.3-p125/bin/ruby myapp.rb

You could also just install Sinatra and any other gems needed for your system Ruby:

sudo gem install sinatra

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM