"Run Anything" Not Detecting Rails



  • macOS Cataline 10.15.1
  • RubyMine 2019.2.4
  • Rbenv to manage Ruby version

Steps Leading Up To Problem:

  • Installed rbenv
  • Installed Ruby version 2.4.1 (wanted an old version)
  • Installed Rails 5.1.3 gem (again, I wanted this version)
  • Performed rbenv rehash
  • Set rbenv global to 2.4.1
  • Configured RubyMine to use rbenv version of Ruby
  • Create new application using RubyMine interface.


  • From the Run Anything prompt, I can run rails server, and it works fine. However, if I run rails version, it tells me that rails is not installed.

My Ideas:

  • If I use rbenv in the RubyMine Terminal to switch to the system version (which doesn't have rails), I also get an error that rails doesn't exist. If I switch the rbenv shell to 2.4.1 in the Terminal, rails is detected. 
  • I have a feeling that the Run Anything prompt is feeding commands to a shell that hasn't read the rbenv environment variables and therefore it's not detecting the rbenv rails shim (command) that is being detected by the Terminal
  • This is confirmed by checking the PATH in the Terminals that work, vs Run Anything's PATH. The Terminal PATHs have .rbenv paths at the start, and Run Anything has the .rbenv paths at the end of its PATH
  • If I run eval "$(rbenv init -)" && env, then I get the correct PATH

How can I get Run Anything to detect the rails gem installed by rbenv?


Update: SOLVED

The issue was in which configuration file for zsh was being loading. Commands run via Run Anything are run via a non-interactive login shell.

Can confirm by running

if [[ -o login ]]; then; print yes; else; print no; fi

if [[ -o interactive ]]; then; print yes; else; print no; fi

in Run Anything.

Zsh loads config files in the follow order (talking about user configs in the home directory):

  1. .zprofile (for login shells) <- rbenv eval moved here
  2. .zshrc (for interactive shells) <- rbenv eval initially here
  3. .zlogin (for login shells)

My rbenv eval (the command while allows the shell to see rails) was in zshrc (thought that this was the right place, ex-bash user). But since Run Anything is a non-interactive shell, that config file was not getting loaded.

Solution: If you are using rbenv to manage your Ruby version, then make sure it is place in .zprofile so that it works in Run Anything.


Don't know what to do with this post, will keep it here if anyone else experiences this problem, mods are free to delete.


Hello Dmitry,

thank you for posting here your investigation and solution, The issue you've described looks similar to the following request https://youtrack.jetbrains.com/issue/IDEABKL-7589


Yes, it's similar, the differences being the macOS vs Linux, and zsh vs bash.

My issue was about the different behaviour between the built-in terminal and the run anything prompt.

The built-in terminal would process the zshrc files, and the run anything prompt wouldn't since it's a non-interactive shell, leading to a difference in expected behaviour.


Please sign in to leave a comment.