Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
fix: use `envconfig.ModelsDir` directly (#4821)
Anatoli Babenia0d16eb310ed2
diff --git a/envconfig/config.go b/envconfig/config.goindex 105b9af6e..62d661ebc 100644--- a/envconfig/config.go+++ b/envconfig/config.go@@ -43,10 +43,10 @@ var (MaxRunners int// Set via OLLAMA_MAX_QUEUE in the environmentMaxQueuedRequests int- // Set via OLLAMA_MODELS in the environment- ModelsDir string// Set via OLLAMA_MAX_VRAM in the environmentMaxVRAM uint64+ // Set via OLLAMA_MODELS in the environment+ ModelsDir string// Set via OLLAMA_NOHISTORY in the environmentNoHistory bool// Set via OLLAMA_NOPRUNE in the environmentdiff --git a/server/modelpath.go b/server/modelpath.goindex 64f59c29a..3fdb4238f 100644--- a/server/modelpath.go+++ b/server/modelpath.go@@ -103,18 +103,9 @@ func (mp ModelPath) GetShortTagname() string {return fmt.Sprintf("%s/%s/%s:%s", mp.Registry, mp.Namespace, mp.Repository, mp.Tag)}-// modelsDir returns the value of the OLLAMA_MODELS environment variable or the user's home directory if OLLAMA_MODELS is not set.-// The models directory is where Ollama stores its model files and manifests.-func modelsDir() (string, error) {- return envconfig.ModelsDir, nil-}-// GetManifestPath returns the path to the manifest file for the given model path, it is up to the caller to create the directory if it does not exist.func (mp ModelPath) GetManifestPath() (string, error) {- dir, err := modelsDir()- if err != nil {- return "", err- }+ dir := envconfig.ModelsDirreturn filepath.Join(dir, "manifests", mp.Registry, mp.Namespace, mp.Repository, mp.Tag), nil}@@ -127,10 +118,7 @@ func (mp ModelPath) BaseURL() *url.URL {}func GetManifestPath() (string, error) {- dir, err := modelsDir()- if err != nil {- return "", err- }+ dir := envconfig.ModelsDirpath := filepath.Join(dir, "manifests")if err := os.MkdirAll(path, 0o755); err != nil {@@ -141,10 +129,7 @@ func GetManifestPath() (string, error) {}func GetBlobsPath(digest string) (string, error) {- dir, err := modelsDir()- if err != nil {- return "", err- }+ dir := envconfig.ModelsDir// only accept actual sha256 digestspattern := "^sha256[:-][0-9a-fA-F]{64}$"