Rubymine Not Locating Gems Specified by BUNDLE_PATH

ⅰ亾dé卋堺 提交于 2019-12-20 12:34:30

问题


I am using RubyMine IDE with RVM for Ruby version management and

bundler install --path vendor/bundle

to keep my gems local. However, RubyMine doesn't seem to be reading my .bundle/config file which specifies where my gems are located with the BUNDLE_PATH property:

BUNDLE_PATH: vendor/bundle
BUNDLE_DISABLE_SHARED_GEMS: '1'

I have found some sources which indicate that RubyMine should support this, but can't seem to find any explanation of exactly how it works or how to fix it properly.

This thread seems to indicate that RubyMine should pick up the bundler/config

"if you configured bundler to install gems in vendor/bundle by-default then RM is supposed to handle this (and if it is not then this is a bug)." http://devnet.jetbrains.com/thread/441239

Here's a few more RubyMine bugs indicating it is not working:

  • http://youtrack.jetbrains.com/issue/RUBY-9898
  • http://youtrack.jetbrains.com/issue/RUBY-12913
  • http://youtrack.jetbrains.com/issue/RUBY-13988
  • http://youtrack.jetbrains.com/issue/RUBY-12340
  • http://youtrack.jetbrains.com/issue/RUBY-12444
  • http://youtrack.jetbrains.com/issue/RUBY-14542 - I created this one to get their attention since most of the others were closed or have gone cold.

I also saw a stackoverflow thread, Using RVM Gemsets & Bundler & RubyMine, where someone complained about the same problem, but the solution was simply to install the gems under the RVM managed path by doing the following:

bundle install --system

Well, this defeats the purpose of keeping your gems isolated between projects. I know there are gemsets for this, but I much prefer not to use them.

The error I am seeing is the following when I try to run my project from RubyMine:

Error running Development: [No Rails found in SDK]

The other symptom is that my gems installed under vendor/bundle aren't visible under the "External Libraries" in the project view, only my Ruby SDK and bundler are installed here.

Also, this works and starts my server find from the command line: bundle exec rails server

But even when I try to run my server with "Run the script in the context of the bundle (bundle exec)", it still fails.


回答1:


Actually running ruby mine from console through bundle helps!

$ bundle exec rubymine

Good luck!




回答2:


Checkout the workarounds posted here:

http://ruby-on-rails.wikidot.com/rubyminelocalbundlepathbug

Workaround #1:

Use a global bundler configuration. Make sure to remove your local bundler configuration too or this won't work.

bundle config --delete path
bundle config --global path vendor/bundle

Workaround #2:

Override the GEM_HOME when starting RubyMine

GEM_PATH="/home/user/project/vendor/bundle/gems/" rubymine



回答3:


As discussed in RUBY-16428, I have written a ruby script which adds the correct gem dependencies as a Rubymine library. Note, this uses features of Rubymine which aren't exposed in the RubyMine UI, based on my workaround using Intellij Idea I described in RUBY-16428.

If you have problems, please feel free to comment on the gist, and I will do my best to help.

https://gist.github.com/robd/ebd2570cc8c50bcda072




回答4:


I got the dreaded "Error running Development: [No Rails found in SDK]" error when I had installed my Gems via bundle install --path vendor/bundle. It seems like the --path vendor/bundle confused RubyMine in some way.

Run bundle install without --path vendor/bundle. Note: if you already ran bundler once with --path vendor/bundle, you should either clone a fresh copy of the repo or clean out anything installed by Bundler, like so:

rm -rf .bundle
rm -rf vendor/bundle
bundle install



回答5:


Try to remove the ruby's version (2.3.1 in my case)

rvm remove 2.3.1

Remove the .idea from your project(s)

Install this libraries (one of them resolved to me, I don't know which)

brew install v8 apple-gcc42 gcc49 ruby-build

Reinstall the ruby

rvm install 2.3.1

Downgrade the rubygem

rvm rubygems 2.5.1 --force

Enter you project's folder and do:

bundle install


来源:https://stackoverflow.com/questions/19717621/rubymine-not-locating-gems-specified-by-bundle-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!