pryforemanruby-on-rails-7

binding.pry not works with command bin/dev


binding.pry not works(console input not available) if i start the server with bin/dev command. It only works with bin/rails s command. I understand it has something to do with foreman and Procfile.dev, but I don't know how. Is this a bug or is it supposed to be like this?


Solution

  • With bin/dev, the Procfile.dev file is run with foreman. The pry issue is caused by the CSS and JS watchers:these just listen to changes in your CSS and JS files.

    What you can do is remove the web: unset PORT && bin/rails server command from your Procfile, so it will only have the CSS and JS watchers and look like this:

    js: yarn build --watch
    css: yarn build:css --watch
    

    Now you'll have to open two terminals, one with bin/rails s and the other with foreman start -f Procfile.dev. This way your pry works in the server terminal as normal and the watchers are watching as normal.