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

Fix gem pristine etc resetting gem twice sometimes #8117

Merged
merged 2 commits into from
Oct 10, 2024

Conversation

deivid-rodriguez
Copy link
Member

@deivid-rodriguez deivid-rodriguez commented Oct 8, 2024

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

If a default version and a regular version of etc are present at the same time, RubyGems will end up duplicating work and running pristine twice.

The etc gem is special because it's loaded by RubyGems by default. When doing this, RubyGems will activate the regularly installed version. The when gem pristine runs, it will find two installed specifications but materialize both to the already activated specification.

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

Make sure we only reuse an already loaded spec instead of loading the installed specification when the default_gem attribute matches it.

Before:

$ gem pristine etc --version 1.4.3
Restoring gems to pristine condition...
Building native extensions. This could take a while...
Restored etc-1.4.3
Building native extensions. This could take a while...
Restored etc-1.4.3

After:

$ gem pristine etc --version 1.4.3
Restoring gems to pristine condition...
Skipped etc-1.4.3, it is a default gem
Building native extensions. This could take a while...
Restored etc-1.4.3

Make sure the following tasks are checked

If a default version and a regular version of etc are present at the
same time, RubyGems will end up duplicating work and running pristine
twice.

The `etc` gem is special because it's loaded by RubyGems by default.
When doing this, RubyGems will activate the regularly installed version.
The when `gem pristine` runs, it will find to installed specifications
but materialize both to the already activated specification.

Before:

```
$ gem pristine etc --version 1.4.3
Restoring gems to pristine condition...
Building native extensions. This could take a while...
Restored etc-1.4.3
Building native extensions. This could take a while...
Restored etc-1.4.3
```

After:

```
$ gem pristine etc --version 1.4.3
Restoring gems to pristine condition...
Skipped etc-1.4.3, it is a default gem
Building native extensions. This could take a while...
Restored etc-1.4.3
```
@deivid-rodriguez deivid-rodriguez force-pushed the deivid-rodriguez/gem-pristine-etc-twice branch from 1acd494 to 5c279ac Compare October 8, 2024 18:57
@deivid-rodriguez deivid-rodriguez merged commit 4241c72 into master Oct 10, 2024
61 checks passed
@deivid-rodriguez deivid-rodriguez deleted the deivid-rodriguez/gem-pristine-etc-twice branch October 10, 2024 14:54
deivid-rodriguez added a commit that referenced this pull request Oct 16, 2024
…etc-twice

Fix `gem pristine etc` resetting gem twice sometimes

(cherry picked from commit 4241c72)
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.

1 participant