0

I am trying to use RubyMine as much as possible and RubyMine sometimes to ask for gems which i'll not utilize for anything on myself (RubyMine does).

Is it possible to detect in Gemfile, that i am bundling from RubyMine? or in general: Is it possible to detect the tool i am bundling from (Terminal, iTerm, RubyMine, TeamCity)?

I know there is specificable platform of ruby as condition for gem. What i am looking for to put into my Gemfile is something like this:

tool :rubymine do
  gem 'minitest-reporters'
  gem 'ruby-debug'
end

In result when i'll run bundling from FOR EXAMPLE RubyMine, i'll get minitest-reporters and ruby-debug installed, BUT my colleague who does bundle from Terminal will NOT get these gems installed.

Mailo Světel
  • 24,002
  • 5
  • 30
  • 40
  • Sorry, I don't understand your question at all. What exactly do you want to achieve? – phoet Jan 07 '14 at 13:42
  • The question is very hard to understand. May be you may want to learn a little bit more Ruby before using an IDE that completely automates everything and makes it even more harder for you to understand what it is doing? Moreover, keep in mind that you write the Gemfile, not RubyMine. So you should know what gems you are using. – Simone Carletti Jan 07 '14 at 14:03
  • phoet: simone: I wan't to achieve to have the gems installed only if they are needed. In other words, colleague who does not use RubyMine will not install the gems, since he has no use for them – Mailo Světel Jan 07 '14 at 14:33
  • simone: I know i am writing Gemfile. RubyMine was just example. There are also another examples in my question ;) – Mailo Světel Jan 07 '14 at 14:34
  • I've add extended description of my expectations to question, hope it'll help all to understand my question – Mailo Světel Jan 07 '14 at 14:40
  • Hack! OS X: `puts "running from " + \`vmmap #{Process.ppid}\`.match(/Virtual Memory Map of process \d+ \((.+)\)/)[1]` (under Linux you can look at `/proc/#{ppid}/cmdline` instead of `vmmap`. – John Ledbetter Jan 07 '14 at 20:17

2 Answers2

2

In general the answer to this is to install the extra gems with gem install instead of putting them in the Gemfile.

If RubyMine is relying on Bundler to be able to find those gems at runtime, I'd say that's a bug.

regularfry
  • 3,248
  • 2
  • 21
  • 27
0

OK, here I found some ways to tell, that you are running from inside of RubyMine

(puts this into your Gemfile to test it)

puts [
        ORIGINAL_ENV['OLDPWD'],
        ORIGINAL_ENV['RM_INFO'],
        ORIGINAL_ENV['RUBYLIB'],
        ORIGINAL_ENV['RUBYMINE_TESTUNIT_REPORTER'],
        ORIGINAL_ENV['TEAMCITY_RAKE_RUNNER_MODE'],
        ORIGINAL_ENV['TEAMCITY_RAKE_RUNNER_USED_FRAMEWORKS'],
        ORIGINAL_ENV['XPC_SERVICE_NAME']
]

So for example this way I am able to install gems for RubyMine, only when it is really needed

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console'
  gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'

  if ORIGINAL_ENV && ORIGINAL_ENV['TEAMCITY_RAKE_RUNNER_MODE']
    gem 'debase'
  end
end

Only bad thing is, that this will be changing Gemfile.lock

Mailo Světel
  • 24,002
  • 5
  • 30
  • 40