diff --git a/cmd/commands/env.go b/cmd/commands/env.go index 83470d8d..9962919a 100644 --- a/cmd/commands/env.go +++ b/cmd/commands/env.go @@ -85,7 +85,7 @@ func outputJSON() error { } tvs.FilterTools(func(name, version string) bool { if lookupSdk, err := manager.LookupSdk(name); err == nil { - if keys, err := lookupSdk.EnvKeys(internal.Version(version), internal.ShellLocation); err == nil { + if keys, err := lookupSdk.EnvKeys(internal.Version(version), internal.OriginalLocation); err == nil { data.SDKs[lookupSdk.Plugin.Name] = keys.Variables data.Paths = append(data.Paths, keys.Paths.Slice()...) return true diff --git a/internal/sdk.go b/internal/sdk.go index 87462ae0..e5a06773 100644 --- a/internal/sdk.go +++ b/internal/sdk.go @@ -705,12 +705,6 @@ func (b *Sdk) label(version Version) string { func (b *Sdk) ClearCurrentEnv() error { current := b.Current() - fmt.Println("Cleaning up current link...") - curPath := filepath.Join(b.InstallPath, "current") - if err := os.RemoveAll(curPath); err != nil { - return fmt.Errorf("failed to remove current link, err:%w", err) - } - if current != "" { envKeys, err := b.MockEnvKeys(current, GlobalLocation) if err != nil { @@ -739,6 +733,12 @@ func (b *Sdk) ClearCurrentEnv() error { _ = envManager.Flush() } + fmt.Println("Cleaning up current link...") + curPath := filepath.Join(b.InstallPath, "current") + if err := os.RemoveAll(curPath); err != nil { + return fmt.Errorf("failed to remove current link, err:%w", err) + } + // clear tool versions toolVersion, err := toolset.NewMultiToolVersions([]string{ b.sdkManager.PathMeta.CurTmpPath,