Skip to content

fix: auto-bootstrap root.json and create bin dir on first run#2709

Open
yahonda wants to merge 2 commits into
pingcap:masterfrom
yahonda:fix/auto-bootstrap-root-json
Open

fix: auto-bootstrap root.json and create bin dir on first run#2709
yahonda wants to merge 2 commits into
pingcap:masterfrom
yahonda:fix/auto-bootstrap-root-json

Conversation

@yahonda

@yahonda yahonda commented Jun 4, 2026

Copy link
Copy Markdown
Member

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:

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.

What is changed and how it works?

This PR 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.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Code changes

  • Has exported function/method change
  • Has exported variable/fields change
  • Has interface methods change
  • Has persistent data change

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

@ti-chi-bot

ti-chi-bot Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign bb7133 for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot requested review from breezewish and nexustar June 4, 2026 06:03
@ti-chi-bot ti-chi-bot Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 4, 2026
@codecov-commenter

codecov-commenter commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 15.38462% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.29%. Comparing base (9bdae04) to head (86ccffc).

Files with missing lines Patch % Lines
pkg/environment/env.go 18.18% 8 Missing and 1 partial ⚠️
pkg/localdata/profile.go 0.00% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.
@yahonda yahonda force-pushed the fix/auto-bootstrap-root-json branch from 7a31234 to 22ab2e7 Compare June 4, 2026 06:52
@ti-chi-bot ti-chi-bot Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 4, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants