How do I setup the ruby SDK in IntelliJ IDEA?
Solution 1
I was able to solve this by doing:
Preferences | Plugins | Install JetBrains plugin
Solution 2
I ran into this problem with Intellij IDEA 2020.2. It took a while to resolve because the Intellij documentation seems to be missing one critical piece.
When you first open a project in IDEA, it assumes all your code is part of a Java module. With that module in place you cannot set a Ruby SDK at the module level. There's no option to do because the existing module is configured as Java.
Here's a screenshot of my example project with the default Java module. Notice the icon is a folder with a blue rectangle in the lower, right corner.
Here's what I had to do.
-
Open the Project Structure dialog (File | Project Structure).
-
In the Modules settings, highlight the top-level project module and click the delete button (looks like a minus sign).
-
Click the plus sign to add a new module.
-
From the pop-up click "New Module".
-
In the "New Module" pop-up select Ruby and the correct Module SDK (e.g. rbenv: 2.5.0)
-
When you are prompted to enter the Module name, Content root, and Module file location, make sure the directories are set to your project's root. When I entered the module name it appended the name to the project's root directory which is probably not what you want.
Once you've done that the module should appear with a Ruby icon on it and the rest should work as documented here: https://www.jetbrains.com/help/idea/configuring-language-interpreter.html
Here's a screenshot of my new Ruby module. You can see the Ruby icon replaced the blue rectangle.
I hope this saves you some time!
Solution 3
In order to set Ruby SDK for your project in IDEA you need to go to File | Project Structure | Project Settings and set project and module SDK.
Solution 4
Olivia is correct, the "Project Structure..." (Mac shortcut Cmd+;) is the dialog for configuring the IDE to use different ruby installations.
The first requirement is that the ruby manager (chruby, rbenv, rvm) is configured properly.
Another concern is exactly where and how jetbrains expects the ruby installation to be organized. I wonder if Intellij is compatible with the way ruby-install lays out ruby? That's the one I used with chruby. I could not make it work.
The posted url to Opening Rails projects in IntelliJ IDEA helped me feel the most confidence that we are on the right track. :)
At the time, I was failing to get Intellij configured due to fact the gem files were not seen by the IDE. All but about 4 gems in my project's Gemfile was being highlighted as having an SDK problem.
To end this, I stopped using chruby and ruby-install. I am not blaming chruby, however I could not make the chruby system work properly with the IDE. It worked fine in the shell. Note, I am a previous user of rvm and rbenv. Switching back to rbenv, now. Note that I've also stopped using ruby-build directly.
Instead, I built the first ruby version directly from rbenv:
rbenv install 2.3.1
Next, I created the .ruby-version file in the root of my rails project directory by running:
rbenv local 2.3.1
To help with any confusion regarding the minimum support needed in the shell startup scripts. Do not alter PATH at all. Place the following in your shell startup script system, whatever that may be:
# rbenv config in my .bash_profile
# --------------------------------
if which rbenv > /dev/null; then
eval "$(rbenv init -)";
fi
With the prerequisites out of the way...
I recommend doing the project import in the same way described in the jetbrains tutorial Opening Rails projects in IntelliJ IDEA.
In the first screenshot from thesowismine, I see two dialogs for different purposes that are simultaneously open. Unless I am mistaken, one of those dialogs should have received its info and closed before going forward, at least during the wizard-like process. Perhaps this was done and that dialog was reloaded later?
In any event, that is not where the Ruby SDK is associated to a Rails project. The screenshot indicates the User is browsing around the brew Cellar, which may indicate two things.
- Ruby was installed with a
brew install <version>
command; I installed ruby by calling the rbenv ecosystem. - That particular dialog is for informing the IDE about the Rails project folder, not the Ruby kit.
Assuming the first dialog is provided with the root directory of the Rails app and next is clicked; then in the second dialog, I change nothing and click next. The 3rd dialog is where I confirm the project directory is correct and I can assign a more elaborate name (which is displayed in the IDE's project menu). Clicking next may prompt you to write over the ".idea/" directory. Say yes. The next dialog confirms that sources were found. Click next. Now Frameworks begin to be detected assuming the Ruby Manager is setup correctly. Click Finish.
Now, goto the "Project Structure..." dialog to set the SDK.
Before or after setting the SDK, go to the the project directory of your Rails project, run:
gem install bundle
bundle install
This will install all the gems your project requires including the rails gem, as presumably it is listed in your Gemfile.
Note that gemsets do not come up, here. In this config, the set of gems are associated to a particular Ruby installation. Bundler is your friend.
Solution 5
Languages & Frameworks > Ruby SDK and Gems

thesowismine
Updated on July 23, 2022Comments
-
thesowismine 10 months
I've been using this guide
Whenever I go to import the module I get this screen:
I used the following file path, maybe this is whats wrong?
/usr/local/Cellar/ruby-build/20160130/share/ruby-build/2.3.0
And got this error:
I'd appreciate any ideas anyone might have, i've been trying get this working all night!
-
Jon over 7 yearsTry installing Rvm. Works seamlessly for me with IntelliJ
-
thesowismine over 7 years@Jon i used rbenv instead, I followed this guide for installing setting up rails and would rather not stray from it at this point if possible
-
Jon over 7 yearsI'm pretty certain the example screenshots in the jetbrains guide you're following also show Rvm being used.
-
thesowismine over 7 years@Jon whoops, sorry, i forgot to link the guide I was talking about, which has nothing to do with intellij IDEA gorails.com/setup/osx/10.11-el-capitan
-
Jon over 7 yearsAh. I'd still use Rvm if I were you. Installation is trivial and IntelliJ works perfectly with it.
-
-
thesowismine over 7 yearsI don't have that option, just a bunch of other stuff including but not limited to JavaScript, Play Configuration, Grails, OSGI, SQL Dialects, and XSLT
-
Josh Brody over 7 yearsOh, oops; for whatever reason I assumed you're using RubyMine. Might want to give that a whirl; it's baked for Ruby. :)
-
thesowismine over 7 yearsYea I might end up doing that. I really want to get this to work though because I've done it before and would rather use the same IDE for everything if possible.
-
Josh Brody over 7 yearsHave you checked this out? confluence.jetbrains.com/display/RUBYDEV/…
-
thesowismine over 7 yearsYea thats what I was using but it seems to varie a little when you go to import the path
-
ziff about 7 yearsThank you for following up so promptly. Good job out of you! That certainly completes the picture.
-
WebComer over 6 yearsFor me, the mentioned Ruby option is missing in Languages & Frameworks in idea 15. Just cannot add Ruby facet yet Ruby sdk's listed in sdk list. Ruby files just a piece in java project.
-
akostadinov over 1 yearI'm using
asdf-vm
and IntelliJ recognizes it. Just FYI