Skip to content

Commit

Permalink
llm: attempt to evaluate symlinks, but do not fail (ollama#9089)
Browse files Browse the repository at this point in the history
provides a better approach to ollama#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
  • Loading branch information
jmorganca authored Feb 14, 2025
1 parent f05774b commit 5296f48
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions discover/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
4 changes: 4 additions & 0 deletions llm/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5296f48

Please sign in to comment.