Question

For some reason, we cannot run rails console in production. The command rails console -e production works on our Windows machine but fails on our Mac.

This SO post explains how to solve it, but can someone explain why we're seeing this error message on one machine and not the other?

/usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands/console.rb:23:in `block in start': invalid option: -e (OptionParser::InvalidOption)
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands/console.rb:18:in `new'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands/console.rb:18:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Thanks!

Was it helpful?

Solution

Like the error says, -e is not a valid option for a rails console command (in your version of Rails). This is the proper usage:

$ rails console --help
Usage: console [environment] [options]
    -s, --sandbox                    Rollback database modifications on exit.
        --debugger                   Enable ruby-debugging for the console.
        --irb                        DEPRECATED: Invoke `/your/choice/of/ruby script/rails console` instead

OTHER TIPS

Actually, I do see the -e option. Funny

rails console --help

gives

Usage: rails console [environment] [options]
    -s, --sandbox                    Rollback database modifications on exit.
    -e, --environment=name           Specifies the environment to run this console under (test/development/production).
                                     Default: development
        --debugger                   Enable the debugger.

rails console -e production

gives me

Loading production environment (Rails 4.0.1)
irb(main):001:0>

I am on Rails 4.0.1.

Edit - missed the part about the problem being in 3.2.12.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top