title: Jekins iOS fastlane build: Could not find 'bundler'
body: <p>I try to use Jenkins in combination with fastlane. The mac on which the build is executed is a slave of the jenkins master. The master is installed on a windows 10 system.</p>
  
  <p>When trying to build an iOS Build with Jenkins and using <code>bundle install</code> or <code>bundle exec fastlane beta</code> I always get the Error:</p>
  
  <blockquote>
    <p>/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'bundler' (>= 0.a) among 253 total gem(s) (Gem::LoadError)</p>
  
  <pre><code>from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
  from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
  from /Users/MY_USER/.rvm/gems/ruby-2.5.0/bin/bundle:25:in `&lt;main&gt;'
  from /Users/MY_USER/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:24:in `eval'
  from /Users/MY_USER/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:24:in `&lt;main&gt;'
  </code></pre>
  </blockquote>
  
  <p>When I execute the command <code>bundle install</code> in the terminal on the mac itself, the command works like expected.</p>
  
  <p>My Jenkins command looks like this:</p>
  
  <pre><code>export PATH="/usr/local/bin:$PATH"
  export PATH="$HOME/.fastlane/bin:$PATH"
  export PATH="$HOME/.rvm/bin:$PATH"
  export PATH="$HOME/.rvm/bin/rvm:$PATH"
  export PATH="$HOME/.rvm/gems/ruby-2.5.0:$PATH"
  export PATH="$HOME/.rvm/gems/ruby-2.5.0/bin:$PATH"
  
  bundle install
  bundle exec fastlane beta
  </code></pre>
  
  <p>I also tried the full path for the command: <code>$HOME/.rvm/gems/ruby-2.5.0/bin/bundle install</code> but that results in the same error.</p>
  
  <p>If I try to run fastlane without the <code>bundle</code> command, then the same error occurs just with <code>Could not find 'fastlane'</code>. So I think it has something to do with the paths and Jenkins not finding / getting the right paths to the right folder. But I have no idea where the error in the setup is hidden.</p>
  
  <p>Additional Info:</p>
  
  <p><code>echo $PATH</code> returns:</p>
  
  <pre><code>/Users/MY_USER/.rvm/gems/ruby-2.5.0/bin:/Users/MY_USER/.rvm/gems/ruby-2.5.0@global/bin:/Users/MY_USER/.rvm/rubies/ruby-2.5.0/bin:/Users/MY_USER/.rvm/gems/ruby-2.5.0:/usr/local/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/appfiff/Development/android-sdk-macosx 2/platform-tools:/Users/appfiff/Development/android-sdk-macosx 2/tools:/Users/MY_USER/.rvm/rubies/ruby-2.5.0/bin/u3d:/usr/local/git/bin:/Users/MY_USER/.rvm/bin:/Users/MY_USER/.rvm/rubies/ruby-2.5.0/bin/u3d
  </code></pre>
  
  <p>The full output of the Jenkins Command is:</p>
  
  <pre><code>+ export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
  + PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
  + export PATH=/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
  + PATH=/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
  + export PATH=/Users/MY_USER/.rvm/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
  + PATH=/Users/MY_USER/.rvm/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
  + export PATH=/Users/MY_USER/.rvm/bin/rvm:/Users/MY_USER/.rvm/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
  + PATH=/Users/MY_USER/.rvm/bin/rvm:/Users/MY_USER/.rvm/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
  + export PATH=/Users/MY_USER/.rvm/gems/ruby-2.5.0:/Users/MY_USER/.rvm/bin/rvm:/Users/MY_USER/.rvm/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
  + PATH=/Users/MY_USER/.rvm/gems/ruby-2.5.0:/Users/MY_USER/.rvm/bin/rvm:/Users/MY_USER/.rvm/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/apppfiff/.rvm/bin
  + export PATH=/Users/MY_USER/.rvm/gems/ruby-2.5.0/bin:/Users/MY_USER/.rvm/gems/ruby-2.5.0:/Users/MY_USER/.rvm/bin/rvm:/Users/MY_USER/.rvm/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
  + PATH=/Users/MY_USER/.rvm/gems/ruby-2.5.0/bin:/Users/MY_USER/.rvm/gems/ruby-2.5.0:/Users/MY_USER/.rvm/bin/rvm:/Users/MY_USER/.rvm/bin:/Users/MY_USER/.fastlane/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin/:/Users/MY_USER/.rvm/bin
  + /Users/MY_USER/.rvm/gems/ruby-2.5.0/bin/bundle install
  /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'bundler' (&gt;= 0.a) among 253 total gem(s) (Gem::LoadError)
      from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
      from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
      from /Users/MY_USER/.rvm/gems/ruby-2.5.0/bin/bundle:25:in `&lt;main&gt;'
      from /Users/MY_USER/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:24:in `eval'
      from /Users/MY_USER/.rvm/gems/ruby-2.5.0/bin/ruby_executable_hooks:24:in `&lt;main&gt;'
  </code></pre>
  
  <p>.</p>
  
  <pre><code>$ which bundle
  /Users/MY_USER/.rvm/gems/ruby-2.5.0/bin/bundle
  
  $ which ruby
  /Users/MY_USER/.rvm/rubies/ruby-2.5.0/bin/ruby
  
  $ gem list bundler
  *** LOCAL GEMS ***
  
  bundler (1.16.3)
  bundler-unload (1.0.2)
  rubygems-bundler (1.4.4)
  </code></pre>
  
  <p>My Gemfile:</p>
  
  <pre><code>source "https://rubygems.org"
  
  gem "fastlane"
  </code></pre>
  
  <p>My Gemfile.lock:</p>
  
  <pre><code>GEM
    remote: https://rubygems.org/
    specs:
      CFPropertyList (3.0.0)
      addressable (2.5.2)
        public_suffix (&gt;= 2.0.2, &lt; 4.0)
      atomos (0.1.2)
      babosa (1.0.2)
      claide (1.0.2)
      colored (1.2)
      colored2 (3.1.2)
      commander-fastlane (4.4.6)
        highline (~&gt; 1.7.2)
      declarative (0.0.10)
      declarative-option (0.1.0)
      domain_name (0.5.20180417)
        unf (&gt;= 0.0.5, &lt; 1.0.0)
      dotenv (2.5.0)
      emoji_regex (0.1.1)
      excon (0.62.0)
      faraday (0.15.2)
        multipart-post (&gt;= 1.2, &lt; 3)
      faraday-cookie_jar (0.0.6)
        faraday (&gt;= 0.7.4)
        http-cookie (~&gt; 1.0.0)
      faraday_middleware (0.12.2)
        faraday (&gt;= 0.7.4, &lt; 1.0)
      fastimage (2.1.3)
      fastlane (2.100.0)
        CFPropertyList (&gt;= 2.3, &lt; 4.0.0)
        addressable (&gt;= 2.3, &lt; 3.0.0)
        babosa (&gt;= 1.0.2, &lt; 2.0.0)
        bundler (&gt;= 1.12.0, &lt; 2.0.0)
        colored
        commander-fastlane (&gt;= 4.4.6, &lt; 5.0.0)
        dotenv (&gt;= 2.1.1, &lt; 3.0.0)
        emoji_regex (~&gt; 0.1)
        excon (&gt;= 0.45.0, &lt; 1.0.0)
        faraday (~&gt; 0.9)
        faraday-cookie_jar (~&gt; 0.0.6)
        faraday_middleware (~&gt; 0.9)
        fastimage (&gt;= 2.1.0, &lt; 3.0.0)
        gh_inspector (&gt;= 1.1.2, &lt; 2.0.0)
        google-api-client (&gt;= 0.21.2, &lt; 0.22.0)
        highline (&gt;= 1.7.2, &lt; 2.0.0)
        json (&lt; 3.0.0)
        mini_magick (~&gt; 4.5.1)
        multi_json
        multi_xml (~&gt; 0.5)
        multipart-post (~&gt; 2.0.0)
        plist (&gt;= 3.1.0, &lt; 4.0.0)
        public_suffix (~&gt; 2.0.0)
        rubyzip (&gt;= 1.2.1, &lt; 2.0.0)
        security (= 0.1.3)
        simctl (~&gt; 1.6.3)
        slack-notifier (&gt;= 2.0.0, &lt; 3.0.0)
        terminal-notifier (&gt;= 1.6.2, &lt; 2.0.0)
        terminal-table (&gt;= 1.4.5, &lt; 2.0.0)
        tty-screen (&gt;= 0.6.3, &lt; 1.0.0)
        tty-spinner (&gt;= 0.8.0, &lt; 1.0.0)
        word_wrap (~&gt; 1.0.0)
        xcodeproj (&gt;= 1.5.7, &lt; 2.0.0)
        xcpretty (~&gt; 0.2.8)
        xcpretty-travis-formatter (&gt;= 0.0.3)
      gh_inspector (1.1.3)
      google-api-client (0.21.2)
        addressable (~&gt; 2.5, &gt;= 2.5.1)
        googleauth (&gt;= 0.5, &lt; 0.7.0)
        httpclient (&gt;= 2.8.1, &lt; 3.0)
        mime-types (~&gt; 3.0)
        representable (~&gt; 3.0)
        retriable (&gt;= 2.0, &lt; 4.0)
      googleauth (0.6.2)
        faraday (~&gt; 0.12)
        jwt (&gt;= 1.4, &lt; 3.0)
        logging (~&gt; 2.0)
        memoist (~&gt; 0.12)
        multi_json (~&gt; 1.11)
        os (~&gt; 0.9)
        signet (~&gt; 0.7)
      highline (1.7.10)
      http-cookie (1.0.3)
        domain_name (~&gt; 0.5)
      httpclient (2.8.3)
      json (2.1.0)
      jwt (2.1.0)
      little-plugger (1.1.4)
      logging (2.2.2)
        little-plugger (~&gt; 1.1)
        multi_json (~&gt; 1.10)
      memoist (0.16.0)
      mime-types (3.1)
        mime-types-data (~&gt; 3.2015)
      mime-types-data (3.2016.0521)
      mini_magick (4.5.1)
      multi_json (1.13.1)
      multi_xml (0.6.0)
      multipart-post (2.0.0)
      nanaimo (0.2.6)
      naturally (2.2.0)
      os (0.9.6)
      plist (3.4.0)
      public_suffix (2.0.5)
      representable (3.0.4)
        declarative (&lt; 0.1.0)
        declarative-option (&lt; 0.2.0)
        uber (&lt; 0.2.0)
      retriable (3.1.2)
      rouge (2.0.7)
      rubyzip (1.2.1)
      security (0.1.3)
      signet (0.8.1)
        addressable (~&gt; 2.3)
        faraday (~&gt; 0.9)
        jwt (&gt;= 1.5, &lt; 3.0)
        multi_json (~&gt; 1.10)
      simctl (1.6.5)
        CFPropertyList
        naturally
      slack-notifier (2.3.2)
      terminal-notifier (1.8.0)
      terminal-table (1.8.0)
        unicode-display_width (~&gt; 1.1, &gt;= 1.1.1)
      tty-cursor (0.6.0)
      tty-screen (0.6.5)
      tty-spinner (0.8.0)
        tty-cursor (&gt;= 0.5.0)
      uber (0.1.0)
      unf (0.1.4)
        unf_ext
      unf_ext (0.0.7.5)
      unicode-display_width (1.4.0)
      word_wrap (1.0.0)
      xcodeproj (1.5.9)
        CFPropertyList (&gt;= 2.3.3, &lt; 4.0)
        atomos (~&gt; 0.1.2)
        claide (&gt;= 1.0.2, &lt; 2.0)
        colored2 (~&gt; 3.1)
        nanaimo (~&gt; 0.2.5)
      xcpretty (0.2.8)
        rouge (~&gt; 2.0.7)
      xcpretty-travis-formatter (1.0.0)
        xcpretty (~&gt; 0.2, &gt;= 0.0.7)
  
  PLATFORMS
    ruby
  
  DEPENDENCIES
    fastlane
  
  BUNDLED WITH
     1.16.3
  </code></pre>
  
  <p>What works:</p>
  
  <ul>
  <li>calling <code>bundle install</code> and <code>bundle exec fastlane beta</code> in the terminal on the slave mac directly </li>
  <li>the other Build steps in Jenkins</li>
  </ul>
  
  <p>What I already tried:</p>
  
  <ul>
  <li>reinstalling <code>ruby</code> with and without <code>sudo</code></li>
  <li>reinstalling <code>bundler</code> with and without <code>sudo</code></li>
  <li>setting the rights in the <code>/usr/local/lib/ruby/gems</code> folder. (from  <a href="https://stackoverflow.com/questions/35186427/could-not-find-bundler-0-among-0-total-gems-gemloaderror">Could not find &#39;bundler&#39; (&gt;= 0) among 0 total gem(s) (Gem::LoadError)</a>)</li>
  <li>using the full path and not just the command for <code>bundle install</code></li>
  </ul>
  
  <p>What I want to know:</p>
  
  <ul>
  <li>Where is the error in my setup? I have the feeling that it is something simple.</li>
  <li>What do I need to do, that I can use Jenkins with fastlane.</li>
  </ul>