Skip to content

Commit 670defb

Browse files
authored
Prevent Shadowenv from mutating BUNDLE_GEMFILE (#2874)
### Motivation I finally understood the issue we were seeing of some folks requiring completely incompatible versions of add-ons. If they used Shadowenv to override BUNDLE_GEMFILE, then it would cause the LSP to skip composing the bundle, which then leads to finding add-ons with `Gem.find_files` without having setup the bundle first. That results in finding all `addon.rb` files defined by every installed gem, which might be ordered alphabetically and then results in requiring an old and incompatible Rails add-on version. ### Implementation We cannot let Shadowenv override `BUNDLE_GEMFILE` because that fully messes up our entire composed bundle setup. I started deleting that key from the activated environment.
1 parent adf28bd commit 670defb

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

vscode/src/ruby/shadowenv.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ export class Shadowenv extends VersionManager {
3232
`${shadowenvExec} exec -- ruby`,
3333
);
3434

35+
// Do not let Shadowenv change the BUNDLE_GEMFILE. The server has to be able to control this in order to properly
36+
// set up the environment
37+
delete parsedResult.env.BUNDLE_GEMFILE;
38+
3539
return {
3640
env: { ...process.env, ...parsedResult.env },
3741
yjit: parsedResult.yjit,

0 commit comments

Comments
 (0)