@@ -210,18 +210,22 @@ export class MiseService {
210210 const hasValidMiseVersion = await this . hasValidMiseVersion ( ) ;
211211 if ( ! hasValidMiseVersion ) {
212212 const canSelfUpdate = await this . canSelfUpdate ( ) ;
213+ const isSelfUpdateDisabled = await this . isSelfUpdateDisabled ( ) ;
214+
213215 const selection = await vscode . window . showErrorMessage (
214216 `Mise version ${ version } is not supported. Please update to a supported version.` ,
215217 { modal : true } ,
216- canSelfUpdate ? "Run mise self-update" : "open mise website" ,
218+ canSelfUpdate && ! isSelfUpdateDisabled
219+ ? "Run mise self-update"
220+ : "open mise website" ,
217221 ) ;
218222 this . hasVerifiedMiseVersion = true ;
219223 if ( selection === "Run mise self-update" ) {
220224 await this . runMiseToolActionInConsole ( "self-update -y" ) ;
221225 }
222226 if ( selection === "open mise website" ) {
223227 await vscode . env . openExternal (
224- vscode . Uri . parse ( "https://mise.jdx.dev/cli/self-update .html" ) ,
228+ vscode . Uri . parse ( "https://mise.jdx.dev/installing-mise .html" ) ,
225229 ) ;
226230 }
227231 }
@@ -774,6 +778,7 @@ export class MiseService {
774778 return [ year , minor , patch ] as [ number , number , number ] ;
775779 }
776780
781+ // Checks whether the mise binary has the self-update command
777782 async canSelfUpdate ( ) {
778783 if ( ! this . getMiseBinaryPath ( ) ) {
779784 return false ;
@@ -787,6 +792,47 @@ export class MiseService {
787792 }
788793 }
789794
795+ // Checks for the presence of the `.disable-self-update` sentinel file in the Mise lib
796+ // dir, to determine if self-update is disabled (ie installed using a package manager).
797+ // It's a re-implementation of the `is_available()` function from `SelfUpdate`.
798+ // https://github.com/jdx/mise/blob/863505d4089126780c2352fb1218c6550c3cf9d8/src/cli/self_update.rs#L100
799+ isSelfUpdateDisabled ( ) : boolean {
800+ logger . info ( "Checking if self-update is disabled..." ) ;
801+ try {
802+ const miseBinPath = this . getMiseBinaryPath ( ) ;
803+ logger . info ( `miseBinPath: ${ miseBinPath } ` ) ;
804+ if ( ! miseBinPath ) {
805+ return false ; // Default to allowing self-update if we can't determine the path
806+ }
807+
808+ // Get canonical path of the mise binary
809+ const canonicalPath = require ( "node:fs" ) . realpathSync ( miseBinPath ) ;
810+
811+ // Get parent directory, then parent of that (two levels up)
812+ const parentDir = path . dirname ( canonicalPath ) ;
813+ const grandParentDir = path . dirname ( parentDir ) ;
814+
815+ // Check for sentinel files that disable self-update
816+ const disablePaths = [
817+ path . join ( grandParentDir , "lib" , ".disable-self-update" ) , // kept for compatibility
818+ path . join ( grandParentDir , "lib" , "mise" , ".disable-self-update" ) ,
819+ ] ;
820+
821+ for ( const disablePath of disablePaths ) {
822+ if ( existsSync ( disablePath ) ) {
823+ logger . info ( `Self-update disabled by sentinel file: ${ disablePath } ` ) ;
824+ return true ;
825+ }
826+ }
827+
828+ return false ;
829+ } catch ( error ) {
830+ // If filesystem operations fail, fall back to allowing self-update
831+ logger . debug ( `Failed to check for self-update disable files: ${ error } ` ) ;
832+ return false ;
833+ }
834+ }
835+
790836 async hasValidMiseVersion ( ) {
791837 if ( ! this . getMiseBinaryPath ( ) ) {
792838 return false ;
@@ -822,6 +868,12 @@ export class MiseService {
822868 }
823869
824870 const canSelfUpdate = await this . canSelfUpdate ( ) ;
871+ const isSelfUpdateDisabled = await this . isSelfUpdateDisabled ( ) ;
872+
873+ if ( isSelfUpdateDisabled ) {
874+ return ;
875+ }
876+
825877 const suggestion = await vscode . window . showInformationMessage (
826878 `New Mise version available ${ newMiseVersionAvailable ?. latestVersion } . (Current: ${ newMiseVersionAvailable ?. currentVersion } )` ,
827879 canSelfUpdate ? "Update Mise" : "How to update Mise" ,
0 commit comments