Skip to content

Commit

Permalink
Prevent composed bundle from failing with SSH git sources (#2810)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock authored Oct 31, 2024
1 parent 4c7659b commit 2cd7b92
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
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: "git@github.com:Shopify/rbi.git", branch: "main"
GEMFILE

File.write(File.join(dir, "Gemfile.lock"), <<~LOCKFILE)
GIT
remote: git@github.com: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: git@github.com:Shopify/rbi.git", File.read(".ruby-lsp/Gemfile.lock"))
end
end
end

private

def with_default_external_encoding(encoding, &block)
Expand Down

0 comments on commit 2cd7b92

Please sign in to comment.