Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix debug platform inclusion for Windows #2978

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/ruby_lsp/setup_bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ def write_custom_gemfile
end

unless @dependencies["debug"]
parts << 'gem "debug", require: false, group: :development, platforms: :mri'
# The `mri` platform excludes Windows. We want to install the debug gem only on MRI for any operating system,
# but that constraint doesn't yet exist in Bundler. On Windows, we are manually checking if the engine is MRI
parts << if Gem.win_platform?
'gem "debug", require: false, group: :development, install_if: -> { RUBY_ENGINE == "ruby" }'
vinistock marked this conversation as resolved.
Show resolved Hide resolved
else
'gem "debug", require: false, group: :development, platforms: :mri'
end
end

if @rails_app && !@dependencies["ruby-lsp-rails"]
Expand Down Expand Up @@ -238,9 +244,13 @@ def run_bundle_install(bundle_gemfile = @gemfile)
sig { params(env: T::Hash[String, String]).returns(T::Hash[String, String]) }
def run_bundle_install_directly(env)
RubyVM::YJIT.enable if defined?(RubyVM::YJIT.enable)

# The ENV can only be merged after checking if an update is required because we depend on the original value of
# ENV["BUNDLE_GEMFILE"], which gets overridden after the merge
should_update = should_bundle_update?
T.unsafe(ENV).merge!(env)

unless should_bundle_update?
unless should_update
Bundler::CLI::Install.new({}).run
correct_relative_remote_paths if @custom_lockfile.exist?
return env
Expand Down
16 changes: 16 additions & 0 deletions test/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,22 @@ def test_launch_mode_with_no_gemfile_and_bundle_path
end
end

def test_composed_bundle_includes_debug
in_temp_dir do |dir|
Bundler.with_unbundled_env do
launch(dir)

_stdout, stderr = capture_subprocess_io do
system(
{ "BUNDLE_GEMFILE" => File.join(dir, ".ruby-lsp", "Gemfile") },
"bundle exec ruby -e 'require \"debug\"'",
)
end
assert_empty(stderr)
end
end
end

private

def launch(workspace_path)
Expand Down
Loading