llm: attempt to evaluate symlinks, but do not fail (#9089)

provides a better approach to #9088 that will attempt to
evaluate symlinks (important for macOS where 'ollama' is
often a symlink), but use the result of os.Executable()
as a fallback in scenarios where filepath.EvalSymlinks
fails due to permission erorrs or other issues
This commit is contained in:
Jeffrey Morgan
2025-02-13 22:37:59 -08:00
committed by GitHub
parent f05774b04c
commit 5296f487a8
2 changed files with 8 additions and 0 deletions

View File

@@ -19,6 +19,10 @@ var LibOllamaPath string = func() string {
return ""
}
if eval, err := filepath.EvalSymlinks(exe); err == nil {
exe = eval
}
var libPath string
switch runtime.GOOS {
case "windows":

View File

@@ -320,6 +320,10 @@ func NewLlamaServer(gpus discover.GpuInfoList, model string, f *ggml.GGML, adapt
return nil, fmt.Errorf("unable to lookup executable path: %w", err)
}
if eval, err := filepath.EvalSymlinks(exe); err == nil {
exe = eval
}
// TODO - once fully switched to the Go runner, load the model here for tokenize/detokenize cgo access
s := &llmServer{
port: port,