[GH-ISSUE #505] Go library fails to compile #46744

Closed
opened 2026-04-27 23:49:52 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @JayNakrani on GitHub (Sep 10, 2023).
Original GitHub issue: https://github.com/ollama/ollama/issues/505

I am trying to use the Ollama Go library in my own project, and running into the following error:

% go build .

../../go/pkg/mod/github.com/jmorganca/ollama@v0.0.18/llm/ggml_llama.go:31:12: pattern llama.cpp/ggml/build/*/bin/*: no matching files found

JayNakrani/ollama-lib-issue repo has the minimal repro code. Filing this issue based on discussion on discord

Originally created by @JayNakrani on GitHub (Sep 10, 2023). Original GitHub issue: https://github.com/ollama/ollama/issues/505 I am trying to use the [Ollama Go library](https://pkg.go.dev/github.com/jmorganca/ollama/server) in my own project, and running into the following error: ```shell % go build . ../../go/pkg/mod/github.com/jmorganca/ollama@v0.0.18/llm/ggml_llama.go:31:12: pattern llama.cpp/ggml/build/*/bin/*: no matching files found ``` [JayNakrani/ollama-lib-issue](https://github.com/JayNakrani/ollama-lib-issue) repo has the minimal repro code. Filing this issue based on [discussion on discord](https://discord.com/channels/1128867683291627614/1128867684130508875/1150556983246721107)
Author
Owner

@JayNakrani commented on GitHub (Sep 10, 2023):

Root cause: The Go library/mod publishing expects the go generate generated code to be checked into the repo, and Ollama repo isn't doing that. So when importing the Go lib, it's not able to find the generated code, and we get the build error.

<!-- gh-comment-id:1712968035 --> @JayNakrani commented on GitHub (Sep 10, 2023): Root cause: The Go library/mod publishing expects the `go generate` generated code to be checked into the repo, and Ollama repo isn't doing that. So when importing the Go lib, it's not able to find the generated code, and we get the build error.
Author
Owner

@JayNakrani commented on GitHub (Sep 11, 2023):

Ok, so I went down a rabbithole and tried a bunch of different solutions. Below is a summary of them all

# Approach Status Notes
1 Import Ollama go library Does not work because of https://github.com/jmorganca/ollama/issues/505#issuecomment-1712968035
2 Git Subtree + Go Vendor Subtree does not work because the Ollama repo has own submodules, and git subtree doesn't seem to gel well with submodule
3 Git submodule + Go Vendor Can't get all vendor deps through go mod vendor -- stops at trying to vendor out the llm due to missing generated files. The "add-submodule followed by go mod vendor" doesn't work either becaue go mod vendor overrides the added submodule!
4 Fork Ollama & check-in generated binaries to get own working Go library The generated files are under ggml -- a submodule of Ollama repo. We'd need to do clone the ggml/llama.cpp and do own submodule in forked repos!
5 Thin proxy server around ollama serve TBD Have been trying to avoid this because it means having to ship yet another binary! But may be there is no way around it!
<!-- gh-comment-id:1713063700 --> @JayNakrani commented on GitHub (Sep 11, 2023): Ok, so I went down a rabbithole and tried a bunch of different solutions. Below is a summary of them all | # | Approach | Status | Notes | |--------|-----------------------------------------------------------------------------------|--------|-------------------------------------------------------------------------------------------------| | 1 | Import [Ollama go library](https://pkg.go.dev/github.com/jmorganca/ollama/server) | ❌ | Does not work because of https://github.com/jmorganca/ollama/issues/505#issuecomment-1712968035 | | 2 | Git Subtree + Go Vendor | ❌ | Subtree does not work because the Ollama repo has own submodules, and git subtree doesn't seem to gel well with submodule | | 3 | Git submodule + Go Vendor | ❌ | Can't get all vendor deps through `go mod vendor` -- stops at trying to vendor out the [`llm`](https://github.com/jmorganca/ollama/tree/main/llm) due to missing generated files. The "add-submodule followed by `go mod vendor`" doesn't work either becaue `go mod vendor` overrides the added submodule! | | 4 | Fork Ollama & check-in generated binaries to get own working Go library | ❌ | The [generated files are under ggml](https://github.com/ggerganov/llama.cpp/blob/9e232f0234073358e7031c1b8d7aa45020469a3b/.gitignore#L16) -- a submodule of Ollama repo. We'd need to do clone the ggml/llama.cpp and do own submodule in forked repos! | | 5 | Thin proxy server around `ollama serve` | TBD | Have been trying to avoid this because it means having to ship yet another binary! But may be there is no way around it! |
Author
Owner

@mxyng commented on GitHub (Sep 11, 2023):

Ollama is not meant to be used as a library. Any suggestion otherwise is unintentional and unsupported. I suggest installing ollama and using the API

<!-- gh-comment-id:1714332650 --> @mxyng commented on GitHub (Sep 11, 2023): Ollama is not meant to be used as a library. Any suggestion otherwise is unintentional and unsupported. I suggest installing ollama and using the API
Author
Owner

@scenaristeur commented on GitHub (Oct 3, 2023):

Ollama is not meant to be used as a library. Any suggestion otherwise is unintentional and unsupported. I suggest installing ollama and using the API

i don't understand your answer : There is a ollama app folder saying to build the lib https://github.com/jmorganca/ollama/blob/main/app/README.md

<!-- gh-comment-id:1745481274 --> @scenaristeur commented on GitHub (Oct 3, 2023): > Ollama is not meant to be used as a library. Any suggestion otherwise is unintentional and unsupported. I suggest installing ollama and using the API i don't understand your answer : There is a ollama app folder saying to build the lib https://github.com/jmorganca/ollama/blob/main/app/README.md
Author
Owner

@JayNakrani commented on GitHub (Oct 3, 2023):

I think what @mxyng meant to say is that they did not mean to export it as a separate Go library. Because the router handler names start with a capital letter, they were automatically picked up as a Go library even though that wasn't the original intention.

<!-- gh-comment-id:1745494763 --> @JayNakrani commented on GitHub (Oct 3, 2023): I think what @mxyng meant to say is that they did not mean to export it as a separate Go library. Because the router handler names start with a capital letter, they were automatically picked up as a Go library even though that wasn't the original intention.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#46744