Running Rails within RubyMine fails with "Could not find a JavaScript runtime"
Hello forum,
New to RubyMine and to ruby in general. Trying to run a Rails application within RubyMine in order to use debugging for that one. The app runs fine outside of RubyMine but when I make an attempt to run it within, following the RM guide [1], I get:
/bin/bash --login -c "env RBENV_VERSION=2.7.3 /home/user/.rbenv/libexec/rbenv exec rails server"
Traceback (most recent call last):
91: from bin/rails:3:in `<main>'
90: from bin/rails:3:in `load'
<... log traceback skipped ...>
2: from /home/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/execjs-2.7.0/lib/execjs.rb:4:in `<main>'
1: from /home/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
/home/user/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/execjs-2.7.0/lib/execjs/runtimes.rb:58:in `autodetect': Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
I have nodejs installed and available in PATH:
$ node -v && npm -v && yarn -v
v16.13.0
7.24.2
1.22.17
I have installed the execjs gem but that did not seem to help.
OS: Ubuntu 21.10 64bit
RubyMine 2021.2.3
Build #RM-212.5457.52, built on October 14, 2021
Licensed to Yassen Damyanov
Subscription is active until December 18, 2021.
Runtime version: 11.0.12+7-b1504.40 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.13.0-22-generic
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 16
Non-Bundled Plugins: name.kropp.intellij.makefile (212.5457.62)
Current Desktop: Budgie:GNOME
Ruby v 2.7.3 (required by the Rails app); installed via rbenv:
$ ruby -v && gem -v && bundle -v
ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [x86_64-linux]
3.1.6
Bundler version 2.1.4
Would much appreciate any help,
Thank you!
-Yassen
[1] https://www.jetbrains.com/help/ruby/running-applications.html#run_without_config
Please sign in to leave a comment.
Hello,
Could you please check how it goes if you start RubyMine from the Terminal and repeat your steps?
Olga, thanks so much! Yes, running RubyMine from the terminal helped -- now the rails server runs and the debugger works as well (although, I got a new request to confirm installing debugging gems, in spite of having already done that initially.)
I see it obviously a matter of having the environment set up the way it is when I work in the terminal and have ~.bashrc sourced upon terminal session start.
Yes, we have a corresponding request on the tracker with possible workarounds:
https://youtrack.jetbrains.com/issue/IDEABKL-7589
As for debugger gems, do you always get such a dialog (to install gems)?
Thanks Olga, the workarounds pointed would help indeed.
No, got it once when tried debugging for the first time while starting RM from application menu; then once only when tried debugging after launching RM from terminal.
Not sure where the gems are kept (I'm new to ruby) but it seems when running the IDE from a terminal, a different location is considered and the initially installed copies are not found.
Can you give me a hint here (about where the gems are kept)?
Thank you!
You can check the gem path listed in 'gem env' output for the SDK in question. Does it contain the installed gems?
Thanks, Olga -- got it -- different projects I work on use different ruby versions (installed via rbenv), each with its own environment, including gem catalogs. For each of these, if a debug session opens, the `ruby-debug-ide` gem needs to be installed once (with its dependencies).
Happy holidays!
Oh, yes, if there're different Ruby versions then you need to install debug gems for each of them.
Happy holidays to you too!