Skip to content

Commit af07bac

Browse files
committed
Ensure tapioca gem command executes in a clean env
1 parent 3540c7c commit af07bac

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

lib/ruby_lsp/tapioca/run_gem_rbi_check.rb

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,22 @@ def generate_gem_rbis
8181

8282
sig { params(gems: T::Array[String]).void }
8383
def execute_tapioca_gem_command(gems)
84-
# Resetting BUNDLE_GEMFILE to root folder to use the project's Gemfile instead of Ruby LSP's composed Gemfile
85-
stdout, stderr, status = T.unsafe(Open3).capture3(
86-
{ "BUNDLE_GEMFILE" => "Gemfile" },
87-
"bundle",
88-
"exec",
89-
"tapioca",
90-
"gem",
91-
"--lsp_addon",
92-
*gems,
93-
)
94-
95-
log_message(stdout) unless stdout.empty?
96-
log_message(stderr) unless stderr.empty?
97-
@result.status = status
84+
Bundler.with_unbundled_env do
85+
# Resetting BUNDLE_GEMFILE to root folder to use the project's Gemfile instead of Ruby LSP's composed Gemfile
86+
stdout, stderr, status = T.unsafe(Open3).capture3(
87+
{ "BUNDLE_GEMFILE" => "Gemfile" },
88+
"bundle",
89+
"exec",
90+
"tapioca",
91+
"gem",
92+
"--lsp_addon",
93+
*gems,
94+
)
95+
96+
log_message(stdout) unless stdout.empty?
97+
log_message(stderr) unless stderr.empty?
98+
@result.status = status
99+
end
98100
end
99101

100102
sig { params(gems: T::Array[String]).void }

0 commit comments

Comments
 (0)