fix: auto-bootstrap root.json and create bin dir on first run#2709
fix: auto-bootstrap root.json and create bin dir on first run#2709yahonda wants to merge 2 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2709 +/- ##
==========================================
- Coverage 42.72% 42.29% -0.43%
==========================================
Files 424 424
Lines 49744 47155 -2589
==========================================
- Hits 21253 19943 -1310
+ Misses 25797 24512 -1285
- Partials 2694 2700 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
When tiup is installed via mise (https://mise.jdx.dev, a polyglot tool version manager similar to asdf) with: mise install github:pingcap/tiup mise use -g github:pingcap/tiup the install.sh script is not executed, which means: 1. ~/.tiup/bin/ directory is not created 2. root.json is not downloaded from the mirror This leaves the installation incomplete and requires the user to manually run 'tiup mirror set' before any tiup command works. This patch fixes both issues: - ResetMirror now ensures the bin directory exists before writing root.json - InitEnv automatically bootstraps root.json from the default mirror if it's missing, so no manual 'tiup mirror set' is needed In the future, we would like to register tiup in the mise registry so that users can simply run: mise install tiup mise use tiup This fix is a prerequisite for that, as it removes the need for any post-install initialization steps.
7a31234 to
22ab2e7
Compare
…mment After aliasing the pingcap/errors import to perrs (to free the name for the stdlib errors used by errors.Is), the package-level ErrInstallFirst sentinel silently switched to stdlib errors.New. Use perrs.New to preserve the prior behavior. Also reword the bootstrap comment: a present-but-corrupt root.json never yields ErrLoadManifest, so the os.Stat guard actually covers the exists-but-unreadable case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
What problem does this PR solve?
When tiup is installed via mise (https://mise.jdx.dev, a polyglot tool version manager similar to asdf) with:
the install.sh script is not executed, which means:
This leaves the installation incomplete and requires the user to manually run 'tiup mirror set' before any tiup command works.
What is changed and how it works?
This PR fixes both issues:
In the future, we would like to register tiup in the mise registry so that users can simply run:
This fix is a prerequisite for that, as it removes the need for any post-install initialization steps.
Check List
Tests
Code changes
Side effects
Related changes