Idea 15, Ruby and Gems Follow
I'm new to Idea so I may be doing something wrong, but I'm struggling to get the environment set up to run Ruby and RSpec. The problem I face is that I can't add any gems to the project as there is no Gems tab in the Module section of Project Structure.
If I create a project from scratch and set it to be Ruby and a project SDK all is ok. If I go to Project Structure I can see a Gem tab under modules and I can see that RSpec is attached along with a bunch of other Gems. Global Library also contains all the Gems. I can run RSpect tests with no problem.
I created a project from a Git repository which downloaded a bunch of source files. I went to Project Structure and added a Ruby SDK - I can also see that the Global Library is full of Gems. There is no Gem tab under modules. I can add RSpec from Global Library as a Dependency. If I try to run an 'file.spec the configuration says no SDK is available for my project (module) although back in Project Structure it's definitely still added to the project.
I've got myself completely confused now and can't work out how to continue to get this working. I think I could delete the project, create a new one as a Ruby project then attach to GitHub and pull the sources - I expect that would work but it seems like the wrong approach.
Could I ask for some help please
Please sign in to leave a comment.
Please check if you can right-click your project in the Project view, select Add Framework Support and add Ruby.
I've checked and there is no Ruby option (JRuby is there) but there is a shed load of other frameworks to select - none of which I think are relevent.
Please take a look at this tutorial https://confluence.jetbrains.com/display/RUBYDEV/Opening+Rails+projects+in+IntelliJ+IDEA
If this does not help, could you please share a screenshot of your project view?
Thanks, I'll give that a go. It isn't that dissimilar to what I did, except that instead of creating a new project from existing source, I created it from Version Control. The only thing it detected at that stage was a JRuby framework, which I was surprised about as it is essentially a set of HTML files and RSpec files. I did undertake step 3 as far as adding a Ruby SDK to the project but then I came unstuck: there is no Gems tab to interact with on the Modules view.
I presume to follow this exactly, I would need to clone the Git repository down to a new Project directory first?
Yes, lets try it this way.
It looks like the project was somehow determined as Java, that's why you see Jruby suggestion.
Installing from project source - these are the steps and outcomes...
1 - Created local directory
2 - Cloned Git repository and copied down source files (html and RSpec files)
3 - started Idea 15 and selected Import Project from Welcome Screen
a - selected 'create project from existing sources'
At this stage it came up with project name/directory which I accepted and on the next panel flagged the project as Ruby followed by no frameworks detected.
Project was opened in Idea.
4. Selected Project Structure and added Ruby SDK (Global Library)
5. Under Modules, the Gems tab is there with a small selection of Gems (but not RSpec)
- the dialog indicates a problem: invalid item "rake (v10....... in the dependencies list" - I think this might be because a Rakefile exists which points to RSpec 2.0 (one of the changes I need to make to point it at RSpec 3)
- not sure how to add RSpec gem: I can select it (and other RSpect gems) in the Global Library, right click and select "Add to Modules" but nothing seems to happen: certainly, they don't appear in the Modules list.
- Also complaining about BigDecimal v1.2.6 gem already existing..
6 Closed Project Structure dialog; Idea informs me that Ruby Gem Manager has detected some of the gems required for the project are not installed and prompts me to install them.
7 Select to install them, then it prompts me that No Bundler Gem found. Would I like to install bundler and use it to install missing gems.
8 Not sure what the right answer is here: I select yes, it runs, but then I'm prompted again that some of the gems are not installed. This seems to loop around every time I say yes to install them with nothing actually getting installed.
I do have the gems on my system and they are visible in the Global Library.
So, it detected a Ruby project importing this way (which it didn't do when importing directly from Github.)
I'm on OSX. Not sure if i it is relevant but f I run cmd type -a ruby I get
ruby is /Users/Andrew/.rvm/rubies/ruby-2.2.1/bin/ruby
ruby is /usr/bin/ruby
If I run type -a gem I get (amongst other things)
gem is /Users/Andrew/.rvm/rubies/ruby-2.2.1/bin/gem
gem is /usr/bin/gem
If I run type -a rspec I get
rspec is /Users/Andrew/.rvm/gems/ruby-2.2.1/bin/rspec
If I look at the settings for the selected SDK for the Project then
Interpreter Path is: /Users/Andrew/.rvm/rubies/ruby-2.2.1/bin/ruby
Gem bin directory is: /Users/Andrew/.rvm/rubies/ruby-2.2.1/bin
Andrew, thanks for details. could you please please check if:
1. ruby-2.2.1 is listed in the Project Settings | SDKs
2. ruby-2.2.1 is selected in the Project Settings | Project amd Modules.
See attached screenshots. If yes, please make sure that you see bundler and rspec gems in the '''Project Settings | Modules | Gems''' tab. If yes, close settings, run '''Tools | Bundler | Install'''
Let me know how it goes and if you still have any problems.
Screen Shot 2015-11-19 at 20.04.07.png
Screen Shot 2015-11-19 at 19.57.05.png
Screen Shot 2015-11-19 at 19.57.00.png
I can confirm that Ruby 2.2.1 is in the Project SDK and Modules.
Bundler wasn't in the list of Gems, neither was RSpec. Bundler wasn't available in the tools menu. So I installed Bundler from the cmd line and restarted Idea 15 - and installed the announced patches, including one for the Ruby Plugin.
Bundler is now in the list of Gems (RSpec isn't) so I ran Bundler / install from the Tools menu (now available) and that showed me it was installing RSpec and dependencies. Seemed to complete succesfully.
RSpec isn't in the list of Gems though - is it as simple as "Install gems" from the Module dialog? Also, it is reporting a Problem with Rake in the list of dependencies but that seems to come and go (as does Rake in the list of External Libraries.) I've posted some screenshots
Screen Shot 2015-11-19 at 18.03.52.png
Screen Shot 2015-11-19 at 18.03.27.png
Screen Shot 2015-11-19 at 18.03.05.png
Screen Shot 2015-11-19 at 18.02.50.png
Screen Shot 2015-11-19 at 18.02.35.png
Hmmmm....I tried this:
1 - In Global Library, I select RSpec Gem, right click and add to Module. Nothing seemed to happen and there wasn't anything in the list of Gems. However, the whole Project Structure dialog went a bit screwy: I navigated back to the Global Directory but it wouldn't display that page; or the Project SDK page. I quit from the dialog and closed Idea.
2 - Re-opened Idea, it loaded in my project and up-popped the Rspec and associated Gems into my project! Checking the Project Structure, they are listed as Gems against the module. Not sure whether that was a result of adding from Global Directory, restarting or what....seems very strange.
3 - My rspec tests will now run. The Run Configuration no longer complains about there being no rspec gem in the SDK.
So, I guess all is right with the world! But goodness, I'm not sure how.
Project Structure dialog is still complaining about Rake and it stil informs me that I have BigDecimal defined twice if I re-set the SDK.
Thanks for the pointers - clearly Bundle had something to do with it. I'm hoping I can re-do all this on my next project, if I have to!!