diff --git a/pkg/cluster/spec/profile.go b/pkg/cluster/spec/profile.go index cf852cb2e7..7ad4ba7c5d 100644 --- a/pkg/cluster/spec/profile.go +++ b/pkg/cluster/spec/profile.go @@ -59,14 +59,19 @@ var initialized = false // The directory will be created before return if it does not already exist. func Initialize(base string) error { tiupData := os.Getenv(tiuplocaldata.EnvNameComponentDataDir) - if tiupData == "" { + tiupHome := os.Getenv(tiuplocaldata.EnvNameHome) + + switch { + case tiupData != "": + profileDir = tiupData + case tiupHome != "": + profileDir = path.Join(tiupHome, tiuplocaldata.StorageParentDir, base) + default: homeDir, err := getHomeDir() if err != nil { return errors.Trace(err) } profileDir = path.Join(homeDir, ".tiup", tiuplocaldata.StorageParentDir, base) - } else { - profileDir = tiupData } clusterBaseDir := filepath.Join(profileDir, TiUPClusterDir)