[GH-ISSUE #8353] FROM path resolution uses working directory instead of Modelfile location #51866

Closed
opened 2026-04-28 21:05:16 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @BruceMacD on GitHub (Jan 8, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/8353

Originally assigned to: @pdevine on GitHub.

What is the issue?

Description:
When using a relative path in a FROM statement within a Modelfile, the path is resolved relative to the current working directory where the ollama command is executed, rather than relative to the Modelfile's location. This makes it difficult to create portable Modelfiles that reference local files, as they break when run from different directories.
Example to reproduce:

# Directory structure:
my-project/
  ├── models/
  │   └── base.txt
  └── custom/
      └── Modelfile  # Contains: FROM ../models/base.txt

# Running from project root works:
cd my-project
ollama create mymodel -f custom/Modelfile  # ✓

# Running from custom/ directory fails:
cd my-project/custom
ollama create mymodel -f Modelfile  # ✗ Error: pull model manifest: file does not exist

Expected behavior:

Relative paths in FROM statements should be resolved relative to the Modelfile's location
This would allow Modelfiles to reliably reference files in their parent/sibling directories regardless of where the ollama command is run from

Current behavior:

Paths are resolved relative to the current working directory where ollama is executed
Makes Modelfiles less portable as they break when run from different directories
Requires users to always run ollama from a specific directory or use absolute paths

Ollama version

Development on main branch

Originally created by @BruceMacD on GitHub (Jan 8, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/8353 Originally assigned to: @pdevine on GitHub. ### What is the issue? **Description:** When using a relative path in a FROM statement within a Modelfile, the path is resolved relative to the current working directory where the ollama command is executed, rather than relative to the Modelfile's location. This makes it difficult to create portable Modelfiles that reference local files, as they break when run from different directories. Example to reproduce: ``` # Directory structure: my-project/ ├── models/ │ └── base.txt └── custom/ └── Modelfile # Contains: FROM ../models/base.txt # Running from project root works: cd my-project ollama create mymodel -f custom/Modelfile # ✓ # Running from custom/ directory fails: cd my-project/custom ollama create mymodel -f Modelfile # ✗ Error: pull model manifest: file does not exist ``` **Expected behavior:** Relative paths in FROM statements should be resolved relative to the Modelfile's location This would allow Modelfiles to reliably reference files in their parent/sibling directories regardless of where the ollama command is run from **Current behavior:** Paths are resolved relative to the current working directory where ollama is executed Makes Modelfiles less portable as they break when run from different directories Requires users to always run ollama from a specific directory or use absolute paths ### Ollama version Development on main branch
GiteaMirror added the bug label 2026-04-28 21:05:16 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#51866