Local Gem not treated as Library Home (Non project-files)
Hi,
We are developing a Rails project with multiple Rails Engines. The Engines are Gems, but they live in the same project.
App tree:
- main_app
-- app
-- engines
--- engine_app
---- app (library home)
---- lib (libary home)
---- Gemfile
-- Gemfile
main_app Gemfile:
gemspec(path: 'engines/engine_app')
engine_app Gemfile:
gemspec
If we want to work on the Engine, all cool RubyMine features like find references, find usages and refactor do not work anymore. These features are used all the time. The local gem is specified as a Library Home and isn't part of the project. But in our case it is a part of the project.
Please sign in to leave a comment.
Hi,
RubyMine doesn't support such project structure very well :( The only think I can suggest to try is to create separate project for engine_app and open it as a second project in main_app.
Hope this helps, Oleg.
Hi Oleg,
The solution didn't work with an 2nd project. But we did have a breakthrough which we would like to share.
When you setup a project with this type of Gemfile:
source 'http://rubygems.org'
gem('engine', path: 'engines/engine_app')
gem('engine2', path: 'engines/engine2_app')
Rubymine (or rubygems) will register the gem engine as a external gem.
engine2_app (0.1)
~/RailsProjects/websend/playground/main_app/engines/engine2_app
bundler (1.3.5)
~/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.5
engine_app (0.1)
~/RailsProjects/websend/playground/main_app/engines/engine_app
When edit your Gemfile and you use this syntax
gemspec(path: 'engines/engine_app')
Rubymine will still see this as a external gem.
If you move your directory to another directory for example main_app2 the gems become local again
The Gem Environment only sees bundler now as external gem
bundler (1.3.5)
~/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.3.5
So the workaround on this subject for now is: Don't use gem 'my-gem-name', path: 'local/path' for local gems.
This is exactly the problem I am having, but this workaround did not work for me. Does this still work in the latest version of RubyMine (7.1.4)?
The following workaround will work in all cases and allows you to use gem 'foo', path: './components/foo' in your gemfile
In components/foo add the file foo.iml with the following contents:
<?xml version="1.0" encoding="UTF-8"?>
Open .idea/modules.xml and add the follwoing
Restart RM, and you should see components/foo as a part of the project.
Once you do this, you will need to open the Ruby SDK and Gems section of preferences and ensure that the foo sub-project is using the right SDK in RubyMine.