Re: [Rails-core] [Proposal] Add additional in-project directory to load custom Rails Command within the app

2020-01-23 Thread jiang jun
That’s really a good feature, if you do that, we can write Rails command instead of Rake task. BTW. {project_root}/lib/commands is a good place, because it has {project_root}/lib/tasks there and do the similar job. From: on behalf of Prem Sichanugrist Reply-To:

Re: [Rails-core] [Proposal] Add additional in-project directory to load custom Rails Command within the app

2020-01-23 Thread Prem Sichanugrist
Yep, as 姜军 said — at the point in time where Rails tries to load all available commands (in boot.rb) the {project_root}/lib directory isn't included in $LOAD_PATH yet. I can confirm that after the app boots, the lib folder is indeed in the $LOAD_PATH. That definitely means lib/commands and

Re: [Rails-core] [Proposal] Add additional in-project directory to load custom Rails Command within the app

2020-01-14 Thread Xavier Noria
Ah, I see now what is the point, commands are able to boot the application (eg, runner), but the lookup happens before. I would not recommend app for that, because by default any subdirectory of app is in the autoload paths and eager loaded if eager loading is enabled. Xavier PS: BTW, Zeitwerk

Re: [Rails-core] [Proposal] Add additional in-project directory to load custom Rails Command within the app

2020-01-14 Thread 姜军
Nope, because code loader (Zeitwerk) isn't setup on Rails commands, it's only load `config/boot.rb` (see https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/app/templates/bin/rails.tt#L2 ), and the `boot.rb` only load gems and Bootsnap (see

Re: [Rails-core] [Proposal] Add additional in-project directory to load custom Rails Command within the app

2020-01-14 Thread Xavier Noria
Hey Prem! The lib directory is indeed in $LOAD_PATH, maybe your app does not have it for some reason? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: [Rails-core] [Proposal] Add additional in-project directory to load custom Rails Command within the app

2020-01-14 Thread Kasper Timm Hansen
Hey Prem, The Rails command infrastructure is still private and I don’t like the current internal API that much. Don’t feel good exposing that. There’s also no way to mark command dependencies yet. Now I did write the initial infrastructure 3-4 years ago for Rails 5.0, so it’s been some time