Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

--database option broken

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

Reported by Sam Ruby · October 28th, 2009 @ 04:12 AM

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: Medium

Activity

  1. Grzegorz Kazulak
    Grzegorz Kazulak

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

    October 31st, 2009 @ 09:29 PM

  2. Prem Sichanugrist (sikachu)
    Prem Sichanugrist (sikachu)
    • State changed from new to resolved

    January 20th, 2010 @ 05:30 PM

  3. Sam Ruby
    Sam Ruby
    • Milestone cleared.
    • State changed from resolved to open

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

    January 20th, 2010 @ 06:26 PM

  4. Prem Sichanugrist (sikachu)
    Prem Sichanugrist (sikachu)
    • 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
    

    January 20th, 2010 @ 06:44 PM

  5. Prem Sichanugrist (sikachu)
    Prem Sichanugrist (sikachu)
    • State changed from wontfix to invalid

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

    January 20th, 2010 @ 06:45 PM

  6. guns
    guns

    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.

    January 24th, 2010 @ 02:16 AM

  7. Ryan Bigg
    Ryan Bigg
    • 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.

    April 13th, 2010 @ 03:22 AM

  8. Prem Sichanugrist (sikachu)
    Prem Sichanugrist (sikachu)

    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?

    April 13th, 2010 @ 04:44 AM

  9. Yehuda Katz (wycats)
    Yehuda Katz (wycats)
    • Assigned user set to José Valim

    April 13th, 2010 @ 05:15 AM

  10. Yehuda Katz (wycats)
    Yehuda Katz (wycats)
    • State changed from open to invalid

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

    April 13th, 2010 @ 05:18 AM

  11. guns
    guns

    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

    April 13th, 2010 @ 05:36 AM

  12. José Valim
    José Valim

    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.

    April 13th, 2010 @ 08:03 AM

  13. Sam Ruby
    Sam Ruby

    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.

    April 13th, 2010 @ 10:38 AM

  14. José Valim
    José Valim
    • 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?

    April 13th, 2010 @ 10:41 AM

  15. guns
    guns

    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.

    April 14th, 2010 @ 04:33 AM

  16. Prem Sichanugrist (sikachu)
    Prem Sichanugrist (sikachu)
    • Milestone cleared.

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

    April 15th, 2010 @ 07:11 AM

  17. Ravinder Rana
    Ravinder Rana

    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?

    April 15th, 2010 @ 08:00 PM

  18. Ravinder Rana
    Ravinder Rana

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

    April 16th, 2010 @ 12:40 PM

  19. Ryan Bigg
    Ryan Bigg

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

    +1

    April 27th, 2010 @ 09:48 AM

  20. Repository
    Repository
    • 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...

    April 29th, 2010 @ 12:44 PM

  21. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Medium

    October 15th, 2010 @ 11:01 PM