Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
x/imagegen: respect OLLAMA_MODELS for manifests and blobs (#13797)
next-nd6dd430abd6b
diff --git a/x/imagegen/manifest.go b/x/imagegen/manifest.goindex 3b3006779..f662915ee 100644--- a/x/imagegen/manifest.go+++ b/x/imagegen/manifest.go@@ -6,8 +6,9 @@ import ("io""os""path/filepath"- "runtime""strings"++ "github.com/ollama/ollama/envconfig")// ManifestLayer represents a layer in the manifest.@@ -32,31 +33,15 @@ type ModelManifest struct {BlobDir string}-// DefaultBlobDir returns the default blob storage directory.func DefaultBlobDir() string {- home, err := os.UserHomeDir()- if err != nil {- home = "."- }- switch runtime.GOOS {- case "darwin":- return filepath.Join(home, ".ollama", "models", "blobs")- case "linux":- return filepath.Join(home, ".ollama", "models", "blobs")- case "windows":- return filepath.Join(home, ".ollama", "models", "blobs")- default:- return filepath.Join(home, ".ollama", "models", "blobs")- }+ return filepath.Join(envconfig.Models(), "blobs")}-// DefaultManifestDir returns the default manifest storage directory.+// DefaultManifestDir returns the manifest storage directory.+// Respects OLLAMA_MODELS.+func DefaultManifestDir() string {- home, err := os.UserHomeDir()- if err != nil {- home = "."- }- return filepath.Join(home, ".ollama", "models", "manifests")+ return filepath.Join(envconfig.Models(), "manifests")}// LoadManifest loads a manifest for the given model name.diff --git a/x/imagegen/manifest_test.go b/x/imagegen/manifest_test.gonew file mode 100644index 000000000..a387d272c--- /dev/null+++ b/x/imagegen/manifest_test.go@@ -0,0 +1,26 @@+package imagegen++import (+ "path/filepath"+ "testing"+)++func TestManifestAndBlobDirsRespectOLLAMAModels(t *testing.T) {+ modelsDir := filepath.Join(t.TempDir(), "models")++ // Simulate packaged/systemd environment+ t.Setenv("OLLAMA_MODELS", modelsDir)+ t.Setenv("HOME", "/usr/share/ollama")++ // Manifest dir must respect OLLAMA_MODELS+ wantManifest := filepath.Join(modelsDir, "manifests")+ if got := DefaultManifestDir(); got != wantManifest {+ t.Fatalf("DefaultManifestDir() = %q, want %q", got, wantManifest)+ }++ // Blob dir must respect OLLAMA_MODELS+ wantBlobs := filepath.Join(modelsDir, "blobs")+ if got := DefaultBlobDir(); got != wantBlobs {+ t.Fatalf("DefaultBlobDir() = %q, want %q", got, wantBlobs)+ }+}