feat(gem-backend): use gem command for backend operations#6650
Conversation
|
@jdx - Is this something you would be willing to consider as a contribution? If so, what are you looking for to move something forward here? |
|
I think this was fine, I just closed a bunch of old PRs so idk if it wasn't passing tests or something |
There was a problem hiding this comment.
Pull Request Overview
This PR replaces the Ruby gems API-based version listing with a gem command-based approach to respect user-configured gem sources and mirrors from ~/.gemrc. The change switches from HTTP API calls to rubygems.org to using the gem info command for listing remote versions.
Key Changes:
- Replace HTTP API calls with
gem infocommand execution to respect gem source configurations - Add parsing logic for
gem infooutput format - Add comprehensive test coverage for the new parsing function
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Ok(versions) | ||
| async fn _list_remote_versions(&self, config: &Arc<Config>) -> eyre::Result<Vec<String>> { | ||
| // Use `gem info` to list versions, which respects configured gem sources/mirrors | ||
| let env = self.dependency_env(config).await.unwrap_or_default(); |
There was a problem hiding this comment.
Using unwrap_or_default() silently swallows errors from dependency_env(). If the environment setup fails, this could lead to unexpected behavior when executing the gem command. Consider propagating the error or logging a warning when dependency_env() fails.
| let env = self.dependency_env(config).await.unwrap_or_default(); | |
| let env = self.dependency_env(config).await?; |
| Ok(versions) | ||
| async fn _list_remote_versions(&self, config: &Arc<Config>) -> eyre::Result<Vec<String>> { | ||
| // Use `gem info` to list versions, which respects configured gem sources/mirrors | ||
| let env = self.dependency_env(config).await.unwrap_or_default(); |
There was a problem hiding this comment.
Bug: Inconsistent Error Handling Hides Problems
The dependency_env call uses .unwrap_or_default() which silently swallows errors, while install_version_ at line 74 propagates them with ?. This inconsistency means configuration errors are hidden during version listing but surfaced during installation, causing confusing behavior. Other backends consistently propagate dependency_env errors.
Initial draft POC in relation to #5325. Switches from using the rubygems API directly to the
gemcommand in order to leverage the~/.gemrcgem sources configuration.Note
Replaces Rubygems API calls with
gem infofor remote version listing (respecting configured sources), adds a parser and tests, and removes related HTTP/URL code.gem info --remote --all --exactusingdependency_env.parse_gem_versionsto extract versions fromgem infooutput.HTTP_FETCH, URL handling, andGemVersionstruct no longer needed.Written by Cursor Bugbot for commit fa8aa27. This will update automatically on new commits. Configure here.