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

Improve install advice when some gems are not found #7265

Merged

Conversation

deivid-rodriguez
Copy link
Member

What was the end-user or developer problem that led to this PR?

This problem is quite specific to our dev environment, but I guess the fix could be handy for other situations.

After merging a change to treat default gems as regular gems, I get this when trying to run rubocop on our repo:

$ bin/rubocop  --only Performance/RegexpMatch
Could not find json-2.6.3 in locally installed gems
Run `bundle install --gemfile /Users/deivid/code/rubygems/rubygems/tool/bundler/lint_gems.rb` to install missing gems.

However, when running the suggested command, nothing changes and I still get the same error:

$ bundle install --gemfile /Users/deivid/code/rubygems/rubygems/tool/bundler/lint_gems.rb
Using ast 2.4.2
Using bundler 2.4.10
Using json 2.6.3
Using parallel 1.23.0
Using racc 1.7.1
Using parser 3.2.2.3
Using rainbow 3.1.1
Using regexp_parser 2.8.1
Using rexml 3.2.5
Using rubocop-ast 1.29.0
Using ruby-progressbar 1.13.0
Using unicode-display_width 2.4.2
Using rubocop 1.52.1
Using rubocop-performance 1.14.2
Bundle complete! 2 Gemfile dependencies, 14 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

$ bin/rubocop  --only Performance/RegexpMatch
Could not find json-2.6.3 in locally installed gems
Run `bundle install --gemfile /Users/deivid/code/rubygems/rubygems/tool/bundler/lint_gems.rb` to install missing gems.

The problem is that our bin/rubocop script uses the development version of Bundler (which has the change causing the problem), but the advice recommands the default version of Bundler, which does not yet have the change.

What is your fix for the problem, implemented in this PR?

This commit changes the advice to recommend to use the same version of Bundler that run into the problem in the first place.

So in the above situation you now get:

$ bin/rubocop  --only Performance/RegexpMatch
Could not find json-2.6.3 in locally installed gems
Run `/Users/deivid/code/rubygems/rubygems/bundler/exe/bundle install --gemfile /Users/deivid/code/rubygems/rubygems/tool/bundler/lint_gems.rb` to install missing gems.

And running that fixes the problem:

$ /Users/deivid//rubygems/rubygems/bundler/exe/bundle install --gemfile /Users/deivid/code/rubygems/rubygems/tool/bundler/lint_gems.rb
Fetching gem metadata from https://rubygems.org/.........
Fetching json 2.6.3
Installing json 2.6.3 with native extensions
Bundle complete! 2 Gemfile dependencies, 14 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

Make sure the following tasks are checked

This problem is quite specific to our dev environment, but I guess the
fix could be handy for other situations.

After merging a change to treat default gems as regular gems, I get this
when trying to run `rubocop` on our repo:

```
$ bin/rubocop  --only Performance/RegexpMatch
Could not find json-2.6.3 in locally installed gems
Run `bundle install --gemfile /Users/deivid/code/rubygems/rubygems/tool/bundler/lint_gems.rb` to install missing gems.
```

However, when running the suggested command, nothing changes and I still
get the same error:

```
$ bundle install --gemfile /Users/deivid/code/rubygems/rubygems/tool/bundler/lint_gems.rb
Using ast 2.4.2
Using bundler 2.4.10
Using json 2.6.3
Using parallel 1.23.0
Using racc 1.7.1
Using parser 3.2.2.3
Using rainbow 3.1.1
Using regexp_parser 2.8.1
Using rexml 3.2.5
Using rubocop-ast 1.29.0
Using ruby-progressbar 1.13.0
Using unicode-display_width 2.4.2
Using rubocop 1.52.1
Using rubocop-performance 1.14.2
Bundle complete! 2 Gemfile dependencies, 14 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

$ bin/rubocop  --only Performance/RegexpMatch
Could not find json-2.6.3 in locally installed gems
Run `bundle install --gemfile /Users/deivid/code/rubygems/rubygems/tool/bundler/lint_gems.rb` to install missing gems.
```

The problem is that our `bin/rubocop` script uses the development
version of Bundler (which has the change causing the problem), but the
advice recommands the default version of Bundler, which does not yet
have the change.

This commit changes the advice to recommend to use the same version of
Bundler that run into the problem in the first place.

So in the above situation you now get:

```
$ bin/rubocop  --only Performance/RegexpMatch
Could not find json-2.6.3 in locally installed gems
Run `/Users/deivid/code/rubygems/rubygems/bundler/exe/bundle install --gemfile /Users/deivid/code/rubygems/rubygems/tool/bundler/lint_gems.rb` to install missing gems.
```

And running that fixes the problem:

```
$ /Users/deivid//rubygems/rubygems/bundler/exe/bundle install --gemfile /Users/deivid/code/rubygems/rubygems/tool/bundler/lint_gems.rb
Fetching gem metadata from https://rubygems.org/.........
Fetching json 2.6.3
Installing json 2.6.3 with native extensions
Bundle complete! 2 Gemfile dependencies, 14 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
```
@deivid-rodriguez deivid-rodriguez force-pushed the improve-bundle-install-advice-when-missing-gems-found branch from a3ec8ea to 10a9588 Compare December 13, 2023 14:55
@deivid-rodriguez deivid-rodriguez merged commit 5114fdc into master Dec 13, 2023
80 checks passed
@deivid-rodriguez deivid-rodriguez deleted the improve-bundle-install-advice-when-missing-gems-found branch December 13, 2023 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants