Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jekins iOS fastlane build: Could not find 'bundler'

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.

When trying to build an iOS Build with Jenkins and using bundle install or bundle exec fastlane beta I always get the Error:

/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)

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 `<main>'
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 `<main>'

When I execute the command bundle install in the terminal on the mac itself, the command works like expected.

My Jenkins command looks like this:

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

I also tried the full path for the command: $HOME/.rvm/gems/ruby-2.5.0/bin/bundle install but that results in the same error.

If I try to run fastlane without the bundle command, then the same error occurs just with Could not find 'fastlane'. 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.

Additional Info:

echo $PATH returns:

/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

The full output of the Jenkins Command is:

+ 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' (>= 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 `<main>'
    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 `<main>'

.

$ 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)

My Gemfile:

source "https://rubygems.org"

gem "fastlane"

My Gemfile.lock:

GEM
  remote: https://rubygems.org/
  specs:
    CFPropertyList (3.0.0)
    addressable (2.5.2)
      public_suffix (>= 2.0.2, < 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 (~> 1.7.2)
    declarative (0.0.10)
    declarative-option (0.1.0)
    domain_name (0.5.20180417)
      unf (>= 0.0.5, < 1.0.0)
    dotenv (2.5.0)
    emoji_regex (0.1.1)
    excon (0.62.0)
    faraday (0.15.2)
      multipart-post (>= 1.2, < 3)
    faraday-cookie_jar (0.0.6)
      faraday (>= 0.7.4)
      http-cookie (~> 1.0.0)
    faraday_middleware (0.12.2)
      faraday (>= 0.7.4, < 1.0)
    fastimage (2.1.3)
    fastlane (2.100.0)
      CFPropertyList (>= 2.3, < 4.0.0)
      addressable (>= 2.3, < 3.0.0)
      babosa (>= 1.0.2, < 2.0.0)
      bundler (>= 1.12.0, < 2.0.0)
      colored
      commander-fastlane (>= 4.4.6, < 5.0.0)
      dotenv (>= 2.1.1, < 3.0.0)
      emoji_regex (~> 0.1)
      excon (>= 0.45.0, < 1.0.0)
      faraday (~> 0.9)
      faraday-cookie_jar (~> 0.0.6)
      faraday_middleware (~> 0.9)
      fastimage (>= 2.1.0, < 3.0.0)
      gh_inspector (>= 1.1.2, < 2.0.0)
      google-api-client (>= 0.21.2, < 0.22.0)
      highline (>= 1.7.2, < 2.0.0)
      json (< 3.0.0)
      mini_magick (~> 4.5.1)
      multi_json
      multi_xml (~> 0.5)
      multipart-post (~> 2.0.0)
      plist (>= 3.1.0, < 4.0.0)
      public_suffix (~> 2.0.0)
      rubyzip (>= 1.2.1, < 2.0.0)
      security (= 0.1.3)
      simctl (~> 1.6.3)
      slack-notifier (>= 2.0.0, < 3.0.0)
      terminal-notifier (>= 1.6.2, < 2.0.0)
      terminal-table (>= 1.4.5, < 2.0.0)
      tty-screen (>= 0.6.3, < 1.0.0)
      tty-spinner (>= 0.8.0, < 1.0.0)
      word_wrap (~> 1.0.0)
      xcodeproj (>= 1.5.7, < 2.0.0)
      xcpretty (~> 0.2.8)
      xcpretty-travis-formatter (>= 0.0.3)
    gh_inspector (1.1.3)
    google-api-client (0.21.2)
      addressable (~> 2.5, >= 2.5.1)
      googleauth (>= 0.5, < 0.7.0)
      httpclient (>= 2.8.1, < 3.0)
      mime-types (~> 3.0)
      representable (~> 3.0)
      retriable (>= 2.0, < 4.0)
    googleauth (0.6.2)
      faraday (~> 0.12)
      jwt (>= 1.4, < 3.0)
      logging (~> 2.0)
      memoist (~> 0.12)
      multi_json (~> 1.11)
      os (~> 0.9)
      signet (~> 0.7)
    highline (1.7.10)
    http-cookie (1.0.3)
      domain_name (~> 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 (~> 1.1)
      multi_json (~> 1.10)
    memoist (0.16.0)
    mime-types (3.1)
      mime-types-data (~> 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 (< 0.1.0)
      declarative-option (< 0.2.0)
      uber (< 0.2.0)
    retriable (3.1.2)
    rouge (2.0.7)
    rubyzip (1.2.1)
    security (0.1.3)
    signet (0.8.1)
      addressable (~> 2.3)
      faraday (~> 0.9)
      jwt (>= 1.5, < 3.0)
      multi_json (~> 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 (~> 1.1, >= 1.1.1)
    tty-cursor (0.6.0)
    tty-screen (0.6.5)
    tty-spinner (0.8.0)
      tty-cursor (>= 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 (>= 2.3.3, < 4.0)
      atomos (~> 0.1.2)
      claide (>= 1.0.2, < 2.0)
      colored2 (~> 3.1)
      nanaimo (~> 0.2.5)
    xcpretty (0.2.8)
      rouge (~> 2.0.7)
    xcpretty-travis-formatter (1.0.0)
      xcpretty (~> 0.2, >= 0.0.7)

PLATFORMS
  ruby

DEPENDENCIES
  fastlane

BUNDLED WITH
   1.16.3

What works:

  • calling bundle install and bundle exec fastlane beta in the terminal on the slave mac directly
  • the other Build steps in Jenkins

What I already tried:

  • reinstalling ruby with and without sudo
  • reinstalling bundler with and without sudo
  • setting the rights in the /usr/local/lib/ruby/gems folder. (from Could not find 'bundler' (>= 0) among 0 total gem(s) (Gem::LoadError))
  • using the full path and not just the command for bundle install

What I want to know:

  • Where is the error in my setup? I have the feeling that it is something simple.
  • What do I need to do, that I can use Jenkins with fastlane.
like image 441
Fabian Schmitz Avatar asked Oct 16 '22 14:10

Fabian Schmitz


1 Answers

Try to set your source to rvm, I have a setup like this:

export GEM_HOME=\$HOME/.rvm/gems/ruby-2.5.0
export GEM_PATH=\$HOME/.rvm/gems/ruby-2.5.0:\$HOME/.rvm/gems/ruby-2.5.0@global
LANG=en_US.UTF-8
source "\$HOME/.rvm/scripts/rvm"
bundle update && bundle install
bundle exec fastlane $cmd

It looks like your are using the wrong ruby version in the Jenkins JVM:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0...

you may need to set the right version with rvm use 2.5.0 before calling bundle ...

The main problem with Jenkins is, that it is running in a different environment then your terminal (your Mac in general) because of the JVM it's working in. Duo to this setup, you need to call your setup like mine always before you make a call to your Bundler (or any ruby gem).

like image 90
zero3nna Avatar answered Nov 02 '22 06:11

zero3nna