Skip to content

Commit 2bbfaf5

Browse files
authored
Fix default local cache location (#204)
1 parent 5e2799b commit 2bbfaf5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

cmd/build.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,13 @@ func getBuildOpts(cmd *cobra.Command) ([]leeway.BuildOption, cache.LocalCache) {
211211
} else {
212212
localCacheLoc = os.Getenv(leeway.EnvvarCacheDir)
213213
if localCacheLoc == "" {
214-
localCacheLoc = filepath.Join(os.TempDir(), "cache")
214+
localCacheLoc = filepath.Join(os.TempDir(), "leeway", "cache")
215215
}
216216
}
217+
// Ensure cache directory exists with proper permissions
218+
if err := os.MkdirAll(localCacheLoc, 0755); err != nil {
219+
log.WithError(err).Fatal("failed to create cache directory")
220+
}
217221
log.WithField("location", localCacheLoc).Debug("set up local cache")
218222
localCache, err := local.NewFilesystemCache(localCacheLoc)
219223
if err != nil {

pkg/leeway/build.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ func newBuildContext(options buildOptions) (ctx *buildContext, err error) {
120120

121121
buildDir := os.Getenv(EnvvarBuildDir)
122122
if buildDir == "" {
123-
buildDir = filepath.Join(os.TempDir(), "build")
123+
buildDir = filepath.Join(os.TempDir(), "leeway", "build")
124+
}
125+
126+
// Ensure cache directory exists with proper permissions
127+
if err := os.MkdirAll(buildDir, 0755); err != nil {
128+
log.WithError(err).Fatal("failed to create build directory")
124129
}
125130

126131
var buildLimit *semaphore.Weighted

0 commit comments

Comments
 (0)