Skip to content

Use env shebangs for RubyGems installs#4126

Draft
joshheinrichs-shopify wants to merge 1 commit into
Shopify:mainfrom
joshheinrichs-shopify:env-shebang
Draft

Use env shebangs for RubyGems installs#4126
joshheinrichs-shopify wants to merge 1 commit into
Shopify:mainfrom
joshheinrichs-shopify:env-shebang

Conversation

@joshheinrichs-shopify
Copy link
Copy Markdown

Motivation

RubyGems bin wrappers hardcode the Ruby used at install time. With
Nix-style Ruby installs, that path can later be garbage-collected or
replaced, leaving wrappers like ruby-lsp and bundle pointing at a stale
store path.

Implementation

Ruby LSP already activates the project Ruby environment before installing
or launching the server, so install the bootstrap ruby-lsp gem and any
missing Bundler versions with RubyGems' env-shebang option. This lets
generated wrappers resolve ruby from the activated PATH instead.

Bundler project binstubs already use env shebangs by default; this makes
the RubyGems bin wrappers Ruby LSP relies on behave similarly.

Automated Tests

Yes.

Manual Tests

In a clean project, ruby-lsp and bundler should have #!/usr/bin/env ruby as the shebang.

RubyGems bin wrappers hardcode the Ruby used at install time. With
Nix-style Ruby installs, that path can later be garbage-collected or
replaced, leaving wrappers like ruby-lsp and bundle pointing at a stale
store path.

Ruby LSP already activates the project Ruby environment before installing
or launching the server, so install the bootstrap ruby-lsp gem and any
missing Bundler versions with RubyGems' env-shebang option. This lets
generated wrappers resolve ruby from the activated PATH instead.

Bundler project binstubs already use env shebangs by default; this makes
the RubyGems bin wrappers Ruby LSP relies on behave similarly.
@rafaelfranca rafaelfranca added vscode This pull request should be included in the VS Code extension's release notes server This pull request should be included in the server gem's release notes bugfix This PR will fix an existing bug labels Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes vscode This pull request should be included in the VS Code extension's release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants