-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Having both rails and rake commands is confusing: Just use rails as the command router. #18878
Comments
I have to say thanks for this. Routing all rake tasks through the rails command really keeps things clean. Can't wait until this is implemented. Any chance of backporting to 3.2 4.1 4.2? I'm sure tons of people would love this. |
@teknull we don't backport any new feature, sorry. |
@rafaelfranca I figured that was the case, but one can dream. Some of us still have 3.2 apps floating out there. :) |
Yeah. I'm in the same boat 😢 |
How about also fixing environment setting for rails command? |
Shouldn't be better to only use |
rake has a variety of issues around parameter parsing that we want to get around to increase the comfort of the CLI. And besides the app generator, we have a bunch of other generators. So filing everything under rails and delegating to rake where we can makes the most sense to me.
|
Is it possible to fix the rake parameter handling? |
Exactly because rake is so embedded in everything, I think it makes change hard. But if someone wants to explore that, that's fine. I think we're still going to route it through the Rails command, since having servers like "rails server" and "rails console" as rake commands doesn't make much sense to me. But it would mean we'd have to do less hacking to get there. |
I second this. Rake parameter parsing is broken and nobody seems interested in looking at a fix over there. As a hole it makes more sense to have the rails command route everything and avoids confusion. I don't think there needs to be a match to the other systems out there, we all know of rake but when we're dealing with rails applications we're in the rails world. A lot of the time I find myself writing rake tasks that access parts of rails anyway so make more sense to tie them in to me. |
I don't like the idea about creating too many parallel worlds... if rails is going to use anyway rake (which is a very reasonable decision, because it is the most mature ruby based task manager) I think it would be better to reduce complexity and only use it. Reading the comments, I think that the overall impression is that rake would be better but rake has an unsolved problem. So, in my view, this should be reduced to estimating the cost of solving that problem vs the complexity of having two worlds. I know my point is very lazy because I'm not going to implement it and I also talk with a lot of ignorance, but this is how I see things from the outside. |
Marc, we’re going to have parallel worlds regardless. “rails server” and “rails console”, to take just two, will never be rake tasks. Rake is an implementation detail for interacting with the Rails framework.
|
What's wrong with "rake console"? |
|
I would love that to be able to work. :) |
I see... I guess there is not beautiful way to implement "magic" rake commands like |
Ship has sailed. This is the path we’re moving forward with now. Let’s move on to the next bikeshed. There are so many left to discuss :)
|
👍 🚲 |
But now I can't write rake tasks that use those tasks as dependencies. 😦 |
Sure you can. We are keeping the tasks that makes sense as rake tasks so you can depend on them. We just allow you to call those through the rails command.
|
@dhh Oh, that's a lot less heart attack inducing. Thank you. |
It would be pretty easy to change the behavior here to call the task instead of giving a message #7891 |
This task is open to anyone who wants to explore it again. |
I'd be glad to take a look. |
@schneems Yes, it would be easy to change the Then I tried something like this and the runtime was a little better, but it seems wrong to load the environment to validate the tasks. require APP_PATH
Rails.application.load_tasks
system("bin/rake #{command}") if Rake::Task.task_defined?(command) Suggestions? |
Currently when you accidentally run `$ bin/rails db:migrate` you got an error message: ``` Error: Command 'db:migrate' not recognized Did you mean: `$ rake db:migrate` ? ``` After this change you'll still get an error message, but it will also run the command: ``` $ be rails routes Error: Command 'routes' not a valid rails command Running: `$ bin/rake routes` instead Prefix Verb URI Pattern Controller#Action teaspoon /jstest Teaspoon::Engine users_sign_in GET /users/sign_in(.:format) redirect(301, /users/auth/github) users_sign_up GET /users/sign_up(.:format) redirect(301, /users/auth/github) new_user_session GET /users/sign_in(.:format) devise/sessions#new user_session POST /users/sign_in(.:format) devise/sessions#create # ... ``` I highly recommend that we keep the warning message. Without it running `$ rails --help` won't show all available commands and `rails db:migrate` would be a touch too magical for my tastes. If we want to switch over documentation so that some commands such as `rails test` work out of the box, we should whitelist them. The alternative would be we add the `$ rake -T` output to `$ rails --help` and that would get pretty messy. Thanks to @repinel for the tip on speeding up the rake check
Here's a potential implementation #21012 |
I think that's a clever quick hack, but the goal here is that the user Also, calling out to system sounds like it might be way slow. But maybe On Wed, Jul 29, 2015 at 6:10 PM, Richard Schneeman <notifications@github.com
|
It's not all that slow on my machine, though I didn't do any kind of benchmarks. It's definitely faster than waiting on the whole command to fail and then manually re-typing in your rake command. I've got spring perma disabled in my The biggest concern about moving in the direction of all bin/rails all the time for me is documentation and behavior. For documenting these commands we could either dump them all to the
But that gets a bit messy, or we could do something like heroku where we have named categories so we could list off The second issue I see is that we're hiding rake functionality. When a rake task fails, I often will re-run it with |
I like "rails db --help" for section lists, but I don't think we need to be I like --verbose and --trace both. Should work both for commands we On Wed, Jul 29, 2015 at 8:37 PM, Richard Schneeman <notifications@github.com
|
@schneems Are you still working on this? If not, I can give it a shot. |
Feel free to take a shot. |
I've implemented a potential solution. I chose the whitelisting approach, as it seemed undesirable to have Rails be a mediator for all rake tasks (even custom ones that may not rely on Rails at all). If it's a requirement to have the |
Fixed @ #22288 🎉 |
Some commands live under
rails
others underrake
and to the user it's not clear that there's a rhythm nor rime. Let's route all the rake commands through the rails command. It's still helpful and useful to use rake tasks such that we can allow others to declare task dependencies and such, but there's no reason it has to be exposed through rake on the CLI.So after this, it should be
rails test
andrails db:setup
.The text was updated successfully, but these errors were encountered: