Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

Move ollama executable out of bin dir (#6535)

Daniel Hiltgen93ea9240aee8
diff --git a/app/ollama.iss b/app/ollama.iss
index bce0a337e..34cc5c4cd 100644
--- a/app/ollama.iss
+++ b/app/ollama.iss
@@ -87,7 +87,7 @@ DialogFontSize=12
[Files]
Source: ".\app.exe"; DestDir: "{app}"; DestName: "{#MyAppExeName}" ; Flags: ignoreversion 64bit
-Source: "..\ollama.exe"; DestDir: "{app}\bin"; Flags: ignoreversion 64bit
+Source: "..\ollama.exe"; DestDir: "{app}"; Flags: ignoreversion 64bit
Source: "..\dist\windows-{#ARCH}\lib\ollama\runners\*"; DestDir: "{app}\lib\ollama\runners"; Flags: ignoreversion 64bit recursesubdirs
Source: "..\dist\ollama_welcome.ps1"; DestDir: "{app}"; Flags: ignoreversion
Source: ".\assets\app.ico"; DestDir: "{app}"; Flags: ignoreversion
@@ -99,7 +99,7 @@ Name: "{userstartup}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilen
Name: "{userprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; IconFilename: "{app}\app.ico"
[Run]
-Filename: "{cmd}"; Parameters: "/C set PATH={app}\bin;%PATH% & ""{app}\{#MyAppExeName}"""; Flags: postinstall nowait runhidden
+Filename: "{cmd}"; Parameters: "/C set PATH={app};%PATH% & ""{app}\{#MyAppExeName}"""; Flags: postinstall nowait runhidden
[UninstallRun]
; Filename: "{cmd}"; Parameters: "/C ""taskkill /im ''{#MyAppExeName}'' /f /t"; Flags: runhidden
@@ -134,8 +134,8 @@ SetupAppRunningError=Another Ollama installer is running.%n%nPlease cancel or fi
[Registry]
Root: HKCU; Subkey: "Environment"; \
- ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}\bin"; \
- Check: NeedsAddPath('{app}\bin')
+ ValueType: expandsz; ValueName: "Path"; ValueData: "{olddata};{app}"; \
+ Check: NeedsAddPath('{app}')
[Code]
diff --git a/envconfig/config.go b/envconfig/config.go
index 7e45a4f51..806a2d08f 100644
--- a/envconfig/config.go
+++ b/envconfig/config.go
@@ -190,7 +190,7 @@ func RunnersDir() (p string) {
}
var paths []string
- for _, root := range []string{filepath.Dir(exe), filepath.Join(filepath.Dir(exe), ".."), cwd} {
+ for _, root := range []string{filepath.Dir(exe), filepath.Join(filepath.Dir(exe), LibRelativeToExe()), cwd} {
paths = append(paths,
root,
filepath.Join(root, runtime.GOOS+"-"+runtime.GOARCH),
@@ -282,3 +282,12 @@ func Values() map[string]string {
func Var(key string) string {
return strings.Trim(strings.TrimSpace(os.Getenv(key)), "\"'")
}
+
+// On windows, we keep the binary at the top directory, but
+// other platforms use a "bin" directory, so this returns ".."
+func LibRelativeToExe() string {
+ if runtime.GOOS == "windows" {
+ return "."
+ }
+ return ".."
+}
diff --git a/gpu/amd_common.go b/gpu/amd_common.go
index 72d204f77..2894ac2c4 100644
--- a/gpu/amd_common.go
+++ b/gpu/amd_common.go
@@ -9,6 +9,8 @@ import (
"path/filepath"
"runtime"
"strings"
+
+ "github.com/ollama/ollama/envconfig"
)
// Determine if the given ROCm lib directory is usable by checking for existence of some glob patterns
@@ -54,7 +56,7 @@ func commonAMDValidateLibDir() (string, error) {
// Installer payload location if we're running the installed binary
exe, err := os.Executable()
if err == nil {
- rocmTargetDir := filepath.Join(filepath.Dir(exe), "..", "lib", "ollama")
+ rocmTargetDir := filepath.Join(filepath.Dir(exe), envconfig.LibRelativeToExe(), "lib", "ollama")
if rocmLibUsable(rocmTargetDir) {
slog.Debug("detected ROCM next to ollama executable " + rocmTargetDir)
return rocmTargetDir, nil
diff --git a/gpu/amd_windows.go b/gpu/amd_windows.go
index a0ae7c960..ef6bf830c 100644
--- a/gpu/amd_windows.go
+++ b/gpu/amd_windows.go
@@ -153,7 +153,7 @@ func AMDValidateLibDir() (string, error) {
// Installer payload (if we're running from some other location)
localAppData := os.Getenv("LOCALAPPDATA")
appDir := filepath.Join(localAppData, "Programs", "Ollama")
- rocmTargetDir := filepath.Join(appDir, "..", "lib", "ollama")
+ rocmTargetDir := filepath.Join(appDir, envconfig.LibRelativeToExe(), "lib", "ollama")
if rocmLibUsable(rocmTargetDir) {
slog.Debug("detected ollama installed ROCm at " + rocmTargetDir)
return rocmTargetDir, nil
diff --git a/gpu/gpu.go b/gpu/gpu.go
index 10afb1e3f..3de93f7fc 100644
--- a/gpu/gpu.go
+++ b/gpu/gpu.go
@@ -653,7 +653,7 @@ func LibraryDir() string {
slog.Warn("failed to lookup working directory", "error", err)
}
// Scan for any of our dependeices, and pick first match
- for _, root := range []string{filepath.Dir(appExe), filepath.Join(filepath.Dir(appExe), ".."), cwd} {
+ for _, root := range []string{filepath.Dir(appExe), filepath.Join(filepath.Dir(appExe), envconfig.LibRelativeToExe()), cwd} {
libDep := filepath.Join("lib", "ollama")
if _, err := os.Stat(filepath.Join(root, libDep)); err == nil {
return filepath.Join(root, libDep)
diff --git a/scripts/build_windows.ps1 b/scripts/build_windows.ps1
index 9cebf1f40..eb8570c8f 100644
--- a/scripts/build_windows.ps1
+++ b/scripts/build_windows.ps1
@@ -122,8 +122,8 @@ function buildOllama() {
/csp "Google Cloud KMS Provider" /kc ${env:KEY_CONTAINER} ollama.exe
if ($LASTEXITCODE -ne 0) { exit($LASTEXITCODE)}
}
- New-Item -ItemType Directory -Path .\dist\windows-${script:TARGET_ARCH}\bin\ -Force
- cp .\ollama.exe .\dist\windows-${script:TARGET_ARCH}\bin\
+ New-Item -ItemType Directory -Path .\dist\windows-${script:TARGET_ARCH}\ -Force
+ cp .\ollama.exe .\dist\windows-${script:TARGET_ARCH}\
}
function buildApp() {