File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -1569,9 +1569,25 @@ pub fn run_zvm(ctx: &ExecutionContext) -> Result<()> {
15691569pub fn run_bun ( ctx : & ExecutionContext ) -> Result < ( ) > {
15701570 let bun = require ( "bun" ) ?;
15711571
1572- print_separator ( "Bun" ) ;
1573-
1574- ctx. execute ( bun) . arg ( "upgrade" ) . status_checked ( )
1572+ // From the official install script (both install.sh and install.ps1), Bun uses
1573+ // the path set in this variable as the install root, and its defaults to
1574+ // `$HOME/.bun`
1575+ //
1576+ // UNIX: https://bun.sh/install.sh
1577+ // Windows: https://bun.sh/install.ps1
1578+ let bun_install_env = env:: var ( "BUN_INSTALL" )
1579+ . map ( PathBuf :: from)
1580+ . unwrap_or ( HOME_DIR . join ( ".bun" ) ) ;
1581+
1582+ // If `bun` is a descendant of `bun_install_env`, then Bun is installed
1583+ // through the official script
1584+ if bun. is_descendant_of ( & bun_install_env) {
1585+ print_separator ( "Bun" ) ;
1586+
1587+ ctx. execute ( bun) . arg ( "upgrade" ) . status_checked ( )
1588+ } else {
1589+ Err ( SkipStep ( "Not installed through the official script" . to_string ( ) ) . into ( ) )
1590+ }
15751591}
15761592
15771593pub fn run_zigup ( ctx : & ExecutionContext ) -> Result < ( ) > {
You can’t perform that action at this time.
0 commit comments