Ruby Sinatra Compile Error : Server handler (thin,puma,reel,HTTP,webrick) not found. (RuntimeError)

Viewed 4329

I'm new to Ruby Sinatra, I tried to build a simple web application with Sinatra with the following code:

require 'rubygems'
require 'sinatra'

get '/firstapp' do
    "Welcome to my first Sinatra App !"
end

when I tried to run it with the command "ruby file.rb" on windows command prompt, an error occured:

C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1755:in `detect_rack_handler': Server handler (thin,puma,reel,HTTP,webrick) not found. (RuntimeError)                                             
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/sinatra-2.1.0/lib/sinatra/base.rb:1493:in `run!'                                                                                                                       
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/sinatra-2.1.0/lib/sinatra/main.rb:45:in `block in <module:Sinatra>'

When I installed sinatra, I forgot to set the path to C:(ruby install directory)\bin. I have set the path after installing sinatra

I have no idea what happened. Can someone help me with this?

2 Answers

install these last one gem using

$ gem install thin
$ gem install puma
$ gem install reel
$ gem install http
$ gem install webrick

work for me

I encountered this problem when using Gemfile to manage my gems, if that is the case for you, rather than use gem install like @yaya-hc suggested, you can add them to your Gemfile

gem thin
gem puma
gem reel
gem http
gem webrick

then run bundle install and try again.

Related