Rackup: unable to load such a file 'sinatra'

I already installed sinatra gem in irb , if I print,

 require 'sinatra' 

Returns true .

But when I do

 rackup -d config.ru 

It tells me

 nil Exception `LoadError' at /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36 - cannot load such file -- sinatra 

Here is my config.ru

 require './app' set :environment, ENV['RACK_ENV'].to_sym set :app_file, 'app.rb' disable :run run Sinatra::Application 

app.rb

 require 'rubygems' require 'sinatra' get '' do 'Hello World' end 

I do not know what is going wrong.


 $ which ruby /usr/local/bin/ruby $ which rackup /usr/local/bin/rackup $ ruby -v ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-linux] $ rackup -v Rack 1.2 (Release: 1.5) 
+4
source share
3 answers

I assume your flash drive script is a rack binstub installed in diff ruby1.9x vm

perhaps an earlier version of ruby1.9.2 so he cannot see the installed sinatra

I would try some sort of raid on the command line

+1
source

I think this is just a verbose output from the -d . Does the server really start (after creating the output load)?

What's happening? Using -d , set the Rubys $DEBUG flag to true . Then Rack tries to download the application through config.ru , which in turn downloads your app.rb The first thing in app.rb is require 'sinatra' .

Rubygems replaces the original require method with its own. When you call require , it tries to download the file, usually using the existing download path and the original require method . If the gem has not been loaded, it will raise a LoadError that Rubygems catches before loading the gem.

With the $DEBUG flag set, Ruby throws a message when an exception occurs, even if it is saved and processed, and this is what you see.

To avoid this, simply lower the -d flag to your call to rackup (perhaps turning on warnings with -w will give you a fairly detailed output without dropping you too much).

If the server does not start, it will be another problem, not a Sinatra search. If so, you need to check the rest of the output for clues.

(Note that I initially thought something else was happening, and that is what my questions were in his comments about.)

+1
source

This is definitely a boot path issue. In any case, try to install the necessary rubies and gems through the RVM and the Bundler. It ensures that Ruby interpreters and boot paths are consistent.

0
source

All Articles