cachix / install-nix-action

Installs Nix on GitHub Actions for the supported platforms: Linux and macOS.
Apache License 2.0
498 stars 78 forks source link

Nix cannot be installed on subsequent runs on hosted runners #191

Closed peperunas closed 4 months ago

peperunas commented 11 months ago

I switched to a self-hosted runner from ubuntu-latest and only the first action was able to complete successfully. The followings fail at installing Nix as it results already installed from the previous run.

It seems the installation in the self-hosted runner is not sandboxed, i.e., Nix is not installed on a per-action basis / contained.

Any hints?

Thank you!

sandydoo commented 11 months ago

Could you paste the error you're seeing?

peperunas commented 10 months ago

Hello,

Unfortunately, I checked the logs, but they expired and are unavailable. I have re-switched to the hosted Github Actions as a workaround for now.

If you have any pointers, I would gladly try to troubleshoot.

Best, Giulio

On 26 Aug 2023 at 10:56 -0700, Sander @.***>, wrote:

Could you paste the error you're seeing? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

vbgl commented 5 months ago

I’ve just witnessed a similar situation: first run on a self-hosted runner went nicely, the following one failed with:

~~> Checking for artifacts of previous installs Before I try to install, I'll check for signs Nix already is or has been installed on this system.

---- oh no! -------------------------------------------------------------------- I back up shell profile/rc scripts before I add Nix to them. I need to back up /etc/bash.bashrc to /etc/bash.bashrc.backup-before-nix, but the latter already exists.

vbgl commented 5 months ago

But it seems to have been fixed already: with version 25 of this action, in a similar setting I get:

Aborting: Nix is already installed at /nix/var/nix/profiles/default/bin/nix

guidodobboletta commented 4 months ago

I still see this with version 25

---- oh no! --------------------------------------------------------------------
  I back up shell profile/rc scripts before I add Nix to them.
  I need to back up /etc/bashrc to /etc/bashrc.backup-before-nix,
  but the latter already exists.
sandydoo commented 4 months ago

It seems the installation in the self-hosted runner is not sandboxed, i.e., Nix is not installed on a per-action basis / contained.

This is a common misconception with self-hosted runners. There's no sandboxing by default. GitHub leaves it up to you to figure out how to set this up.

I’ve just witnessed a similar situation: first run on a self-hosted runner went nicely, the following one failed with...

I still see this with version 25

The action checks whether nix is in the PATH. If Nix is already installed on your runner, but the action can't find it, then there's likely something wrong with your environment. You may have to modify your runner to make this work.

A lot of this was already discussed in #98, so I'm closing this as a duplicate.