'Gitlab CI-CD using Fastlane An error occurred while installing rake (13.0.6), and Bundler cannot continue

I am trying to integrate CI-CD using Fastlane all the lanes are working fine in my personal laptop but when I try to push it on my repo and after the job starts it shows the below error enter image description here

My .gitlab.ci.yml file is

variables: GIT_STRATEGY: fetch LC_ALL: "en_US.UTF-8" LANG: "en_US.UTF-8"

stages:

  • lint
  • unit_tests
  • archive

before_script:

  • bundle install --path vendor/bundle
  • bundle exec pod install

lint: stage: lint script: - fastlane lint tags: - ios-tag

unit_tests: stage: unit_tests script: - fastlane test tags: - ios-tag

archive_project: stage: archive script: - fastlane distribute tags: - ios-tag

And when I try to execute the jobs it shows me the above error

I have also removed everything written in my .bash_profile considering if rvm was causing some issue

Below is the full console output when I try to run the job on GitLab:

Running with gitlab-runner 14.10.0 (c6bb62f6) on demo for ci-cd iQtGJP4Z Preparing the "shell" executor 00:00 Using Shell executor... Preparing environment 00:00 Running on xxxxxxxx082... Getting source from Git repository 00:02 Fetching changes with git depth set to 20... Reinitialized existing Git repository in /Users/Mohit.Pareek/Documents/CI-CD-Demo/builds/iQtGJP4Z/0/mohit.pareek/ci-cd-demo/.git/ Checking out e699b9da as main... Skipping Git submodules setup Executing "step_script" stage of the job script 00:16 $ bundle install Fetching gem metadata from https://rubygems.org/....... Following files may not be writable, so sudo is needed: /Library/Ruby/Gems/2.6.0 /Library/Ruby/Gems/2.6.0/build_info /Library/Ruby/Gems/2.6.0/bundler /Library/Ruby/Gems/2.6.0/cache /Library/Ruby/Gems/2.6.0/doc /Library/Ruby/Gems/2.6.0/extensions /Library/Ruby/Gems/2.6.0/gems /Library/Ruby/Gems/2.6.0/specifications Fetching rake 13.0.6 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Using rexml 3.2.5 Using concurrent-ruby 1.1.10 Using minitest 5.15.0 Using zeitwerk 2.5.4 Using httpclient 2.8.3 Using atomos 0.1.3 Using bundler 2.3.10 Fetching jmespath 1.6.1 Fetching public_suffix 4.0.7 Fetching json 2.6.1 Fetching artifactory 3.0.15 Fetching aws-partitions 1.587.0 Fetching aws-eventstream 1.2.0 Fetching babosa 1.0.4 Using claide 1.1.0 Using fuzzy_match 2.0.4 Using nap 1.1.0 Using netrc 0.11.0 Using cocoapods-deintegrate 1.0.5 Using cocoapods-downloader 1.6.3 Fetching ffi 1.15.5 Using cocoapods-try 1.2.0 Using escape 0.0.4 Using cocoapods-search 1.0.1 Using colored2 3.1.2 Using fourflusher 2.3.1 Using nanaimo 0.3.0 Using gh_inspector 1.1.3 Using molinillo 0.8.0 Using ruby-macho 2.5.1 Fetching colored 1.2 Fetching highline 2.0.3 Fetching unf_ext 0.0.8.1 Fetching declarative 0.0.20 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching dotenv 2.7.6 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching emoji_regex 3.2.3 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching excon 0.92.3 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching faraday-em_http 1.0.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching faraday-em_synchrony 1.0.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching faraday-excon 1.1.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching faraday-httpclient 1.0.1 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching multipart-post 2.0.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching faraday-net_http 1.0.1 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching faraday-net_http_persistent 1.2.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching faraday-patron 1.0.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching faraday-rack 1.0.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching faraday-retry 1.0.3 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching ruby2_keywords 0.0.5 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching fastimage 2.2.6 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching jwt 2.3.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching memoist 0.16.2 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching multi_json 1.15.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching os 1.1.4 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching mini_mime 1.1.2 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching trailblazer-option 0.1.2 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching uber 0.1.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching retriable 3.1.2 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching webrick 1.7.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching google-cloud-errors 1.2.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching mini_magick 4.11.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching naturally 2.2.1 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching optparse 0.1.1 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching plist 3.6.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching rubyzip 2.3.2 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching security 0.1.3 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching terminal-notifier 2.0.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching unicode-display_width 1.8.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching tty-screen 0.8.1 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching tty-cursor 0.7.1 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching word_wrap 1.0.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Using rouge 2.0.7 Fetching fastlane-plugin-firebase_app_distribution 0.3.4 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching slack-notifier 2.4.0 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Fetching xcresult 0.2.1 sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper sudo: a password is required Bundler::SudoNotPermittedError: Bundler requires sudo access to install at the moment. Try installing again, granting Bundler sudo access when prompted, or installing into a different path. /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler.rb:547:in block in sudo' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler.rb:532:in synchronize' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler.rb:532:in sudo' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/source/rubygems.rb:485:in fetch_gem' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/source/rubygems.rb:165:in install' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/installer/gem_installer.rb:54:in install' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/installer/gem_installer.rb:16:in install_from_spec' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/installer/parallel_installer.rb:186:in do_install' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/installer/parallel_installer.rb:90:in call' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/installer/parallel_installer.rb:71:in call' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/installer.rb:259:in install_in_parallel' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/installer.rb:209:in install' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/installer.rb:89:in block in run' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/process_lock.rb:19:in rescue in lock' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/process_lock.rb:15:in lock' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/installer.rb:71:in run' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/installer.rb:23:in install' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/cli/install.rb:62:in run' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/cli.rb:255:in block in install' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/settings.rb:131:in temporary' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/cli.rb:254:in install' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/vendor/thor/lib/thor/command.rb:27:in run' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in invoke_command' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/vendor/thor/lib/thor.rb:392:in dispatch' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/cli.rb:31:in dispatch' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/vendor/thor/lib/thor/base.rb:485:in start' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/cli.rb:25:in start' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/exe/bundle:48:in block in <top (required)>' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/lib/bundler/friendly_errors.rb:103:in with_friendly_errors' /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.10/exe/bundle:36:in <top (required)>' /usr/local/bin/bundle:23:in load' /usr/local/bin/bundle:23:in ' An error occurred while installing rake (13.0.6), and Bundler cannot continue. In Gemfile: xcov was resolved to 1.8.1, which depends on fastlane was resolved to 2.205.2, which depends on google-cloud-storage was resolved to 1.36.2, which depends on digest-crc was resolved to 0.6.4, which depends on rake ERROR: Job failed: exit status 1 lint

Duration: 18 seconds Finished: 20 hours ago Timeout: 1h (from project)

Runner: #8 (iQtGJP4Z) demo for ci-cd Tags: ios-tag

Commit e699b9da fasfzf

Pipeline #37641 for main lint



Solution 1:[1]

I have finally found the issue. Basically, access was not given. So I just uploaded my public ssh key for that specific repository gitlab->your_project->settings->repository->deploy keys

It solved my issue. Also i will suggest to move from rvm to rbenv for managing ruby

Solution 2:[2]

I'm assuming the runner being utilized is a shell runner, since you are encountering issues with installing gems (e.g. - Bundler requires sudo access to install at the moment).

I would recommend installing Docker, and registering a runner using the docker executor. Then, update your gitlab-ci.yml to use a Ruby docker image.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mohit Pareek
Solution 2 Richard