Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-32627

RVM does not work when Jenkins is started from command line

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Component/s: rvm-plugin
    • Labels:
      None
    • Environment:
      OSX 10.11.2; Jenkins 1.625.2; RVM plugin 0.4
    • Similar Issues:

      Description

      In my setup, I have several ruby installations, but I only use one of them for my project. Therefore, the required gems are only installed in one of the ruby installations.

      I did the following:

      1) stop jenkins launch daemon and start it from the command line instead:
      > launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist && JENKINS_HOME=/Users/Shared/Jenkins/Home /Library/Application\ Support/Jenkins/jenkins-runner.sh &>/var/log/jenkins/jenkins.log &
      2) In Jenkins job configuration: Set rvm plugin to use ruby version "2.1.5"
      3) In Jenkins job configuration: Use "build" -> "run shell command" and run a ruby command using a gem installed in version 2.1.5
      4) run the Jenkins job

      Expected result: Job should run properly

      Actual result: Job fails due to missing gems. Sample output:

      Exit status of command 'bundle install' was 1 instead of 0.
      /Users/bygadmin/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'bundler' (>= 0) among 106 total gem(s) (Gem::LoadError)
      Checked in 'GEM_PATH=/Users/bygadmin/.rvm/gems/ruby-2.0.0-p643:/Users/bygadmin/.rvm/gems/ruby-2.0.0-p643@global', execute `gem env` for more information
      from /Users/bygadmin/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/dependency.rb:324:in `to_spec'
      from /Users/bygadmin/.rvm/rubies/ruby-2.1.5/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:58:in `gem'
      from /Users/bygadmin/.rvm/gems/ruby-2.1.5/bin/bundle:22:in `<main>'

      To identify what was wrong, I ran type rvm | head -1 in the shell command. Expected result: "rvm is a function". Actual result: "rvm is /Users/bygadmin/.rvm/bin/rvm".

      My conlusion: rvm environment is not properly set up when running jenkins from command line.

      Workarounds:

      • It works when Jenkins is running as a launch daemon.
      • It works if running rvm manually in the "run shell command" section:

        #!/bin/bash
        source ~/.rvm/scripts/rvm
        rvm use 2.1.5

      Extra environment information

      > rvm list
      rvm rubies
      * ruby-2.0.0-p643 [ x86_64 ]
      => ruby-2.1.5 [ x86_64 ]
      ruby-2.2.1 [ x86_64 ]
      ruby-2.2.2 [ x86_64 ]
      ruby-2.2.3 [ x86_64 ]
      > gem list

      *** LOCAL GEMS ***

      activesupport (4.2.5.1)
      addressable (2.4.0, 2.3.8)
      ansi (1.5.0)
      autoparse (0.3.3)
      awesome_print (1.6.1)
      babosa (1.0.2)
      bigdecimal (1.2.7, 1.2.4)
      briar (2.0.1)
      builder (3.2.2)
      bundle (0.0.1)
      bundler (1.11.2, 1.7.6)
      bundler-unload (1.0.2)
      calabash (1.2.1)
      calabash-android (0.6.0, 0.4.21)
      calabash-common (0.0.2)
      calabash-cucumber (0.17.1, 0.9.169)
      cert (1.2.8)
      CFPropertyList (2.3.2)
      childprocess (0.5.9)
      claide (0.9.1)
      coderay (1.1.0)
      colored (1.2)
      colorize (0.7.7)
      command_runner_ng (0.1.0)
      commander (4.3.5)
      credentials_manager (0.14.0)
      cucumber (2.3.2, 2.1.0, 1.3.20)
      cucumber-core (1.4.0, 1.3.1)
      cucumber-wire (0.0.1)
      debase (0.2.2.beta6)
      debase-ruby_core_source (0.8.4)
      declarative (0.0.5)
      deliver (1.8.1)
      diff-lcs (1.2.5)
      domain_name (0.5.25)
      dotenv (2.1.0)
      easter (0.1.2)
      edn (1.1.0)
      escape (0.0.4)
      event-bus (0.2.3)
      excon (0.45.4)
      executable-hooks (1.3.2)
      extlib (0.9.16)
      faraday (0.9.2)
      faraday-cookie_jar (0.0.6)
      faraday_middleware (0.10.0)
      fastimage (1.8.1, 1.6.8)
      fastlane (1.53.0)
      fastlane_core (0.35.1)
      ffi (1.9.10)
      frameit (2.4.1)
      gem-wrappers (1.2.7)
      geocoder (1.2.14, 1.1.9)
      gherkin (3.2.0, 2.12.2)
      gherkin3 (3.1.2)
      google-api-client (0.9.1, 0.8.6)
      googleauth (0.5.1)
      gym (1.4.0)
      highline (1.7.8)
      http-cookie (1.0.2)
      httpclient (2.7.1, 2.3.4.1)
      hurley (0.2)
      i18n (0.7.0)
      io-console (0.4.5, 0.4.2)
      json (1.8.3, 1.8.1)
      jwt (1.5.2)
      krausefx-shenzhen (0.14.7)
      launchy (2.4.3)
      little-plugger (1.1.4)
      logging (2.0.0)
      luffa (2.0.0)
      match (0.2.5)
      memoist (0.14.0)
      method_source (0.8.2)
      mime-types (3.0, 2.99, 1.25.1)
      mime-types-data (3.2015.1120)
      mini_magick (4.3.6, 4.0.4)
      minitest (5.8.4, 4.7.5)
      multi_json (1.11.2)
      multi_test (0.1.2)
      multi_xml (0.5.5)
      multipart-post (2.0.0)
      net-sftp (2.1.2)
      net-ssh (3.0.2)
      netrc (0.11.0)
      os (0.9.6)
      pem (1.1.1)
      pilot (1.2.1)
      plist (3.1.0)
      power_assert (0.2.7)
      produce (1.1.1)
      pry (0.10.3)
      psych (2.0.17, 2.0.5)
      rack (1.6.4)
      rack-protection (1.5.3)
      rainbow (2.1.0)
      rake (10.5.0, 10.1.0)
      rbx-require-relative (0.0.9)
      rdoc (4.2.1, 4.1.0)
      representable (3.0.0, 2.3.0)
      rest-client (1.8.0, 1.6.9)
      retriable (2.1.0, 1.4.1, 1.3.3.1)
      rmagick (2.15.4)
      rouge (1.10.1)
      ruby-debug-ide (0.6.0)
      rubygems-bundler (1.4.4)
      rubyzip (1.1.7, 0.9.9)
      run_loop (2.0.4, 0.2.1)
      rvm (1.11.3.9)
      scan (0.4.2)
      security (0.1.3)
      sentry-raven (0.15.3)
      sigh (1.3.0)
      signet (0.7.2)
      sim_launcher (0.5.0, 0.4.13)
      sinatra (1.4.7)
      slack-notifier (1.5.1)
      slop (4.2.1, 3.6.0)
      slowhandcuke (0.0.3)
      snapshot (1.5.0)
      spaceship (0.19.3, 0.15.1)
      supply (0.3.0)
      terminal-notifier (1.6.3)
      terminal-table (1.5.2, 1.4.5)
      test-unit (3.1.7, 2.1.5.0)
      thor (0.19.1)
      thread_safe (0.3.5)
      tilt (2.0.2)
      tzinfo (1.2.2)
      uber (0.0.15)
      unf (0.1.4)
      unf_ext (0.0.7.1)
      xamarin-test-cloud (1.1.2, 0.9.34)
      xcode-install (1.2.5, 1.0.1)
      xcodeproj (0.28.2)
      xcpretty (0.2.2)
      xcpretty-travis-formatter (0.0.4)

        Attachments

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Unassigned
              Reporter:
              jrv Johan Vase
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: