From 3ba628ab389da57f3d9a492aa063ab4537867074 Mon Sep 17 00:00:00 2001 From: Kaan Ozkan Date: Wed, 13 May 2026 13:41:02 -0400 Subject: [PATCH] Warn when `--only-bootsnap-rbs-cache` runs without `TAPIOCA_RBS_CACHE=1` Without the env var set, `bootsnap/setup` isn't required at boot and no RBS cache gets populated. Previously the command would still print "Bootsnap RBS cache populated", misleading users into thinking it had done useful work. Addresses https://github.com/Shopify/tapioca/pull/2617#discussion_r3209320189 --- lib/tapioca/commands/dsl_generate.rb | 3 +++ spec/tapioca/cli/dsl_spec.rb | 24 ++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/tapioca/commands/dsl_generate.rb b/lib/tapioca/commands/dsl_generate.rb index 530cfb067..5fbb01496 100644 --- a/lib/tapioca/commands/dsl_generate.rb +++ b/lib/tapioca/commands/dsl_generate.rb @@ -18,6 +18,9 @@ def execute load_application if @only_bootsnap_rbs_cache + unless ENV["TAPIOCA_RBS_CACHE"] == "1" + say_error("Warning: --only-bootsnap-rbs-cache has no effect without TAPIOCA_RBS_CACHE=1", :yellow) + end say("Bootsnap RBS cache populated, exiting before RBI generation.", :green) return end diff --git a/spec/tapioca/cli/dsl_spec.rb b/spec/tapioca/cli/dsl_spec.rb index bc1c595da..3f35192f7 100644 --- a/spec/tapioca/cli/dsl_spec.rb +++ b/spec/tapioca/cli/dsl_spec.rb @@ -669,13 +669,33 @@ class Post end RB - result = @project.tapioca("dsl --only-bootsnap-rbs-cache Post") + result = @project.tapioca("dsl --only-bootsnap-rbs-cache Post", env: { "TAPIOCA_RBS_CACHE" => "1" }) assert_stdout_includes(result, <<~OUT) Bootsnap RBS cache populated, exiting before RBI generation. OUT - assert_empty_stderr(result) + assert_stderr_includes(result, "bootsnap miss:") + refute_project_file_exist("sorbet/rbi/dsl/post.rbi") + assert_success_status(result) + end + + it "warns when --only-bootsnap-rbs-cache is set without TAPIOCA_RBS_CACHE=1" do + @project.write!("lib/post.rb", <<~RB) + require "smart_properties" + + class Post + include SmartProperties + property :title, accepts: String + end + RB + + result = @project.tapioca("dsl --only-bootsnap-rbs-cache Post") + + assert_stderr_includes( + result, + "Warning: --only-bootsnap-rbs-cache has no effect without TAPIOCA_RBS_CACHE=1", + ) refute_project_file_exist("sorbet/rbi/dsl/post.rbi") assert_success_status(result) end