diff --git a/cmd/helm/installer/init.go b/cmd/helm/installer/init.go index 52ecdd4e2..9e5d1e1e5 100644 --- a/cmd/helm/installer/init.go +++ b/cmd/helm/installer/init.go @@ -87,7 +87,8 @@ func ensureDefaultRepos(home helmpath.Home, out io.Writer, skipRefresh bool, set if fi, err := os.Stat(repoFile); err != nil { fmt.Fprintf(out, "Creating %s \n", repoFile) f := repo.NewRepoFile() - // the cache path is prepended to all relative paths, for backwards compatibility, we must be relative to the cache directory + // The cache path is prepended to all relative paths. + // For backwards compatibility, the repo path must be relative to the cache directory sif, err := filepath.Rel(home.Cache(), home.CacheIndex(stableRepository)) if err != nil { return err @@ -96,6 +97,7 @@ func ensureDefaultRepos(home helmpath.Home, out io.Writer, skipRefresh bool, set if err != nil { return err } + // Same for local repo path. lif, err := filepath.Rel(home.Cache(), home.CacheIndex("local")) if err != nil { return err @@ -131,9 +133,7 @@ func initStableRepo(cacheFile string, home helmpath.Home, out io.Writer, skipRef return &c, nil } - // In this case, the cacheFile is always absolute. So passing empty string - // is safe. - if err := r.DownloadIndexFile(""); err != nil { + if err := r.DownloadIndexFile(home.Cache()); err != nil { return nil, fmt.Errorf("Looks like %q is not a valid chart repository or cannot be reached: %s", stableRepositoryURL, err.Error()) } diff --git a/cmd/helm/repo_add.go b/cmd/helm/repo_add.go index 1d068f3e2..d446415ea 100644 --- a/cmd/helm/repo_add.go +++ b/cmd/helm/repo_add.go @@ -111,6 +111,8 @@ func addRepository(name, url, username, password string, home helmpath.Home, cer return fmt.Errorf("repository name (%s) already exists, please specify a different name", name) } + // The cache path is prepended to all relative paths. + // For backwards compatibility, the repo path must be relative to the cache directory cif, err := filepath.Rel(home.Cache(), home.CacheIndex(name)) if err != nil { return err