This project is archived and is in readonly mode.

#3435 ✓resolved
Sam Ruby

--database option broken

Reported by Sam Ruby | October 28th, 2009 @ 04:12 AM | in 3.0.2

$ruby $RAILS/railties/bin/rails --database=mysql depot
no value provided for required arguments 'app_path'

Comments and changes to this ticket

  • Grzegorz Kazulak

    Grzegorz Kazulak October 31st, 2009 @ 09:29 PM

    That should solve it. Set's the default for app_path to the current dir.

  • Prem Sichanugrist (sikachu)

    Prem Sichanugrist (sikachu) January 20th, 2010 @ 05:30 PM

    • State changed from “new” to “resolved”
  • Sam Ruby

    Sam Ruby January 20th, 2010 @ 06:26 PM

    • Milestone cleared.
    • State changed from “resolved” to “open”

    I'm still seeing this with the latest 3.0pre...

  • Prem Sichanugrist (sikachu)

    Prem Sichanugrist (sikachu) January 20th, 2010 @ 06:44 PM

    • State changed from “open” to “wontfix”

    options for the generator in rails 3.0pre is required to be appended after application name. So it should be

    $ruby $RAILS/railties/bin/rails depot --database=mysql
    
  • Prem Sichanugrist (sikachu)

    Prem Sichanugrist (sikachu) January 20th, 2010 @ 06:45 PM

    • State changed from “wontfix” to “invalid”

    I wish I could get it right this time ...

  • guns

    guns January 24th, 2010 @ 02:16 AM

    options for the generator in rails 3.0pre is required to be appended after application name.

    I'd like to point out that this is counterintuitive to longtime shell users. I know that Thor is being used as a replacement for OptionParser, but I feel unhappy that it doesn't support OptionParser's flexibility.

  • Ryan Bigg

    Ryan Bigg April 13th, 2010 @ 03:22 AM

    • State changed from “invalid” to “open”

    This has stung me a couple of times too, but there are other programs out there that accept command lines in a specific order. It should be sensible that the operator of the rails command comes after the name, followed by the options to apply to it. See commands like:

    git reset --hard <commit>
    

    are not

    git <commit> --hard reset
    

    for a reason. It is conventional to have them in a certain way, and Rails IS "convention over configuration".

    Perhaps the error message should be more intuitive though.

  • Prem Sichanugrist (sikachu)

    Prem Sichanugrist (sikachu) April 13th, 2010 @ 04:44 AM

    As I stated, this is actually a bug of Thor. We need to look at how Thor parse those arguments, and patch it instead.

    I feel a bit awkward too, having to specify the argument after application name. How can people send patch to Thor then? Github?

  • Yehuda Katz (wycats)

    Yehuda Katz (wycats) April 13th, 2010 @ 05:15 AM

    • Assigned user set to “José Valim”
  • Yehuda Katz (wycats)

    Yehuda Katz (wycats) April 13th, 2010 @ 05:18 AM

    • State changed from “open” to “invalid”

    This should be taken up with Thor. Let's see what we can do :)

  • guns

    guns April 13th, 2010 @ 05:36 AM

    As I stated, this is actually a bug of Thor

    Well, having used rails 3 for a few months now, I take back my whining from earlier. I actually stepped through the Thor initialization back in January to patch it, but I realized it was unnecessary, as Thor is more a Rake replacement than an OptionParser replacement.

    The only confusion is that years of rails tutorials have ingrained in people to create an app with rails -d mydb myapp (even though the inverse would have worked just fine)

    Perhaps the error message should be more intuitive though.

    I think a deprecation message for rails would be just fine, esp. if Yehuda or José don't really want to muck up Thor's options processing

  • José Valim

    José Valim April 13th, 2010 @ 08:03 AM

    This is not going to be fixed. Rails 3 scaffold and generators are incredibly flexible, you can hook in template engine, ORM and test framework and it will pull all the --options available in the hooks.

    This means if you have a Datamapper ORM, all the options available to generate your ORM model are pulled in and available in scaffold.

    The downside of this solution is that you have less flexibility when invoking it through the command line. You need to put arguments first and just then the --switches.

  • Sam Ruby

    Sam Ruby April 13th, 2010 @ 10:38 AM

    José: I may be misreading guns' comment, but I see him as suggesting that usage of options before the app name be deprecated -- in Rails 2.3.6.

  • José Valim

    José Valim April 13th, 2010 @ 10:41 AM

    • State changed from “invalid” to “open”
    • Milestone set to 2.3.6

    That sounds good. What needs to be changed? Where Rails 2.3.6 is telling people to do the wrong way?

  • guns

    guns April 14th, 2010 @ 04:33 AM

    This is alot of chatter from me for a misunderstanding, but...

    I meant that rails v3.0 should still fail, but with a deprecation message when a user tries to create a new application with options preceding arguments. Unless I'm mistaken, the rails 2.3 branch will not adopt Thor, so there is no need to warn users that may have no plans to upgrade to v3.0.

    I think this would avoid producing large amounts of confused users when rails 3 is officially released.

  • Prem Sichanugrist (sikachu)

    Prem Sichanugrist (sikachu) April 15th, 2010 @ 07:11 AM

    • Milestone cleared.

    Ok, I think to 'warn' the user for that would make sense. Can somebody provide the patch for it?

  • Ravinder Rana

    Ravinder Rana April 15th, 2010 @ 08:00 PM

    Attached is the patch to show message if options are given before application name.

    Unfortunately, i'm not able to get the test working for this fix. Tried for an hour but not could not figure out what's wrong with the following test:

    def test_options_before_application_name_raises_an_error
        content = capture(:stderr){ run_generator(["--skip-activerecord", destination_root]) }
        assert_equal "Options should be given after the application name. For details run: rails --help\n", content
      end
    

    Can someone help to figure out the issue?

  • Ravinder Rana

    Ravinder Rana April 16th, 2010 @ 12:40 PM

    Ignore the previous patch. Attached is the patch with test.

  • Ryan Bigg

    Ryan Bigg April 27th, 2010 @ 09:48 AM

    This patch (even though with the wrong extension) applies cleanly and tests pass.

    +1

  • Repository

    Repository April 29th, 2010 @ 12:44 PM

    • State changed from “open” to “resolved”

    (from [e9a9ef094e84abfe6a0167e9255abcf5b63412d9]) warn user if options are given before application name [#3435 state:resolved]

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/e9a9ef094e84abfe6a0167e9255abc...

  • Jeremy Kemper

    Jeremy Kemper October 15th, 2010 @ 11:01 PM

    • Milestone set to 3.0.2
    • Importance changed from “” to “Medium”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages