Running Rspec Tests within RubyMine fails with "Could not find a JavaScript runtime"

I've been using RubyMine for a while but just ran into this error recently after having to re-install Homebrew and re-clone a repo. When I try to run rspec tests from the IDE, I get the error below every time:

/Users/mayaebsworth/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.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 can run the same tests from my mac terminal using:

bundle exec rspec <filename>
I think the issue is related to node/nvm and possibly the way my PATH, environment variables, and/or .zshrc file are integrated with my RubyMine, but I'm not sure how to fix it.
 
I checked in Preferences > Languages & Frameworks > Node.js and NPM. The "Node interpreter" was set to "node - no executable found in $PATH", and I changed it to another option in the dropdown "~/.nvm/versions/node/v16.13.1/bin/node". I also changed the "Package manager" from "npm" to "yarn". But neither of those things worked.
 
I restarted RubyMine, tried `spring stop`, tried installing node and nvm and yarn from inside the RubyMine terminal, but nothing's worked yet.
 
Any help would be appreciated! Happy to answer more questions.
3 comments
Comment actions Permalink

Hello Maya,

That appears to be related to the known problem, could you please check the corresponding issue and proposed workarounds:

https://youtrack.jetbrains.com/issue/IDEABKL-7589/Load-interactive-shell-environment-variables-on-Linux

0
Comment actions Permalink

Hi Olga, thank you for your response! I tried the workarounds but they didn't work for me. I'll include some more detail here in case I'm not doing them correctly.

My environment variables are defined in ~/.zshrc.

Workaround 1: make required variables available in a login shell (i.e. for Bash, move them from .bashrc to .bash_profile or .profile), then restart X session (logout/login).

I created a ~/.profile file and then pasted everything in my ~/.zshrc into that file. Then I restarted RubyMine and tried to run the tests and got the same error as before. Wasn't sure what "restart X session" meant or if I had to do more than copy & paste.

Workaround 2: run IDE from a terminal

I looked up how to do this, and then opened up a new terminal window, ran:

$ source ~/.zshrc
$ open -a "RubyMine.app"

Then tried running tests again, got the same error as before. Wasn't sure if I had to add any more arguments to the open command in order to make the environment variables available.

Workaround 3: edit IDE desktop launcher and set command to /bin/bash -l -i -c "/path/to/webstorm.sh"
 
I wasn't sure how to do this one - I tried looking it up and didn't find a good answer yet. I'm on Max OSX Big Sur.
0
Comment actions Permalink

Got it working! I needed to:

  1. Undo the changes to ~/.profile.
  2. Restart computer
  3. Open new terminal window
  4. Run:
  5. source ~/.zshrc
    nvm use 16
    open -a "RubyMine.app"

Then was able to run tests!

 

Thank you for your help, Olga!

0

Please sign in to leave a comment.