diff --git a/install.ps1 b/install.ps1 index 336eb55a2f..f7805e091d 100644 --- a/install.ps1 +++ b/install.ps1 @@ -460,6 +460,12 @@ function Install-UnslothStudio { # legacy default, llama.cpp still lives at ~/.unsloth/llama.cpp. # Keep the persisted UNSLOTH_LLAMA_CPP_PATH consistent with that. $_legacyStudio = Join-Path $env:USERPROFILE ".unsloth\studio" + # Canonicalize the legacy side (when it exists) to match the + # resolved $StudioHome from the env-override path. This keeps + # the legacy-equality check stable across path normalization. + if (Test-Path -LiteralPath $_legacyStudio -PathType Container) { + $_legacyStudio = (Resolve-Path -LiteralPath $_legacyStudio).Path + } $_llamaPath = if ($StudioHome -eq $_legacyStudio) { Join-Path $env:USERPROFILE ".unsloth\llama.cpp" } else { diff --git a/install.sh b/install.sh index da83a9eb80..5e42b4f58d 100755 --- a/install.sh +++ b/install.sh @@ -692,7 +692,15 @@ LAUNCHER_EOF # happens to point at the legacy default, llama.cpp still lives # at ~/.unsloth/llama.cpp (one shared build across legacy # installs) -- keep UNSLOTH_LLAMA_CPP_PATH consistent with that. + # $STUDIO_HOME is canonicalized (cycle 24) but $HOME/.unsloth/studio + # is still logical. Canonicalize the legacy side too so a symlinked + # $HOME doesn't make the comparison fail when both point at the + # same dir. _css_legacy_studio="$HOME/.unsloth/studio" + if [ -d "$_css_legacy_studio" ]; then + _css_legacy_studio=$(CDPATH= cd -P -- "$_css_legacy_studio" 2>/dev/null && pwd -P) \ + || _css_legacy_studio="$HOME/.unsloth/studio" + fi if [ "$STUDIO_HOME" = "$_css_legacy_studio" ]; then _css_llama_path="$HOME/.unsloth/llama.cpp" else diff --git a/studio/setup.ps1 b/studio/setup.ps1 index 7c54891257..f323a6bf2f 100644 --- a/studio/setup.ps1 +++ b/studio/setup.ps1 @@ -1827,6 +1827,10 @@ step "transformers" "5.5.0 pre-installed" # stale UNSLOTH_STUDIO_HOME pointing at the legacy default does not # accidentally relocate llama.cpp. $LegacyStudioHome = Join-Path $env:USERPROFILE ".unsloth\studio" +# Canonicalize the legacy side to match $StudioHome's normalized form. +if (Test-Path -LiteralPath $LegacyStudioHome -PathType Container) { + $LegacyStudioHome = (Resolve-Path -LiteralPath $LegacyStudioHome).Path +} if ($StudioHome -eq $LegacyStudioHome) { $UnslothHome = Join-Path $env:USERPROFILE ".unsloth" } else { diff --git a/studio/setup.sh b/studio/setup.sh index 99740752ba..86f66f1909 100755 --- a/studio/setup.sh +++ b/studio/setup.sh @@ -575,6 +575,13 @@ fi # of env-var presence avoids regressing default installs that incidentally # inherit UNSLOTH_STUDIO_HOME from a parent process or the CLI. _LEGACY_STUDIO_HOME="$HOME/.unsloth/studio" +# Canonicalize the legacy side so a symlinked $HOME doesn't make the +# comparison fail when STUDIO_HOME (already canonicalized) and the +# legacy path point at the same directory. +if [ -d "$_LEGACY_STUDIO_HOME" ]; then + _LEGACY_STUDIO_HOME=$(CDPATH= cd -P -- "$_LEGACY_STUDIO_HOME" 2>/dev/null && pwd -P) \ + || _LEGACY_STUDIO_HOME="$HOME/.unsloth/studio" +fi if [ "$STUDIO_HOME" = "$_LEGACY_STUDIO_HOME" ]; then UNSLOTH_HOME="$HOME/.unsloth" else