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
Add bin/dev and Procfile.dev to new Rails apps #44658
base: main
Are you sure you want to change the base?
Conversation
`jsbundling-rails`, `cssbundling-rails`, and `tailwindcss-rails` all introduce a new bin/dev and Procfile.dev file to the app when they are installed. This is a good thing as it allows developers to run one command to execute their Rails server and frontend build tools. However, this change in flow is not very obvious to newcomers or even Rails developers with even moderate experience. Up until this point, they've been told to simply run `rails s` and they can start developing their app. It's not clear with the introduction of the bundling gems they need to run this separate command to get everything going unless they dig into the gems' README files. They are then left wondering why none of their Javascript or CSS changes are applying because its not obvious they have to run a separate process. This change introduces `bin/dev` and `Procfile.dev` to Rails proper as first class citizens added on the defualt app install - regardless of `--javascript` or `--css` flags. A `--skip-bin-dev` flag was added to not generate those files. `bin/dev` is identical to the one found in the bundling gems. Their installers will see the identical file and skip it. `Procfile.dev` includes only the "web" process which is also taken from the bundling gems. So why even have `Procfile.dev` if it only has one service in it? If the default workflow of Rails apps going forward uses `bin/dev` to start/stop the dev stack, this can result in a more smoother transition from importmaps/raw css into the bundling gems as developers would already be using `bin/dev`. The gems would append to `Procfile.dev` and no other change would be needed on the developer's part. Also, this allows for other gems such as `sidekiq`, `resque`, `shackapacker`, `goodjob`, etc (which also need their own separate process while working locally) to slide into the Rails flow easily as one would append a new service to `Procfile.dev`.
While I like the idea of matching the same workflow no matter how your app is setup (we do that in shopify using dev and I know GitHub does using binstubs like this one). I don't like that Rails know depends on foreman by default. Here are some reasons:
The last two reason in my opinion make the development experience worse than an occasional error when the asset server is not stated. A better solution in my opinion would add proper error pages for the when the assets server are not started when using one of the other assets gem. |
@rafaelfranca would you be open to standardising on a tool that isn't foreman? I don't have a suggestion in mind right now, but I think the PR makes some good points about how most apps these days will eventually need to run multiple processes for comprehensive development (once you start thinking about job queue etc) and it could be good to try and have a 1-command solution for all apps for this. |
+1 on not being to do |
I'm not sure there's something simple we can standardize on. When I was at GitHub and we realized foreman wasn't maintained we switched to overmind but it has the same complexities as foreman with Pry and other debuggers and it was often a struggle to explain to teams how to use the debugger. I would not want the Rails issues tracker full of "how do I debug with overmind" questions. I think we should document this issue and gave an example of how to fix it. That way someone would be opting into making their own Procfile without putting the burden on us to own it. |
@t27duck Nice work, I've really been enjoying utilizing I think this script should be thought of in a similar way as While the initial I understand the concern around utilizing foreman since it's not actively maintained but then I started looking at what Heroku is utilizing because of their Procfile support. It looks like they're using node-foreman which hasn't been updated since 2018, very few open issues and PRs I'll add though. They then go on to suggest utilizing the foreman ruby gem as an unofficial route. What is a good Procfile manager alternative for local development? Fork the foreman gem and start working through some of those issues? What's everyone else using? Spurlunking through logs can be fixed in the same way that you'd run |
Summary
jsbundling-rails
,cssbundling-rails
, andtailwindcss-rails
all introduce a new bin/dev and Procfile.dev file to the app when they are installed. This is a good thing as it allows developers to run one command to execute their Rails server and frontend build tools.However, this change in flow is not very obvious to newcomers or even Rails developers with even moderate experience. Up until this point, they've been told to simply run
rails s
and they can start developing their app. It's not clear with the introduction of the bundling gems they need to run this separate command to get everything going unless they dig into the gems' README files. They are then left wondering why none of their Javascript or CSS changes are applying because its not obvious they have to run a separate process.This change introduces
bin/dev
andProcfile.dev
to Rails proper as first class citizens added on the defualt app install - regardless of--javascript
or--css
flags. A--skip-bin-dev
flag was added to not generate those files.bin/dev
is identical to the one found in the bundling gems. Their installers will see the identical file and skip it.Procfile.dev
includes only the "web" process which is also taken from the bundling gems.So why even have
Procfile.dev
if it only has one service in it? If the default workflow of Rails apps going forward usesbin/dev
to start/stop the dev stack, this can result in a more smoother transition from importmaps/raw css into the bundling gems as developers would already be usingbin/dev
. The gems would append toProcfile.dev
and no other change would be needed on the developer's part. Also, this allows for other gems such assidekiq
,resque
,shackapacker
,goodjob
, etc (which also need their own separate process while working locally) to slide into the Rails flow easily as one would append a new service toProcfile.dev
.Other Information
Added a changelog entry and did my best to modify some existing guides.