Question

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?

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top