2

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?

kkaul
  • 147
  • 1
  • 2
  • 13

1 Answers1

6

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
Jacob Brown
  • 7,221
  • 4
  • 30
  • 50
  • Perfect. I was using rvm so `rvmsudo ruby myapp.rb` worked perfectly. Thank you so much! – kkaul Aug 15 '13 at 14:56