[英]Ruby Sinatra Compile Error : Server handler (thin,puma,reel,HTTP,webrick) not found. (RuntimeError)
I'm new to Ruby Sinatra, I tried to build a simple web application with Sinatra with the following code:我是 Ruby Sinatra 的新手,我尝试使用 Sinatra 构建一个简单的 web 应用程序,代码如下:
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:当我尝试在 windows 命令提示符上使用命令“ruby file.rb”运行它时,出现错误:
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.安装 sinatra 时忘记设置 C:(ruby 安装目录)\bin 的路径。 I have set the path after installing sinatra
我在安装 sinatra 后设置了路径
I have no idea what happened.我不知道发生了什么。 Can someone help me with this?
有人可以帮我弄这个吗?
install these last one gem using使用安装这些最后一个 gem
$ 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我在使用 Gemfile 管理我的 gem 时遇到了这个问题,如果你是这种情况,而不是像 @yaya-hc 建议的那样使用
gem install
,你可以将它们添加到你的 Gemfile
gem thin
gem puma
gem reel
gem http
gem webrick
then run bundle install
and try again.然后运行
bundle install
试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.