skip to Main Content

My pull request keep failing on linters with this Ruby gem error:

Run[ -f Gemfile ] && bundle --deployment
gem install --no-document rspec:'~>3.0'
shell: /bin/bash -e {0}/opt/hostedtoolcache/Ruby/2.6.6/x64/lib/ruby/2.6.0/rubygems.rb:283:in 
`find_spec_for_exe': Could not find 'bundler' (2.1.2) required by your 
/home/runner/work/Telegram_Inspirational_Bot/Telegram_Inspirational_Bot/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.To install the missing version, run `gem install bundler:2.1.2`from/opt/hostedtoolcache/Ruby/2.6.6/x64/lib/ruby/2.6.0/rubygems.rb:302:in`activate_bin_path'from/opt/hostedtoolcache/Ruby/2.6.6/x64/bin/bundle:23:in `<main>'Error: Process completed with exit code 1.

Screenshot CI

And my client can’t run my app

My client can’t run my app. I’m sure it’s because of this error. He’s getting this error after making a pull request:

The error: 
bundle install
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Bundler could not find compatible versions for gem "bundle exec rspec":
  In Gemfile:
    telegram-bot-ruby was resolved to 0.13.0, which depends on
      virtus was resolved to 1.0.5, which depends on
        bundle exec rspec

Could not find gem 'bundle exec rspec', which is required by gem 'virtus', in any of the sources.

I really can’t figure out the issue as initially I thought it was a bug from the gem file.

Gem file:

source 'https://rubygems.org'

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

# gem "rails"

gem 'json'
gem 'net-http-persistent', '~> 2.9', '>= 2.9.4'
gem 'rubocop', '~>0.81.0'
gem 'telegram-bot-ruby'

Gem file lock:

GEM
  remote: https://rubygems.org/
  specs:
    axiom-types (0.1.1)
      descendants_tracker (~> 0.0.4)
      ice_nine (~> 0.11.0)
      thread_safe (~> 0.3, >= 0.3.1)
    coercible (1.0.0)
      descendants_tracker (~> 0.0.1)
    descendants_tracker (0.0.4)
      thread_safe (~> 0.3, >= 0.3.1)
    equalizer (0.0.11)
    faraday (1.1.0)
      multipart-post (>= 1.2, < 3)
      ruby2_keywords
    ice_nine (0.11.2)
    inflecto (0.0.2)
    json (2.3.1)
    multipart-post (2.1.1)
    net-http-persistent (2.9.4)
    ruby2_keywords (0.0.2)
    telegram-bot-ruby (0.13.0)
      faraday
      inflecto
      virtus
    thread_safe (0.3.6)
    virtus (1.0.5)
      axiom-types (~> 0.1)
      coercible (~> 1.0)
      descendants_tracker (~> 0.0, >= 0.0.3)
      equalizer (~> 0.0, >= 0.0.9)

PLATFORMS
  ruby

DEPENDENCIES
  json
  net-http-persistent (~> 2.9, >= 2.9.4)
  telegram-bot-ruby

BUNDLED WITH
   2.1.4

2

Answers


  1. Chosen as BEST ANSWER

    The issue was on the linter.yml that I was using. A friend of mine recently solve the issue by modifying the linter.yml from:

    name: Linters

    on: pull_request

    jobs:

    rubocop:

    name: Rubocop
    
    runs-on: ubuntu-18.04
    
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-ruby@v1
        with:
          ruby-version: 2.6.x
      - name: Setup Rubocop
        run: |
          gem install --no-document rubocop:'~>0.81.0' # https://docs.rubocop.org/en/stable/installation/
          [ -f .rubocop.yml ] || wget https://raw.githubusercontent.com/microverseinc/linters-config/master/ruby/.rubocop.yml
      - name: Rubocop Report
        run: rubocop --color
    

    To:

    name: Tests

    on: pull_request

    jobs:

    rspec:

    name: RSpec
    
    runs-on: ubuntu-18.04
    
    steps:
    
      - uses: actions/checkout@v2
    
      - uses: actions/setup-ruby@v1
        with:
          ruby-version: 2.6.x
      - name: Setup Bundler
          run:  gem install bundler:2.1.4
      - name: Setup RSpec
        run: |
          [ -f Gemfile ] && bundle --deployment
          gem install --no-document rspec:'~>3.0'
      - name: RSpec Report
        run: rspec --force-color --format documentation
    

    The latter worked.


  2. I think there are two issues here.

    Bundler is not installed (or the wrong version is installed)

    Whatever system is running the tests / linter (appears to be Github’s CI tool) doesn’t have the correct version of bundler installed. Try adding

    gem install bundler:2.1.2
    

    to the job invoking your test suite.

    RSpec is not included in the Gemfile

    RSpec is a required dependency. It appears you’re installing rspec in the test job, but it isn’t included in your Gemfile. Try adding

    gem 'rspec'
    

    to your Gemfile.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search