Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用ruby启动精简服务器?要求';:无法加载此类文件--应用程序(LoadError)_Ruby_Sinatra - Fatal编程技术网

如何使用ruby启动精简服务器?要求';:无法加载此类文件--应用程序(LoadError)

如何使用ruby启动精简服务器?要求';:无法加载此类文件--应用程序(LoadError),ruby,sinatra,Ruby,Sinatra,我想使用精简服务器启动我的应用程序 在config.ru中 require 'sinatra' require 'app' run Sinatra.application 它们在同一个目录上 kithokit@19:05:26 hello (master) $ ls config.ru app.rb app.rb config.ru 但我还是犯了这个错误 kithokit@19:05:14 meet-api (master) $ thin start Using rack adapte

我想使用精简服务器启动我的应用程序

在config.ru中

require 'sinatra'

require 'app'
run Sinatra.application
它们在同一个目录上

kithokit@19:05:26 hello (master) $ ls config.ru app.rb 
app.rb  config.ru
但我还是犯了这个错误

kithokit@19:05:14 meet-api (master) $ thin start
Using rack adapter
/home/kithokit/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- app (LoadError)
        from /home/kithokit/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
换行

require 'app'


有关更多备选方案,请参见:

有点困惑。我使用ruby-1.9.3,这意味着需要“应用程序”才能工作。但是你是对的,我们需要加上“/”你知道为什么吗?还有其他引用吗?最好使用$LOAD_PATH。unshift('.')而不是$LOAD_PATH unshift将在路径前面加上前缀。这意味着您自己的类被加载,以支持使用相同名称的gems等。通常情况下,您会避免名称冲突,因此在实践中我想这并不重要。如果您仔细阅读,您会注意到
/
对于1.9.2及以上版本是必需的,这意味着在1.9.1之前它只会以“旧方式”工作。您有1.9.3,它在
$LOAD\u PATH
中没有
/
require './app'