Skip to content

Use Bootsnap compiler namespaces for hook caches - #5

Merged
palkan merged 3 commits into
ruby-next:masterfrom
rafaelfranca:rmf-bootsnap-custom
Aug 26, 2026
Merged

Use Bootsnap compiler namespaces for hook caches#5
palkan merged 3 commits into
ruby-next:masterfrom
rafaelfranca:rmf-bootsnap-custom

Conversation

@rafaelfranca

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request?

Fixes #3.

#2 isolates transformed ISeq entries through changes to
Bootsnap::CompileCache::ISeq.cache_dir.

The Bootsnap getter returns a path with the -iseq suffix. The setter
appends that suffix again. Cache directory restoration can therefore
corrupt the process-wide path.

Bootsnap 1.24 introduced per-compiler cache namespaces in
rails/bootsnap#535.
This pull request uses that API and leaves the global cache directory
unchanged.

What changes did you make? (overview)

  • Require Hooks wraps the compiler chosen by an existing selector.
  • The wrapper adds the hook configuration hash to the compiler namespace.
  • The wrapper delegates compilation to the selected compiler.
  • Unhooked paths continue to use the original compiler.
  • Older Bootsnap versions use the fetch cache_dir argument.
  • Regression tests verify that the global cache directory stays unchanged.
  • A test verifies compatibility with an existing compiler selector.
  • The README and Changelog describe the new behavior.

Is there anything you'd like reviewers to focus on?

Please review the composition with existing Bootsnap compiler selectors.

Please also review the fallback for Bootsnap versions before 1.24.

Verification

  • bundle exec bin/mspec: 300 examples and 964 expectations passed.
  • The Bootsnap 1.23 compatibility scenarios passed.
  • RuboCop passed for all changed Ruby files.

Checklist

  • I've added tests for this change
  • I've added a Changelog entry
  • I've updated a documentation

Bootsnap 1.24 adds a namespace to each compiler cache. Require Hooks
now wraps the selected compiler for hooked paths and uses the hook
configuration hash as its namespace.

This avoids changes to the process-wide cache directory. Older
Bootsnap versions use the fetch cache_dir argument instead.

Preserve prior compiler selectors and add regression coverage.

Fixes ruby-next#3

@palkan palkan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

Comment thread spec/require-hooks/bootsnap_spec.rb
@palkan
palkan merged commit 483e617 into ruby-next:master Aug 26, 2026
25 checks passed
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.

Bootsnap ISeq.cache_dir corrupted after the first hooked load (regression in 0.4.0)

2 participants