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

Prevent composed bundle from failing with SSH git sources #2810

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
3 changes: 3 additions & 0 deletions lib/ruby_lsp/setup_bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ def correct_relative_remote_paths
else
match
end
rescue URI::InvalidURIError, URI::InvalidComponentError
# If the path raises an invalid error, it might be a git ssh path, which indeed isn't a URI
match
end

@custom_lockfile.write(content)
Expand Down
47 changes: 47 additions & 0 deletions test/setup_bundler_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,53 @@ def test_progress_is_printed_to_stderr
end
end

def test_succeeds_when_using_ssh_git_sources_instead_of_https
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
File.write(File.join(dir, "Gemfile"), <<~GEMFILE)
source "https://rubygems.org"
gem "rbi", git: "[email protected]:Shopify/rbi.git", branch: "main"
GEMFILE

File.write(File.join(dir, "Gemfile.lock"), <<~LOCKFILE)
GIT
remote: [email protected]:Shopify/rbi.git
revision: d2e59a207c0b2f07d9bbaf1eb4b6d2500a4782ea
branch: main
specs:
rbi (0.2.1)
prism (~> 1.0)
sorbet-runtime (>= 0.5.9204)

GEM
remote: https://rubygems.org/
specs:
prism (1.2.0)
sorbet-runtime (0.5.11630)

PLATFORMS
arm64-darwin-23
ruby

DEPENDENCIES
rbi!

BUNDLED WITH
2.5.22
LOCKFILE

Bundler.with_unbundled_env do
capture_subprocess_io do
stub_bundle_with_env(bundle_env(dir, ".ruby-lsp/Gemfile"))
run_script(dir)
end
end

assert_match("remote: [email protected]:Shopify/rbi.git", File.read(".ruby-lsp/Gemfile.lock"))
end
end
end

private

def with_default_external_encoding(encoding, &block)
Expand Down
Loading