Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos-upgrade.service: error: executing 'git': No such file or directory #54946

Closed
thiagokokada opened this issue Jan 30, 2019 · 7 comments
Closed

Comments

@thiagokokada
Copy link
Contributor

thiagokokada commented Jan 30, 2019

Issue description

In my /etc/nixos/configuration.nix I have:

{ pkgs, config, ... }:

let
  unstable = import (fetchGit {
    name = "nixos-unstable-2019-01-10";
    url = https://github.com/nixos/nixpkgs/;
    rev = "77ec7d75a9effb1d45dc3c01fb1261be43bcc1e0"; # py3status 3.15
  }) {
    config = config.nixpkgs.config;
  };
in
{
    systemPackages = with pkgs; [
      unstable.kitty
    ];
  };

  system.autoUpgrade = {
    enable = true;
    dates = "daily";
  };
}

However, looking at nixos-upgrade.service logs, I got:

● nixos-upgrade.service - NixOS Upgrade
   Loaded: loaded (/nix/store/h0zrzjf8wnjarfzjg347kvw1c9h0y229-unit-nixos-upgrade.service/nixos-upgrade.service; linked; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2019-01-30 13:13:18 -02; 2s ago
  Process: 29560 ExecStart=/nix/store/rr81z5vhylz63rixkbcarnjgrkkvkr36-unit-script-nixos-upgrade-start (code=exited, status=1/FAILURE)
 Main PID: 29560 (code=exited, status=1/FAILURE)

jan 30 13:13:16 mirai-nubank rr81z5vhylz63rixkbcarnjgrkkvkr36-unit-script-nixos-upgrade-start[29560]: unpacking channels...
jan 30 13:13:16 mirai-nubank rr81z5vhylz63rixkbcarnjgrkkvkr36-unit-script-nixos-upgrade-start[29560]: building Nix...
jan 30 13:13:17 mirai-nubank rr81z5vhylz63rixkbcarnjgrkkvkr36-unit-script-nixos-upgrade-start[29560]: building the system configuration...
jan 30 13:13:18 mirai-nubank rr81z5vhylz63rixkbcarnjgrkkvkr36-unit-script-nixos-upgrade-start[29560]: error: executing 'git': No such file or directory
jan 30 13:13:18 mirai-nubank rr81z5vhylz63rixkbcarnjgrkkvkr36-unit-script-nixos-upgrade-start[29560]: error: executing 'git': No such file or directory
jan 30 13:13:18 mirai-nubank rr81z5vhylz63rixkbcarnjgrkkvkr36-unit-script-nixos-upgrade-start[29560]: error: program 'git' failed with exit code 1
jan 30 13:13:18 mirai-nubank rr81z5vhylz63rixkbcarnjgrkkvkr36-unit-script-nixos-upgrade-start[29560]: (use '--show-trace' to show detailed location information)
jan 30 13:13:18 mirai-nubank systemd[1]: nixos-upgrade.service: Main process exited, code=exited, status=1/FAILURE
jan 30 13:13:18 mirai-nubank systemd[1]: nixos-upgrade.service: Failed with result 'exit-code'.
jan 30 13:13:18 mirai-nubank systemd[1]: Failed to start NixOS Upgrade.

Running nixos-rebuild switch --upgrade as a user works. I think because nixos-rebuild inside service runs without PATH it does not find git installed in the system.

Steps to reproduce

Added a package backport using fetchGit in your /etc/nixos/configuration.nix, set system.autoUpgrade = true and run systemctl start nixos-upgrade.service.

Technical details

 - system: `"x86_64-linux"`
 - host os: `Linux 4.14.95, NixOS, 18.09.1985.749a3a0d00b (Jellyfish)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.1.3`
 - channels(root): `"nixos-18.09.1985.749a3a0d00b, nixos-unstable-19.03pre164715.201d739b0ff"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos
@dtzWill
Copy link
Member

dtzWill commented Jan 30, 2019

For this reason I have the following in all my machine's configuration.nix:

systemd.services.nixos-upgrade.path = [ pkgs.git ];

Basically, nix has runtime dependencies that it are intentionally omitted (as optional, I think) when installing or using it. Not sure if there's a list anywhere, xz and tar I think have been needed previously.

@thiagokokada
Copy link
Contributor Author

@dtzWill Good one, this seems to work.

Wouldn't it be better to export those packages in the service itself though? The fact that it works via command line and doesn't work via service file is confusing.

@dtzWill
Copy link
Member

dtzWill commented Jan 30, 2019

I think this would be a good idea to have included by default, actually (I agree). Folks can share their thoughts on the PR making the change :). Would you mind putting that together? :)

@thiagokokada
Copy link
Contributor Author

@dtzWill I will take a look when I have sometime, thanks for the suggestion!

@markuskowa
Copy link
Member

Is there any argument against the obvious solution?

diff --git a/nixos/modules/tasks/auto-upgrade.nix b/nixos/modules/tasks/auto-upgrade.nix
index 7b756b70e2f..712c520ca26 100644
--- a/nixos/modules/tasks/auto-upgrade.nix
+++ b/nixos/modules/tasks/auto-upgrade.nix
@@ -78,7 +78,7 @@ let cfg = config.system.autoUpgrade; in
           HOME = "/root";
         } // config.networking.proxy.envVars;
 
-      path = [ pkgs.gnutar pkgs.xz.bin config.nix.package.out ];
+      path = [ pkgs.gnutar pkgs.xz.bin pkgs.git config.nix.package.out ];
 
       script = ''
         ${config.system.build.nixos-rebuild}/bin/nixos-rebuild switch ${toString cfg.flags}

@matthewbauer
Copy link
Member

No I think that will work for everyone!

@dtzWill
Copy link
Member

dtzWill commented Jan 31, 2019

Yep!

markuskowa added a commit to markuskowa/nixpkgs that referenced this issue Feb 1, 2019
Resolves NixOS#54946
where nixos-rebuild can not find git, when executed
from inside the systemd service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants