3

New ubuntu-20 system with the following:

  ruby 3.0.4
  rails 6.1.4
  redmine 5.0.0

After install, trying to start webrick test server:

bundle exec rails server webrick -e redmine_test

fails with:

/home/test_user/.gem/ruby/3.0.4/gems/thor-1.2.1/lib/thor/base.rb:525:in `handle_argument_error':
  ERROR: "rails server" was called with arguments ["webrick"] (Thor::InvocationError)
Usage: "rails server -u [thin/puma/webrick] [options]"
        from .../thor-1.2.1/lib/thor/command.rb:34:in `rescue in run'
        from .../thor-1.2.1/lib/thor/command.rb:20:in `run'
        from .../thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
        from .../thor-1.2.1/lib/thor.rb:392:in `dispatch'
        from .../railties-6.1.4.7/lib/rails/command/base.rb:69:in `perform'
        from .../railties-6.1.4.7/lib/rails/command.rb:48:in `invoke'
        from .../railties-6.1.4.7/lib/rails/commands.rb:18:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'
.../railties-6.1.4.7/lib/rails/commands/server/server_command.rb:130:in `perform':
  wrong number of arguments (given 1, expected 0) (ArgumentError)
        from .../thor-1.2.1/lib/thor/command.rb:27:in `run'
        from .../thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
        from .../thor-1.2.1/lib/thor.rb:392:in `dispatch'
        from .../railties-6.1.4.7/lib/rails/command/base.rb:69:in `perform'
        from .../railties-6.1.4.7/lib/rails/command.rb:48:in `invoke'
        from .../railties-6.1.4.7/lib/rails/commands.rb:18:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

It's not clear to me which arguments / syntax it's complaining about; I've tried different combinations and all complain about wrong number of arguments:

bundle exec rails server webrick -e redmine_test        (given 1, expected 0)
bundle exec rails server webrick -e=redmine_test        (given 1, expected 0)
RAILS_ENV=redmine_test bundle exec rails server webrick (given 1, expected 0)
bundle exec rails server webrick redmine_test           (given 2, expected 0)
bundle exec rails server webrick                        (given 1, expected 0)
Gary Aitken
  • 233
  • 2
  • 12

2 Answers2

4

The command-line format seems to have changed for Rails 6:

> rails server --help
Usage:
  rails server -u [thin/puma/webrick] [options]
               ^^

You may also need to add webrick to your Gemfile:

bundle add webrick
Casper
  • 33,403
  • 4
  • 84
  • 79
  • Thanks. But now it complains about "Could not load server "webrick". Maybe add to Gemfile? But it is in Gemfile.lock, although not in Gemfile. – Gary Aitken May 21 '22 at 21:27
  • @GaryAitken You could try `bundle add webrick; bundle install` to make sure. On my system it works, but i have webrick among my system gems. – Casper May 21 '22 at 22:14
  • Can't remember what I did, I think "bundle add webrick". Thanks. I'm almost there, but can't get passenger to start under apache; a gem path problem that doesn't make sense to me -- [link] (https://stackoverflow.com/questions/72339642/apache-passenger-rails-ruby-redmine-rails-startup-gem-path-problem) – Gary Aitken May 23 '22 at 19:47
  • The solution (using the -u) saved my time. Thanks a lot! So finally the command needed to run is `bundle exec rails server -u webrick -e redmine_test` – Shamim Aug 18 '22 at 13:34
0

Casper showed that solution and I am rearranging the solution point by point here.

  1. Add webrick if it's not already installed. bundle add webrick
  2. Run bundle exec rails server -u webrick -e redmine_test Look at the last keyword redmine_test. It's the enviroment that you are using for this case. So, write production if you are trying to run it in production.
Shamim
  • 635
  • 2
  • 12
  • 28