Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Running bundle pristine on a git source gem doesn't rebuild the native extension #6294

Closed
wagenet opened this issue Feb 14, 2018 · 8 comments · Fixed by #6305
Closed

Running bundle pristine on a git source gem doesn't rebuild the native extension #6294

wagenet opened this issue Feb 14, 2018 · 8 comments · Fixed by #6305

Comments

@wagenet
Copy link
Contributor

wagenet commented Feb 14, 2018

I believe this can be fixed by adding the following before https://github.com/bundler/bundler/blob/v1.16.1/lib/bundler/cli/pristine.rb#L33:

FileUtils.rm_rf spec.extension_dir if spec.have_extensions?

I'm happy to send a PR if this sounds like the correct thing to do.

@colby-swandale
Copy link
Member

Can you provide us with more information on how it's not working the way you expect with some examples?

@wagenet
Copy link
Contributor Author

wagenet commented Feb 15, 2018

@colby-swandale if you look at the code, you'll see that it only removed the main source directory, not the built extension. That means that the reinstall won't rebuild the native extension.

@colby-swandale
Copy link
Member

bundle pristine does rebuild native extensions even though it's not clear by just looking at the code, this is done by RubyGems when we reinstall the gem.

› ls -la nokogiri
-rwxr-xr-x  1 c  staff  2295772  8 Feb 19:49 nokogiri.bundle*

› bundle pristine
Installing mini_portile2 2.3.0
Installing nokogiri 1.8.2 with native extensions

› ls -la nokogiri
total 4488
-rwxr-xr-x  1 c  staff  2295772 16 Feb 07:25 nokogiri.bundle*

I've also used bundle pristine to rebuild charlock_holmes whenever libicudata is updated to a new version so i know for certain that the extension is compiled again.

@wagenet
Copy link
Contributor Author

wagenet commented Feb 15, 2018

@colby-swandale it doesn't happen for Git gems however.

@colby-swandale
Copy link
Member

Thanks for clarifying, yes this needs to be fixed.

PS. A quick suggestion: Please explain in as much detail as possible about what the problem is in the issue description. Saying "bundle pristine doesn't rebuild extensions" offers no information for us and makes work for us in trying to figure out what you're talking about. See #6276 for an example on a great example of explaining an issue in Bundler.

Thanks

@wagenet wagenet changed the title bundle pristine doesn't rebuild native extensions Running bundle pristine on a git source gem doesn't rebuild the native extension Feb 16, 2018
@wagenet
Copy link
Contributor Author

wagenet commented Feb 16, 2018

@colby-swandale I've updated the title to something more descriptive, I believe. In my local tests, the fix I proposed in the initial issue description solves the problem. Should I submit a PR with this change?

@colby-swandale
Copy link
Member

Yes please.

@wagenet
Copy link
Contributor Author

wagenet commented Feb 22, 2018

@colby-swandale see PR for partial solution

bundlerbot added a commit that referenced this issue Mar 27, 2018
Correctly re-install extensions when running `pristine` for a git source

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

I have a gem with a native extension that is installed via git. I had to recompile it due to some needed build arguments.

### The problem was...

Running `bundle pristine` would not recompile it as expected.

### My diagnosis was...

After digging into the source, I discovered that the built extension lived in a different location than the cloned git repo. `bundle pristine` was only removing the git repo so the built extension was not getting rebuilt.

### My fix...

Update `bundle pristine` to also remove the built extension. For 2.0, this also required removing the built extension cache. Without doing that, the built extension directory would just be recreated from the cache.

### I chose this fix because...

As far as I know, it's the only solution.

Resolves #6294
colby-swandale pushed a commit that referenced this issue Sep 20, 2018
Correctly re-install extensions when running `pristine` for a git source

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

I have a gem with a native extension that is installed via git. I had to recompile it due to some needed build arguments.

### The problem was...

Running `bundle pristine` would not recompile it as expected.

### My diagnosis was...

After digging into the source, I discovered that the built extension lived in a different location than the cloned git repo. `bundle pristine` was only removing the git repo so the built extension was not getting rebuilt.

### My fix...

Update `bundle pristine` to also remove the built extension. For 2.0, this also required removing the built extension cache. Without doing that, the built extension directory would just be recreated from the cache.

### I chose this fix because...

As far as I know, it's the only solution.

Resolves #6294

(cherry picked from commit 77dbd12)
colby-swandale pushed a commit that referenced this issue Oct 5, 2018
Correctly re-install extensions when running `pristine` for a git source

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

I have a gem with a native extension that is installed via git. I had to recompile it due to some needed build arguments.

### The problem was...

Running `bundle pristine` would not recompile it as expected.

### My diagnosis was...

After digging into the source, I discovered that the built extension lived in a different location than the cloned git repo. `bundle pristine` was only removing the git repo so the built extension was not getting rebuilt.

### My fix...

Update `bundle pristine` to also remove the built extension. For 2.0, this also required removing the built extension cache. Without doing that, the built extension directory would just be recreated from the cache.

### I chose this fix because...

As far as I know, it's the only solution.

Resolves #6294

