[GH-ISSUE #429] Why does Ollama need sudo? #198

Closed
opened 2026-04-12 09:43:30 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @vegabook on GitHub (Aug 27, 2023).
Original GitHub issue: https://github.com/ollama/ollama/issues/429

I run nix on my mac to isolate all software.

nix-shell -p ollama works great since ollama is available on the unstable channel.

Works perfectly if I sudo both the server, and the client:

image

But if either client or server is not run as superuser, then either errors out or doesn't work.

image

I note that because I have to be root, the ~/.ollama directory is also owned by root.

Is there a reason we can't run the whole stack in userspace? Having to sudo inhibits some automation and isolation options. Alternatively using the installer, clutters up process space with yet another background task, and also forces a toolbar icon.

Originally created by @vegabook on GitHub (Aug 27, 2023). Original GitHub issue: https://github.com/ollama/ollama/issues/429 I run nix on my mac to isolate all software. `nix-shell -p ollama` works great since ollama is [available on the unstable channel](https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=ollama). Works perfectly if I sudo both the server, and the client: <img width="1392" alt="image" src="https://github.com/jmorganca/ollama/assets/3780883/0ea353d9-5303-4cd6-a684-2ead9c1baca2"> But if either client or server is _not_ run as superuser, then either errors out or doesn't work. <img width="656" alt="image" src="https://github.com/jmorganca/ollama/assets/3780883/adf4fb21-a7d6-4c5a-8b23-99a890619b62"> I note that because I have to be root, the ~/.ollama directory is also owned by root. Is there a reason we can't run the whole stack in userspace? Having to `sudo` inhibits some automation and isolation options. Alternatively using the installer, clutters up process space with yet another background task, and also forces a toolbar icon.
Author
Owner

@mxyng commented on GitHub (Aug 27, 2023):

There's no reason ollama needs sudo in runtime. The only occurrence of sudo or any form of elevated privileges is during install when the MacOS app installs the ollama binary to /usr/local/bin. Can you check the ownership of ~/.ollama and ensure it and any children are owned by your user then retry without sudo?

<!-- gh-comment-id:1694642023 --> @mxyng commented on GitHub (Aug 27, 2023): There's no reason ollama needs `sudo` in runtime. The only occurrence of `sudo` or any form of elevated privileges is during install when the MacOS app installs the ollama binary to `/usr/local/bin`. Can you check the ownership of `~/.ollama` and ensure it and any children are owned by your user then retry without `sudo?`
Author
Owner

@vegabook commented on GitHub (Aug 27, 2023):

There's no reason ollama needs sudo in runtime. The only occurrence of sudo or any form of elevated privileges is during install when the MacOS app installs the ollama binary to /usr/local/bin. Can you check the ownership of ~/.ollama and ensure it and any children are owned by your user then retry without sudo?

My bad. I must've been root when I initialized the flake. Closing.

BTW here is my (very basic) flake.nix for ollama if anybody cares:

{
  description = "Python 3.11 development environment";

  # Flake inputs
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; # also valid: "nixpkgs"
  };

  # Flake outputs
  outputs = { self, nixpkgs }:
    let
      # Systems supported
      allSystems = [
        "x86_64-linux" # 64-bit Intel/AMD Linux
        "aarch64-linux" # 64-bit ARM Linux
        "x86_64-darwin" # 64-bit Intel macOS
        "aarch64-darwin" # 64-bit ARM macOS
      ];

      # Helper to provide system-specific attributes
      forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
        pkgs = import nixpkgs { inherit system; };
      });
    in
    {
      # Development environment output
      devShells = forAllSystems ({ pkgs }: {
        default = pkgs.mkShell {
          # The Nix packages provided in the environment
          packages = with pkgs; [
            ollama
            python311
            python311Packages.pandas
            python311Packages.numpy
            python311Packages.scipy
            python311Packages.scikit-learn
            python311Packages.matplotlib
            python311Packages.ipython
            python311Packages.requests
            python311Packages.aiohttp
            python311Packages.gql
            python311Packages.pathlib2
          ];
        };
      });
    };
}
'''
<!-- gh-comment-id:1694645163 --> @vegabook commented on GitHub (Aug 27, 2023): > There's no reason ollama needs `sudo` in runtime. The only occurrence of `sudo` or any form of elevated privileges is during install when the MacOS app installs the ollama binary to `/usr/local/bin`. Can you check the ownership of `~/.ollama` and ensure it and any children are owned by your user then retry without `sudo?` My bad. I must've been root when I initialized the flake. Closing. BTW here is my (very basic) `flake.nix` for ollama if anybody cares: ``` { description = "Python 3.11 development environment"; # Flake inputs inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; # also valid: "nixpkgs" }; # Flake outputs outputs = { self, nixpkgs }: let # Systems supported allSystems = [ "x86_64-linux" # 64-bit Intel/AMD Linux "aarch64-linux" # 64-bit ARM Linux "x86_64-darwin" # 64-bit Intel macOS "aarch64-darwin" # 64-bit ARM macOS ]; # Helper to provide system-specific attributes forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f { pkgs = import nixpkgs { inherit system; }; }); in { # Development environment output devShells = forAllSystems ({ pkgs }: { default = pkgs.mkShell { # The Nix packages provided in the environment packages = with pkgs; [ ollama python311 python311Packages.pandas python311Packages.numpy python311Packages.scipy python311Packages.scikit-learn python311Packages.matplotlib python311Packages.ipython python311Packages.requests python311Packages.aiohttp python311Packages.gql python311Packages.pathlib2 ]; }; }); }; } '''
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#198