title: can't find gem rspec-core (>= 0.a) (Gem::GemNotFoundException) when running on Jenkins
body: <p>I am trying to run ruby spec tests in a Jenkinsfile.<br>
  However I have run into problems when executing this code:  </p>
  
  <pre><code>sh 'rspec spec/unit/test_spec.rb'
  </code></pre>
  
  <p>This is the error: <br></p>
  
  <blockquote>
    <p>/home/user/.rvm/rubies/ruby-2.4.0/lib/ruby/site_ruby/2.4.0/rubygems.rb:271:in
    'find_spec_for_exe': can't find gem rake (>= 0.a)
    (Gem::GemNotFoundException)   from
    /home/user/.rvm/rubies/ruby-2.4.0/lib/ruby/site_ruby/2.4.0/rubygems.rb:299:in
    'activate_bin_path'   from
    /home/user/.rvm/gems/ruby-2.4.0@global/bin/rake:23:in ''    from
    /home/user/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in eval'
      from /home/user/.rvm/gems/ruby-2.4.0/bin/ruby_executable_hooks:15:in
    ''</p>
  </blockquote>
  
  <p>I am running Jenkins on an EC2 instance. The gem rspec-core is definitely installed, as I do a bundle install before running the spec test. I have also run the exact same test as the one on the instance itself instead of Jenkins and it works.
  When I run <code>gem which rspec</code> on Jenkins, it gives me this error: <br></p>
  
  <blockquote>
    <p>ERROR:  Can't find ruby library file or shared library rspec</p>
  </blockquote>
  
  <p>But when I run it on the instance, it returns<br>
  <code>/home/user/.rvm/gems/ruby-2.4.0@global/gems/rspec-3.6.0/lib/rspec.rb</code></p>
  
  <p>Both are using the global gemset.
  What could be the problem?</p>