(cherry picked from commit 77dbd12)
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Dec 17, 2018
pkgsr change
* Remove @Prefix@ from ALTERNATIVES file.

## 1.17.2 (2018-12-11)

 - Add compatability for bundler merge with Ruby 2.6

## 1.17.1 (2018-10-25)

 - Convert `Pathname`s to `String`s before sorting them, fixing #6760 and #6758 ([#6761](rubygems/bundler#6761), @alexggordon)

## 1.17.0 (2018-10-25)

No new changes.

## 1.17.0.pre.2 (2018-10-13)

Features:

  - Configure Bundler home, cache, config and plugin directories with `BUNDLE_USER_HOME`, `BUNDLE_USER_CACHE`, `BUNDLE_USER_CONFIG` and `BUNDLE_USER_PLUGIN` env vars ([#4333](rubygems/bundler#4333), @gwerbin)
  - Add `--all` option to `bundle binstubs` that will generate an executable file for all gems with commands in the bundle
  - Add `bundle remove` command to remove gems from the Gemfile via the CLI
  - Improve checking file permissions and asking for `sudo` in Bundler when it doesn't need to
  - Add error message to `bundle add` to check adding duplicate gems to the Gemfile
  - When asking for `sudo`, Bundler will show a list of folders/files that require elevated permissions to write to.

The following new features are available but are not enabled by default. These are intended to be tested by users for the upcoming release of Bundler 2.

  - Improve deprecation warning message for `bundle show` command
  - Improve deprecation warning message for the `--force` option in `bundle install`

## 1.17.0.pre.1 (2018-09-24)

Features:

  - Check folder/file permissions of the Bundle home directory in the `bundle doctor` command ([#5786](rubygems/bundler#5786), @ajwann)
  - Remove compiled gem extensions when running `bundle clean` ([#5596](rubygems/bundler#5596), @akhramov)
  - Add `--paths` option to `bundle list` command ([#6172](rubygems/bundler#6172), @colby-swandale)
  - Add base error class to gems generated from `bundle gem` ([#6260](rubygems/bundler#6260), @christhekeele)
  - Correctly re-install gem extensions with a git source when running `bundle pristine` ([#6294](rubygems/bundler#6294), @wagenet)
  - Add config option to disable platform warnings ([#6124](rubygems/bundler#6124), @agrim123)
  - Add `--skip-install` option to `bundle add` command to add gems to the Gemfile without installation ([#6511](rubygems/bundler#6511), @agrim123)
  - Add `--only-explicit` option to `bundle outdated` to list only outdated gems in the Gemfile ([#5366](rubygems/bundler#5366), @peret)
  - Support adding multiple gems to the Gemfile with `bundle add` ([#6543](rubygems/bundler#6543), @agrim123)
  - Make registered plugin events easier to manage in the Plugin API (@jules2689)
  - Add new gem install hooks to the Plugin API (@jules2689)
  - Add `--optimistic` and `--strict` options to `bundle add` ([#6553](https://github.com/bundler/bundler/issues/6553), @agrim123)
  - Add `--without-group` and `--only-group` options to `bundle list` ([#6564](rubygems/bundler#6564), @agrim123)
  - Add `--gemfile` option to the `bundle exec` command ([#5924](rubygems/bundler#5924), @ankitkataria)

The following new features are available but are not enabled by default. These are intended to be tested by users for the upcoming release of Bundler 2.

  - Make `install --path` relative to the current working directory ([#2048](rubygems/bundler#2048), @igorbozato)
  - Auto-configure job count ([#5808](rubygems/bundler#5808), @segiddins)
  - Use the Gem Version Promoter for major gem updates ([#5993](rubygems/bundler#5993), @segiddins)
  - Add config option to add the Ruby scope to `bundle config path` when configured globally (@segiddins)

## 1.16.6 (2018-10-05)

Changes:

  - Add an error message when adding a gem with `bundle add` that's already in the bundle ([#6341](rubygems/bundler#6341), @agrim123)
  - Add Homepage, Source Code and Chanagelog URI metadata fields to the `bundle gem` gemspec template (@walf443)

Bugfixes:

  - Fix issue where updating a gem resulted in the gem's version being downgraded when `BUNDLE_ONLY_UPDATE_TO_NEWER_VERSIONS` was set ([#6529](rubygems/bundler#6529), @theflow)
  - Fix some rescue calls that don't specifiy error type (@utilum)
  - Fix an issue when the Lockfile would contain platform-specific gems that it didn't need ([#6491](rubygems/bundler#6491), @segiddins)
  - Improve handlding of adding new gems with only a single group to the Gemfile in `bundle add` (@agrim123)
  - Refactor check for OpenSSL in `bundle env` (@voxik)
  - Remove an unnecessary assignment in Metadata (@voxik)

Documentation:

  - Update docs to reflect revised guidance to check in Gemfile.lock into version control for gems ([#5879](https://github.com/bundler/bundler/issues/5879), @arbonap)
  - Add documentation for the `--all` flag in `bundle update` (@agrim123)
  - Update README to use `bundle add` in usage examples (@hdf1986)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants