Skip to content

Don't leave the Rust build directory behind on a source install - #6

Merged
marcoroth merged 1 commit into
mainfrom
source-install-build-directory
Aug 25, 2026
Merged

Don't leave the Rust build directory behind on a source install#6
marcoroth merged 1 commit into
mainfrom
source-install-build-directory

Conversation

@marcoroth

Copy link
Copy Markdown
Owner

This pull request stops a source install leaving Cargo's build directory inside the installed gem.

extconf.rb runs cargo build from the gem's own rust/ directory, so rust/target is written inside the gem and stays there once the install finishes. Nothing removes it. On a platform without a precompiled gem, every install leaves several hundred megabytes of Rust intermediates sitting in the gem directory forever.

The static library is the only thing the link step needs, so it is copied into ext/ and the build directory is removed before make runs.

before   556 MB
after     43 MB

A working checkout is told apart from an installed gem by the presence of .git, so rake compile keeps rust/target and incremental builds are unaffected. Only the installed-gem path cleans up.

Precompiled gems never reach this branch at all, since they ship the built extension and do not run cargo.

@marcoroth
marcoroth enabled auto-merge (squash) August 25, 2026 02:39
@marcoroth
marcoroth merged commit 4194bc7 into main Aug 25, 2026
11 checks passed
@marcoroth
marcoroth deleted the source-install-build-directory branch August 25, 2026 02:41
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.

1 participant