-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 Corepack install failure by activating local package manager fallback #11484
Conversation
rescue SharedHelpers::HelperSubprocessFailed => e | ||
Dependabot.logger.error("Error installing #{name}@#{version}: #{e.message}") | ||
Helpers.fallback_to_local_version(name) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Tip: Implement a fallback mechanism to activate the local package manager if corepack
installation fails.
5baf649
to
c197736
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@@ -467,6 +467,8 @@ def self.install(name, version, env: {}) | |||
# Attempt to activate the local version of the package manager | |||
sig { params(name: String).void } | |||
def self.fallback_to_local_version(name) | |||
return "Corepack does not support #{name}" unless corepack_supported_package_manager?(name) | |||
|
|||
Dependabot.logger.info("Falling back to activate the currently installed version of #{name}.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to get test coverage for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, I just saw your message.
We have spec for fallback case shared in the reference link. Regarding the bun
condition, I added it as a precaution in case it gets called. Since @markhallen checks for other commands, I wanted to ensure it doesn’t unintentionally affect bun
.
If needed, I can create another PR to add specs for:
return "Corepack does not support #{name}" unless corepack_supported_package_manager?(name)
Let me know if you think this is necessary.
Reference: [helpers_spec.rb#L314](https://github.com/dependabot/dependabot-core/blob/main/npm_and_yarn/spec/dependabot/npm_and_yarn/helpers_spec.rb#L314)
What are you trying to accomplish?
The
fetch_files
phase was failing due to a Corepack installation issue withpnpm
. The error stemmed from an inability to verify the package manager's signature when installing[email protected]
. This caused the entire process to fail.This PR addresses the issue by activating the local package manager as a fallback when Corepack installation fails. This ensures that Dependabot can proceed with file fetching even if Corepack encounters verification issues.
Anything you want to highlight for special attention from reviewers?
pnpm
installation and instead allow Dependabot to use an already available version.How will you know you've accomplished your goal?
fetch_files
phase due topnpm
installation issues.bin/run fetch_files
now completes successfully without encounteringfile_fetcher_error
.Checklist