diff --git a/studio/setup.ps1 b/studio/setup.ps1 index f323a6bf2..2dd52d36b 100644 --- a/studio/setup.ps1 +++ b/studio/setup.ps1 @@ -1827,11 +1827,18 @@ 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. +# Canonicalize BOTH sides. $StudioHome is the resolved env-override path +# in env-mode (line 1474) but the bare logical path in default mode +# (line 1480). Canonicalizing on the fly handles a junctioned/symlinked +# %USERPROFILE% the same in both modes. +$_studioHomeCanon = $StudioHome +if (Test-Path -LiteralPath $_studioHomeCanon -PathType Container) { + $_studioHomeCanon = (Resolve-Path -LiteralPath $_studioHomeCanon).Path +} if (Test-Path -LiteralPath $LegacyStudioHome -PathType Container) { $LegacyStudioHome = (Resolve-Path -LiteralPath $LegacyStudioHome).Path } -if ($StudioHome -eq $LegacyStudioHome) { +if ($_studioHomeCanon -eq $LegacyStudioHome) { $UnslothHome = Join-Path $env:USERPROFILE ".unsloth" } else { $UnslothHome = $StudioHome diff --git a/studio/setup.sh b/studio/setup.sh index 86f66f190..affcc5683 100755 --- a/studio/setup.sh +++ b/studio/setup.sh @@ -575,14 +575,21 @@ 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. +# Canonicalize BOTH sides under symlinked $HOME. STUDIO_HOME is logical +# in default-mode (line 416 sets it from the bare $HOME path) and +# canonical in env-mode (line 413 uses pwd -P). Canonicalizing on the +# fly here means default-mode under symlinked $HOME still recognizes +# the legacy default and keeps llama.cpp at ~/.unsloth/llama.cpp. +_studio_home_canon="$STUDIO_HOME" +if [ -d "$_studio_home_canon" ]; then + _studio_home_canon=$(CDPATH= cd -P -- "$_studio_home_canon" 2>/dev/null && pwd -P) \ + || _studio_home_canon="$STUDIO_HOME" +fi 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 +if [ "$_studio_home_canon" = "$_LEGACY_STUDIO_HOME" ]; then UNSLOTH_HOME="$HOME/.unsloth" else UNSLOTH_HOME="$STUDIO_HOME"