Narrow set of paths we load GGML from (#10485)

Users may have other incompatible GGML installs on their systems.
This will prevent us from trying to load them from the path.
This commit is contained in:
Daniel Hiltgen
2025-04-30 11:25:22 -07:00
committed by GitHub
parent 421b7edeb4
commit 718eda1b3e
2 changed files with 10 additions and 11 deletions

View File

@@ -57,26 +57,20 @@ var OnceLoad = sync.OnceFunc(func() {
exe = "."
}
// PATH, LD_LIBRARY_PATH, and DYLD_LIBRARY_PATH are often
// set by the parent process, however, use a default value
// if the environment variable is not set.
var name, value string
var value string
switch runtime.GOOS {
case "darwin":
// On macOS, DYLD_LIBRARY_PATH is often not set, so
// we use the directory of the executable as the default.
name = "DYLD_LIBRARY_PATH"
value = filepath.Dir(exe)
case "windows":
name = "PATH"
value = filepath.Join(filepath.Dir(exe), "lib", "ollama")
default:
name = "LD_LIBRARY_PATH"
value = filepath.Join(filepath.Dir(exe), "..", "lib", "ollama")
}
paths, ok := os.LookupEnv(name)
// Avoid potentially loading incompatible GGML libraries
paths, ok := os.LookupEnv("OLLAMA_LIBRARY_PATH")
if !ok {
slog.Debug("OLLAMA_LIBRARY_PATH not set, falling back to default", "search", value)
paths = value
}