Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

lorri via systemd fails to build project #385

Closed
nomeata opened this issue Apr 28, 2020 · 9 comments
Closed

lorri via systemd fails to build project #385

nomeata opened this issue Apr 28, 2020 · 9 comments

Comments

@nomeata
Copy link

nomeata commented Apr 28, 2020

After the discussion in #96 (comment) I thought I’ll give the recommended way to run lorri a try, and followed the instructions at https://github.com/target/lorri/blob/master/contrib/daemon.md

Indeed the socket triggers and lorri starts, but I get an odd error there about a file not found (not sure which file is missing)

~ $ journalctl --user -u lorri -f
-- Logs begin at Sat 2019-04-06 14:02:38 CEST. --
Apr 28 10:38:14 kirk systemd[901]: Started Lorri Daemon.
Apr 28 10:38:14 kirk lorri[13688]: Apr 28 10:38:14.495 INFO ready
Apr 28 10:38:14 kirk lorri[13688]: Apr 28 10:38:14.496 INFO build status, message: BuildEvent(Started { nix_file: Shell("/home/jojo/project/shell.nix"), reason: ProjectAdded(Shell("/home/jojo/project/shell.nix")) })
Apr 28 10:38:14 kirk lorri[13688]: Apr 28 10:38:14.497 INFO build status, message: BuildEvent(Failure { nix_file: Shell("/home/jojo/project/shell.nix"), failure: Spawn { cmd: "\"nix-instantiate\" \"-vv\" \"--add-root\" \"/tmp/.tmpcImKjk/result\" \"--indirect\" \"--argstr\" \"runtimeClosure\" \"/nix/store/667ylysk5vfq960y7mn1iwimlhk7whpx-runtime-closure.nix\" \"--argstr\" \"shellSrc\" \"/home/jojo/project/shell.nix\" \"--\" \"/home/jojo/.cache/lorri/cas/66c4fc8f70f0926419733bdbfd442181\"", msg: "No such file or directory (os error 2)" } })

Running lorri daemon manually works:

~ $ lorri daemon
Apr 28 10:42:21.395 INFO ready
Apr 28 10:42:23.291 INFO build status, message: BuildEvent(Started { nix_file: Shell("/home/jojo/project/shell.nix"), reason: ProjectAdded(Shell("/home/jojo/project/shell.nix")) })
Apr 28 10:42:46.172 INFO build status, message: BuildEvent(Completed { nix_file: Shell("/home/jojo/project/shell.nix"), result: BuildResults { output_paths: OutputPaths { shell_gc_root: RootPath("/home/jojo/.cache/lorri/gc_roots/43e4499f1c4f23e1a58cfccfade95fa1/gc_root/shell_gc_root") } } })
~/project $ lorri info --shell-file shell.nix 
lorri version: 1.0
gc roots exist, shell_gc_root: "/home/jojo/.cache/lorri/gc_roots/43e4499f1c4f23e1a58cfccfade95fa1/gc_root/shell_gc_root"
~/dfinity/motoko $ uname -a
Linux kirk 4.19.0-8-amd64 #1 SMP Debian 4.19.98-1 (2020-01-26) x86_64 GNU/Linux
@nomeata
Copy link
Author

nomeata commented Apr 28, 2020

I tried to disable the security features in https://github.com/target/lorri/blob/master/contrib/lorri.service but doesn’t seem to make a difference.

@curiousleo
Copy link
Collaborator

One of the possible causes for this error would be that nix-instantiate is not on the PATH in the daemon's context.

The relevant NixOS setting is here:

https://github.com/NixOS/nixpkgs/blob/56622fa339118b89d14a86ea4d56d3d0f3b5b6ba/nixos/modules/services/development/lorri.nix#L35

It may be necessary to change lorri.service so that nix-instantiate is on the PATH.

This is just a hypothesis at this point.

@Profpatsch
Copy link
Collaborator

Profpatsch commented Apr 28, 2020 via email

@nomeata
Copy link
Author

nomeata commented Apr 28, 2020

Manual systemd, sorry for not being clear about that. This is nix on a Debian stable machine.

@nomeata
Copy link
Author

nomeata commented Apr 28, 2020

Indeed, with

Environment=PATH=%h/.nix-profile/bin:/usr/local/bin:/usr/bin

in the system file it works. Not sure how universal that will work – up to you to keep the issue open to either make that change to the instructions, or make lorri print smarter error messages (e.g. “could not find nix-instantiate in the PATH), or something else.

@nomeata
Copy link
Author

nomeata commented Apr 28, 2020

Also, given

ProtectHome=read-only

I am actually surprised it can write to /home/jojo/.cache/lorri/cas/66c4fc8f70f0926419733bdbfd442181. 🤷

@Profpatsch
Copy link
Collaborator

I added an issue that should make things like this easier to debug in the future: #386

I am actually surprised it can write to /home/jojo/.cache/lorri/cas/66c4fc8f70f0926419733bdbfd442181. shrug

That’s XDG_CACHE_DIR, I wouldn’t be surprised if systemd had an exception for XDG_CACHE_DIR/command_name or similar.

@nomeata nomeata closed this as completed Apr 28, 2020
@wentasah
Copy link

I had to extend lorri.service as follows:

Environment=PATH=%h/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/usr/local/bin:/usr/bin:/bin

Compared to @nomeata 's Environment in #385 (comment), I had to add /nix/var/nix/profiles/default/bin (I use multi-user Nix installation) and /bin, because something (not sure what) needs tar. Without /bin, I got the following error message:

Jul 21 12:29:21 steelpick lorri[333940]: Jul 21 12:29:21.613 INFO build status, message: BuildEvent(Failure { nix_file: Shell("/home/wsh/q/vmmu/shell.nix"), failure: Exit { cmd: "\"nix-instantiate\" \"-vv\" \"--add-root\" \"/tmp/.tmpmPvp3J/result\" \"--indirect\" \"--argstr\" \"runtimeClosure\" \"/nix/store/ad1jbfbaabcw8wnss8bgza0kwvdzal9g-runtime-closure.nix\" \"--argstr\" \"shellSrc\" \"/home/wsh/q/vmmu/shell.nix\" \"--\" \"/home/wsh/.cache/lorri/cas/66c4fc8f70f0926419733bdbfd442181\"", status: Some(1), logs: [LogLine("downloading \'https://github.com/NixOS/nixpkgs-channels/archive/4d373182597cff60b3a820affb5a73dd274e205b.tar.gz\'..."), LogLine("unpacking \'https://github.com/NixOS/nixpkgs-channels/archive/4d373182597cff60b3a820affb5a73dd274e205b.tar.gz\'..."), LogLine("error: executing \'tar\': No such file or directory"), LogLine("error: program \'tar\' failed with exit code 1")] } })

@nomeata
Copy link
Author

nomeata commented Jul 27, 2020

Yeah, just ran into needing /bin as well :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants