Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion for handling Gemfile.lock on miq_bot #566

Closed
wants to merge 4 commits into from

Conversation

agrare
Copy link
Member

@agrare agrare commented Aug 23, 2021

When I clone this repo and try to run specs I get:

adam@desktop:~/src/manageiq/miq_bot$ rspec

An error occurred while loading spec_helper. - Did you mean?
                    rspec ./spec/spec_helper.rb

Failure/Error: require File.expand_path("../../config/environment", __FILE__)

Gem::MissingSpecVersionError:
  Could not find 'bundler' (1.17.3) required by your /home/grare/adam/src/manageiq/miq_bot/Gemfile.lock.
  To update to the latest version installed on your system, run `bundle update --bundler`.
  To install the missing version, run `gem install bundler:1.17.3`
  Checked in 'GEM_PATH=/home/grare/adam/.gem/ruby/2.7.0:/var/lib/gems/2.7.0:/usr/local/lib/ruby/gems/2.7.0:/usr/lib/ruby/gems/2.7.0:/usr/lib/x86_64-linux-gnu/ruby/gems/2.7.0:/usr/share/rubygems-integration/2.7.0:/usr/share/rubygems-integration/all:/usr/lib/x86_64-linux-gnu/rubygems-integration/2.7.0:/home/grare/adam/.gem' , execute `gem env` for more information
# ./config/boot.rb:4:in `<top (required)>'
# ./config/application.rb:1:in `<top (required)>'
# ./config/environment.rb:2:in `<top (required)>'
# ./spec/spec_helper.rb:3:in `<top (required)>'
No examples found.


Finished in 0.00005 seconds (files took 0.09503 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

If I then rm Gemfile.lock && bundle update I pull down an invalid version of celluloid which causes failures when running rspec:

adam@desktop:~/src/manageiq/miq_bot$ rspec

An error occurred while loading spec_helper. - Did you mean?
                    rspec ./spec/spec_helper.rb

Failure/Error: require File.expand_path("../../config/environment", __FILE__)

LoadError:
  cannot load such file -- celluloid/current

Looks like we require ~> 0.17.4

@agrare
Copy link
Member Author

agrare commented Aug 23, 2021

cc @bdunne @Fryguy

Just wanted to throw this up for discussion, this is basically what I have to do every time I want to run some specs locally on this repo
If this is still intentional and serving a purpose I don't mind continuing to do this but wanted to put this out there. I'm sure this will impact the bot build.

@agrare
Copy link
Member Author

agrare commented Aug 23, 2021

Interestingly the spec failure is new with rspec 3.10 (we were on 3.9) https://app.travis-ci.com/github/ManageIQ/miq_bot/builds/236027823#L540-L554

@NickLaMuro
Copy link
Member

@agrare Did you not do bundle exec rspec? That might be your issue there.

@agrare
Copy link
Member Author

agrare commented Aug 23, 2021

@NickLaMuro I did use bundle exec rspec

$ bundle exec rspec spec/models/batch_job_spec.rb 

Randomized with seed 14666
.........F.........

Failures:

  1) BatchJob#check_complete when destroyed by another checker
     Failure/Error: expect(job).to_not receive(:finalize!)
     
     ArgumentError:
       Cannot proxy frozen objects, rspec-mocks relies on proxies for method stubbing and expectations.
     # ./spec/models/batch_job_spec.rb:90:in `block (3 levels) in <top (required)>'
     # /home/grare/adam/.gem/gems/webmock-3.14.0/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'

Finished in 0.20497 seconds (files took 1.88 seconds to load)
19 examples, 1 failure

Failed examples:

rspec ./spec/models/batch_job_spec.rb:87 # BatchJob#check_complete when destroyed by another checker

Randomized with seed 14666

We don't have any version limits on rspec in our Gemfile but since the Gemfile.lock was committed and no one bundle update'd we were still running with the older version.

@NickLaMuro
Copy link
Member

@NickLaMuro I did use bundle exec rspec

@agrare roger. Was just double checking since the OP just showed:

adam@desktop:~/src/manageiq/miq_bot$ rspec

Fixes `Cannot proxy frozen objects, rspec-mocks relies on proxies for
method stubbing and expectations.`
@agrare
Copy link
Member Author

agrare commented Aug 23, 2021

Ah yeah good call, I'm usually too lazy to run through bundle exec (or even alias to be) and only do that if I run into issues (like this)

@bdunne
Copy link
Member

bdunne commented Aug 23, 2021

I think you just need to gem install bundler:1.17.3 then bundle exec rspec or bundle exec rake should work. I'm not opposed to updating bundler or other dependencies if you want, but I'd prefer not to delete the Gemfile.lock completely since it's used for production.

@NickLaMuro
Copy link
Member

NickLaMuro commented Aug 23, 2021

@agrare So I wasn't able to reproduce the errors you had. I did a bundle exec rspec with no issue out of the gate (minus not having redis locally), and then doing rspec by itself led to a more reasonable error:

$ rspec
Traceback (most recent call last):
        37: from ~/.gem/ruby/2.6.6/bin/rspec:23:in `<main>'
        36: from ~/.gem/ruby/2.6.6/bin/rspec:23:in `load'
        35: from ~/.gem/ruby/2.6.6/gems/rspec-core-3.9.3/exe/rspec:4:in `<top (required)>'
        34: from ~/.gem/ruby/2.6.6/gems/rspec-core-3.9.3/lib/rspec/core/runner.rb:45:in `invoke'
        33: from ~/.gem/ruby/2.6.6/gems/rspec-core-3.9.3/lib/rspec/core/runner.rb:71:in `run'
            ...
         3: from ~/.rubies/ruby-2.6.6/lib/ruby/2.6.0/forwardable.rb:230:in `each'
         2: from ~/.rubies/ruby-2.6.6/lib/ruby/2.6.0/forwardable.rb:230:in `each'
         1: from ~/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/runtime.rb:31:in `block in setup'
~/.rubies/ruby-2.6.6/lib/ruby/2.6.0/bundler/runtime.rb:319:in `check_for_activated_spec!': You have already activated rspec-support 3.9.4, but your Gemfile requires rspec-support 3.9.2. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
        17: from ~/.gem/ruby/2.6.6/bin/rspec:23:in `<main>'
        16: from ~/.gem/ruby/2.6.6/bin/rspec:23:in `load'
        15: from ~/.gem/ruby/2.6.6/gems/rspec-core-3.9.3/exe/rspec:4:in `<top (required)>'
            ...
         3: from ~/.gem/ruby/2.6.6/gems/rspec-core-3.9.3/lib/rspec/core/configuration.rb:1568:in `block in requires='
         2: from ~/.gem/ruby/2.6.6/gems/rspec-core-3.9.3/lib/rspec/core/configuration.rb:2105:in `load_file_handling_errors'
         1: from ~/.gem/ruby/2.6.6/gems/rspec-core-3.9.3/lib/rspec/core/configuration.rb:2109:in `rescue in load_file_handling_errors'
~/.gem/ruby/2.6.6/gems/rspec-core-3.9.3/lib/rspec/core/configuration.rb:2109:in `require': cannot load such file -- rspec/core/did_you_mean (LoadError)
        18: from ~/.gem/ruby/2.6.6/bin/rspec:23:in `<main>'
        17: from ~/.gem/ruby/2.6.6/bin/rspec:23:in `load'
        16: from ~/.gem/ruby/2.6.6/gems/rspec-core-3.9.3/exe/rspec:4:in `<top (required)>'
            ...
         3: from ~/.gem/ruby/2.6.6/gems/rspec-core-3.9.3/lib/rspec/core/formatters.rb:152:in `add'
         2: from ~/.gem/ruby/2.6.6/gems/rspec-core-3.9.3/lib/rspec/core/formatters.rb:182:in `find_formatter'
         1: from ~/.gem/ruby/2.6.6/gems/rspec-core-3.9.3/lib/rspec/core/formatters.rb:212:in `built_in_formatter'
~/.gem/ruby/2.6.6/gems/rspec-core-3.9.3/lib/rspec/core/formatters.rb:212:in `require': cannot load such file -- rspec/core/formatters/progress_formatter (LoadError)

This was somewhat expected as I had some newer versions of rspec installed:

$ gem list | grep rspec
guard-rspec (4.7.3)
rspec (3.10.0, 3.9.0, 3.5.0)
rspec-core (3.10.1, 3.10.0, 3.9.3, 3.9.1, 3.5.4)
rspec-expectations (3.10.1, 3.10.0, 3.9.4, 3.9.3, 3.9.2, 3.9.0, 3.5.0)
rspec-mocks (3.10.2, 3.10.1, 3.10.0, 3.9.1, 3.5.0)
rspec-rails (5.0.1, 4.0.2, 4.0.1, 3.9.1, 3.9.0)
rspec-support (3.10.2, 3.10.1, 3.10.0, 3.9.4, 3.9.3, 3.9.2, 3.5.0)
rubocop-rspec (2.0.1)
spring-commands-rspec (1.0.4)

Which I handled by doing a bit of bash hackery a few times. Example below:

$ cat <<-EOF | xargs -I {} gem uninstal {} -Iv 3.10.2
rspec
rspec-core
rspec-expectations
rspec-mocks
rspec-support
EOF

And then it ran just fine.


So this leads me to believe it might be something odd with your setup (besides Linux v.s. OSX). As @bdunne suggested, possibly you have a different version of bundler installed than what is expected. I was also doing my tests with ruby-2.6.6, and it seem like you were using ruby.2.7.X of some sort, so that might be it too.

That said, I also think that doing a rm Gemfile.lock is not the real problem here, so I don't know that is the solution we should do. I am going to try reproducing with a fresh install of ruby-2.7.0, but I don't think that is going to be the issue at play here.

EDIT: Also tested on a fresh version of ruby-2.7.1 and fresh clone, and aside from the fun OSX issue for thin:

macournoyer/thin#364

I had no issues with that either.

@miq-bot
Copy link
Member

miq-bot commented Aug 23, 2021

Checked commits agrare/miq_bot@2d49f2d~...b5061a7 with ruby 2.6.3, rubocop 1.13.0, haml-lint 0.35.0, and yamllint
2 files checked, 0 offenses detected
Everything looks fine. ⭐

@agrare
Copy link
Member Author

agrare commented Aug 24, 2021

So this leads me to believe it might be something odd with your setup (besides Linux v.s. OSX).

It was failing on travis also, not just locally: https://app.travis-ci.com/github/ManageIQ/miq_bot/builds/236027823#L542-L547
Locking back down to rspec 3.9 resolved it locally so it appears to mainly be an issue with rspec 3.10.

@agrare
Copy link
Member Author

agrare commented Aug 24, 2021

Since @bdunne wants to keep Gemfile.lock committed I'll close this and focus on getting some of the gems here updated since e.g. rspec 3.9 is going to be 2 years old soon

@agrare agrare closed this Aug 24, 2021
@agrare agrare deleted the dont_commit_gemfile_lock branch August 24, 2021 13:26
@agrare agrare mentioned this pull request Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants