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

Improve error message when changing Gemfile to a mistyped git ref #6130

Merged
merged 5 commits into from
Dec 15, 2022

Conversation

deivid-rodriguez
Copy link
Member

@deivid-rodriguez deivid-rodriguez commented Dec 14, 2022

What was the end-user or developer problem that led to this PR?

Before #4475, changing a locked git source in the Gemfile with a bad reference name would saw a helpful error saying that the reference does not exist remotely:

$ bundle install
Fetching https://github.com/rails/rails.git
fatal: Needed a single revision
Git error: command `git rev-parse --verify bad` in directory
/Users/deivid/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/cache/bundler/git/rails-fcf0202857b07db1a0f6220dae5ca99319ca0f32 has failed.
Revision bad does not exist in the repository https://github.com/rails/rails.git. Maybe you misspelled it?
If this error persists you could try removing the cache directory
'/Users/deivid/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/cache/bundler/git/rails-fcf0202857b07db1a0f6220dae5ca99319ca0f32'

To be honest, the error was not ideal but at least the culprit is mentioned Revision bad does not exist in the repository https://github.com/rails/rails.git. Maybe you misspelled it?

After #4475, the error is in my opinion worse:

$ bundle install
Fetching https://github.com/rails/rails.git
fatal: couldn't find remote ref refs/heads/bad

Retrying `git fetch --force --quiet --no-tags --depth 1 -- https://github.com/rails/rails.git refs/heads/bad:refs/heads/bad` at /Users/deivid/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/cache/bundler/git/rails-fcf0202857b07db1a0f6220dae5ca99319ca0f32 due to error (2/4): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --no-tags --depth 1 -- https://github.com/rails/rails.git refs/heads/bad:refs/heads/bad` in directory /Users/deivid/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/cache/bundler/git/rails-fcf0202857b07db1a0f6220dae5ca99319ca0f32 has failed.

If this error persists you could try removing the cache directory '/Users/deivid/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/cache/bundler/git/rails-fcf0202857b07db1a0f6220dae5ca99319ca0f32'

Retrying `git fetch --force --quiet --no-tags --depth 1 -- https://github.com/rails/rails.git refs/heads/bad:refs/heads/bad` at /Users/deivid/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/cache/bundler/git/rails-fcf0202857b07db1a0f6220dae5ca99319ca0f32 due to error (3/4): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --no-tags --depth 1 -- https://github.com/rails/rails.git refs/heads/bad:refs/heads/bad` in directory /Users/deivid/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/cache/bundler/git/rails-fcf0202857b07db1a0f6220dae5ca99319ca0f32 has failed.

If this error persists you could try removing the cache directory '/Users/deivid/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/cache/bundler/git/rails-fcf0202857b07db1a0f6220dae5ca99319ca0f32'

Retrying `git fetch --force --quiet --no-tags --depth 1 -- https://github.com/rails/rails.git refs/heads/bad:refs/heads/bad` at /Users/deivid/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/cache/bundler/git/rails-fcf0202857b07db1a0f6220dae5ca99319ca0f32 due to error (4/4): Bundler::Source::Git::GitCommandError Git error: command `git fetch --force --quiet --no-tags --depth 1 -- https://github.com/rails/rails.git refs/heads/bad:refs/heads/bad` in directory /Users/deivid/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/cache/bundler/git/rails-fcf0202857b07db1a0f6220dae5ca99319ca0f32 has failed.

If this error persists you could try removing the cache directory '/Users/deivid/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/cache/bundler/git/rails-fcf0202857b07db1a0f6220dae5ca99319ca0f32'

Git error: command `git fetch --force --quiet --no-tags --depth 1 -- https://github.com/rails/rails.git refs/heads/bad:refs/heads/bad` in directory
/Users/deivid/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/cache/bundler/git/rails-fcf0202857b07db1a0f6220dae5ca99319ca0f32 has failed.

If this error persists you could try removing the cache directory
'/Users/deivid/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/cache/bundler/git/rails-fcf0202857b07db1a0f6220dae5ca99319ca0f32'

The culprit is still mentioned fatal: couldn't find remote ref refs/heads/bad, but the error is flooded with other unhelpful information.

What is your fix for the problem, implemented in this PR?

My fix is to refactor things and show a better error in this situation:

$ bundle install
Fetching https://github.com/rails/rails.git

Git error: command `git fetch --force --quiet --no-tags --depth 1 -- https://github.com/rails/rails.git refs/heads/bad:refs/heads/bad` in directory
/Users/deivid/.asdf/installs/ruby/3.1.3/lib/ruby/gems/3.1.0/cache/bundler/git/rails-fcf0202857b07db1a0f6220dae5ca99319ca0f32 has failed.
Revision bad does not exist in the repository https://github.com/rails/rails.git. Maybe you misspelled it?

Make sure the following tasks are checked

My experience is that this advice makes the error unnecessarily too
verbose and most of the times makes no difference.

I'm removing it.
@deivid-rodriguez deivid-rodriguez merged commit 8f85d1f into master Dec 15, 2022
@deivid-rodriguez deivid-rodriguez deleted the another-git-clone-regresion branch December 15, 2022 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant