在开发模式下工作正常。但是,当我执行rails s生产命令时,我有以下错误消息:
rails s production
Exiting
Traceback (most recent call last):
20: from bin/rails:4:in `<main>'
19: from bin/rails:4:in `require'
18: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
17: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
16: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
15: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
14: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
13: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
12: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `perform'
11: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `tap'
10: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:135:in `block in perform'
9: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:38:in `start'
8: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:67:in `print_boot_information'
7: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:96:in `use_puma?'
6: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/rack-2.0.3/lib/rack/server.rb:301:in `server'
5: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/rack-2.0.3/lib/rack/handler.rb:16:in `get'
4: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/rack-2.0.3/lib/rack/handler.rb:74:in `try_require'
3: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
2: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
1: from /home/cabox/.rvm/gems/ruby-2.5.1/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/home/cabox/.rvm/gems/ruby-2.5.1/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require': cannot load such file -- rack/handler/production (LoadError)
我认为这与错误的最后一行有关:
5.1.4/lib/active_support/dependencies.rb:292:in `require': cannot load such file -- rack/handler/production (LoadError)
我试图在没有任何结果的情况下使用activesupport gem。我正在运行Ruby on Rails 5.1.4,rvm运行ruby 2.5.1。我的操作系统是ubuntu 14.04。
答案 0 :(得分:3)
正确的命令是:
rails server -e production
或者您可以使用完整选项执行此操作:
rails s -e production -p [your port] -b [your ip address] -P tmp/pids/test.pid