Fixed: Rubymine doesn’t show files in “library” directories

If you work on a medium or large-sized Rails project, there’s a good chance that you utilize the vendor/gems or vendor/engines directories to help keep your code organized into modules (as opposed to stuffing hundreds of models, controllers and views into a web of subdirectories in the app folder).

Unfortunately for us, the Powers that Be at Rubymine do not index any of these directories in file or symbol searches under the belief that any file in these directories must be third party library code, and therefore not shown unless one checks the “include non-project files” every time they want to look up their files. Even with this burdensome workaround, one would still find their methods/files listed below any partial matches that may occur in the main project.

The fix is to edit your Rubymine project’s iml file, it’s located at [project dir]/.idea/[project name].iml. You’ll need to find “NewModuleRootManager” and make the following update within it:

<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/engines" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/packaging/vendor" />
<excludeFolder url="file://$MODULE_DIR$/public/assets" />
<excludeFolder url="file://$MODULE_DIR$/tmp" />
</content>
</component>

You’ll then need to close and re-open the project, and voila.

I have repeatedly and unsuccessfully lobbied Jetbrains to at least create an option for users to make their own decision about whether vendor/engines and vendor/gems should be treated as libraries, but they have denied the motion, telling me to file a bug for it. I did so, it lives here: https://youtrack.jetbrains.com/issue/RUBY-18315. If you care about this file, you should login to Youtrack and cast a vote for it. Or leave a comment on this blog.

Leave a Reply

Your email address will not be published. Required fields are marked *