Module: Tapioca::RBS::BootsnapGuard

Extended by:
T::Sig
Defined in:
lib/tapioca/rbs/rewriter.rb

Overview

Raises when the host calls ‘Bootsnap.setup` after tapioca’s setup. Host’s call would overwrite tapioca’s cache directory, so rewritten iseqs would end up in the host’s regular cache.

Instance Method Summary collapse

Instance Method Details

#setup(**_kwargs) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/tapioca/rbs/rewriter.rb', line 19

def setup(**_kwargs)
  Kernel.raise HostBootsnapSetupError, <<~MSG
    Bootsnap.setup was called while TAPIOCA_RBS_CACHE=1 is set. Tapioca already
    configured bootsnap with a dedicated cache directory; re-running setup
    would overwrite that config and start writing rewritten iseqs into your
    host's cache.

    Gate your host's Bootsnap.setup on the env var, e.g. in config/boot.rb:

      require "bootsnap/setup" unless ENV["TAPIOCA_RBS_CACHE"] == "1"
  MSG
end