How do I run a Rails7 app including the js and css watchers in Rubymine ?

I've set up a skeleton Rails 7 app using `esbuild` and `bootstrap` via

rails new mojoknows7 -j esbuild -css bootstrap

I used ruby 3.1.0 and after a bit of wrangling I got the app to work. It is supposed to be run in terminal via

bin/dev

which in turn runs

#!/usr/bin/env bash

if ! command -v foreman &> /dev/null
then
echo "Installing foreman..."
gem install foreman
fi

foreman start -f Procfile.dev

which then runs the following components (web, js, css):

web: bin/rails server -p 3000
js: yarn build --watch
css: yarn build:css --watch

From what I can tell, when I run the Rails server from within Rubymine, it only does the web part - how can I control all 3 components from within rubymine, so that when I start the 'server' all 3 are started and when I stop it all 3 are stopped?

 

 

9 comments
Comment actions Permalink

Hello Patrick,

You can create a corresponding Run configuration to run Foreman (https://www.jetbrains.com/help/ruby/debug-foreman.html#create_config), will it cover your needs?

0
Comment actions Permalink

Thank you Olga - I tried that but I got "Gem executable not found" - could that be because I am using rvm ?

I got it working using just a "Shell Script" configuration and running bin/dev directly that way.

0
Comment actions Permalink

Patrick, could you please try specifying the arguments (like `start`) in the corresponding field below the one with the executable name. How does it go?

0
Comment actions Permalink

You can just create new shell script and point executable to your `~/your-rails-project/bin/dev` script. That works as is intended by the rails team, since `./bin/dev` executable is a shell script, not a Gem command. I attached a screenshot.

1
Comment actions Permalink

Thank you all - got it working as a script now !

1
Comment actions Permalink

I have some problems configuring this shell script in Windows with the repo source in WSL 2.
I can't find a valid "interpreter path" to use, and the "script path" must be absolute unfortunately so that means that I have to use the full path to the WSL filesystem which doesn't seem to work...

0
Comment actions Permalink

Well, I solved with a "Gem command" configuration like in this guide: https://www.jetbrains.com/help/ruby/debug-foreman.html

I had to put foreman in the Gemfile though:

group :development do
...
gem 'foreman', require: false
end

This is the configuration:

1
Comment actions Permalink

I got the shell script to work but the debugger doesn't seem to attach. How do I get this to work and enable debugging?

0
Comment actions Permalink

Jdstanhope, it'd be great if you could submit a report on our tracker https://youtrack.jetbrains.com/issues/RUBY specifying your steps and providing if possible a project sample for reproduce. 

0

Please sign in to leave a comment.