NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.33k stars 1.49k forks source link

Installing on MacOS fails when user UID is already in use #2242

Open johncoder opened 6 years ago

johncoder commented 6 years ago

While installing nix on MacOS it fails while creating build user 5:

~~> Setting up the build user nixbld5
<main> attribute status: eDSRecordAlreadyExists
<dscl_cmd> DS Error: -14135 (eDSRecordAlreadyExists)

---- oh no! --------------------------------------------------------------------
Jeeze, something went wrong. If you can take all the output and open
an issue, we'd love to fix the problem so nobody else has this issue.

:(

We'd love to help if you need it.

If you can, open an issue....

After some investigation, I realized it fails because I have a _sophos user with UniqueID "30005"

dscl . -search /Users UniqueID "30005"

yields:

_sophos     UniqueID = (
    30005
)

Is there a way to work around this?

matthewbauer commented 6 years ago

This is definitely a serious issue! We may be able to just skip user id that is taken.

/cc @grahamc

vcunat commented 6 years ago

I'm not sure how to approach this. Having some non-nix UIDs in the nix block would seem sub-optimal to me as well; it would seem better to just choose a different contiguous block.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

stale[bot] commented 2 years ago

I closed this issue due to inactivity. → More info

bjornfor commented 2 years ago

Duplicate(?) issue still open here: https://github.com/NixOS/nix/issues/6153

fbettag commented 3 months ago

on macos sequoia the uid 301 is now being used by _modelmanagerd:

dscl . -search /Users UniqueID "301"                                                                                                                      ─╯
_modelmanagerd      UniqueID = (
    301
)

resulting in

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld1 UniqueID 301

Creating the Nix build user (#1), _nixbld1

<main> attribute status: eDSRecordAlreadyExists
<dscl_cmd> DS Error: -14135 (eDSRecordAlreadyExists)
aarnphm commented 3 months ago

on macos sequoia the uid 301 is now being used by _modelmanagerd:

dscl . -search /Users UniqueID "301"                                                                                                                      ─╯
_modelmanagerd        UniqueID = (
    301
)

resulting in

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld1 UniqueID 301

Creating the Nix build user (#1), _nixbld1

<main> attribute status: eDSRecordAlreadyExists
<dscl_cmd> DS Error: -14135 (eDSRecordAlreadyExists)

Hi there, just upgraded to sequoia to day, would recommend https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file and set the following

NIX_INSTALLER_NIX_BUILD_USER_ID_BASE=400 curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install

Though I do think build user id should just start at 400 since Apple might add new build users in the future

slice commented 3 months ago

I woke up today to see that _nixbld1 through _nixbld4 were suddenly missing on macOS Sequoia Seed 1 AKA 15.0 Beta (24A5264n), so I'll drop the other users for posterity. dscacheutil -q user outputs:

name: _modelmanagerd
password: *
uid: 301
gid: 301
dir: /var/db/modelmanagerd
shell: /usr/bin/false
gecos: Model Manager

name: _reportsystemmemory
password: *
uid: 302
gid: 302
dir: /var/empty
shell: /usr/bin/false
gecos: ReportSystemMemory

name: _swtransparencyd
password: *
uid: 303
gid: 303
dir: /var/db/swtransparencyd
shell: /usr/bin/false
gecos: Software Transparency Services

name: _naturallanguaged
password: *
uid: 304
gid: 304
dir: /var/db/com.apple.naturallanguaged
shell: /usr/bin/false
gecos: Natural Language Services

These users overwrote the Nix build users overnight. Maybe the default user ID base should be bumped?

Eveeifyeve commented 3 months ago

I have noticed this issue on MacOS Sequoia read my issue that linked this one.

abhillman commented 2 months ago

on macos sequoia the uid 301 is now being used by _modelmanagerd:

dscl . -search /Users UniqueID "301"                                                                                                                      ─╯
_modelmanagerd      UniqueID = (
    301
)

resulting in

---- sudo execution ------------------------------------------------------------
I am executing:

    $ sudo /usr/bin/dscl . create /Users/_nixbld1 UniqueID 301

Creating the Nix build user (#1), _nixbld1

<main> attribute status: eDSRecordAlreadyExists
<dscl_cmd> DS Error: -14135 (eDSRecordAlreadyExists)

Hi there, just upgraded to sequoia to day, would recommend https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file and set the following

NIX_INSTALLER_NIX_BUILD_USER_ID_BASE=400 curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install

Though I do think build user id should just start at 400 since Apple might add new build users in the future

I have found that the following works for the canonical installer:

NIX_FIRST_BUILD_UID=30001 sh <(curl -L https://nixos.org/nix/install)

Source: https://github.com/NixOS/nix/blob/master/scripts/install-darwin-multi-user.sh#L7

Here is a way to list all taken uids:

% dscacheutil -q user | grep uid | awk '{ print $2 }' | sort -h | uniq
-2
0
1
4
13
24
25
26
27
31
...
abhillman commented 2 months ago

PR https://github.com/NixOS/nix/pull/11095 should solve this issue. Please feel free +1.

theoparis commented 1 month ago

NIX_FIRST_BUILD_UID=30001 sh <(curl -L https://nixos.org/nix/install)

I received the following error with this command:

It seems the build user _nixbld1 already exists, but with the UID
with the UID ''. This script can't really handle that right
now, so I'm going to give up.

If you already created the users and you know they start from
 and go up from there, you can edit this script and change
NIX_FIRST_BUILD_UID near the top of the file to  and try
again.

We'd love to help if you need it.

Edit: Running for u in $(sudo dscl . -list /Users | grep _nixbld); do sudo dscl . -delete /Users/$u; done and re-running the installer command worked.

Eveeifyeve commented 1 month ago

Fixed in: https://github.com/NixOS/nix/pull/10919

Eveeifyeve commented 1 month ago

Sort of but not a permanent solution so not really but It's under decision as of this: https://github.com/NixOS/nix/pull/10919#issuecomment-2329777647 A PR has been made 34mins ago that fixes the mistake: https://github.com/NixOS/nix/pull/11433#issue-2506616528

Eveeifyeve commented 1 month ago

cc @tomberek, close this issue as it's solved in #11433?

theoparis commented 4 weeks ago

It is not solved via sh <(curl -L https://nixos.org/nix/install) yet.. I still have to prepend NIX_FIRST_BUILD_UID=30001

nixos-discourse commented 2 weeks ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/macos-15-sequoia-update-clobbers-nixbld1-4-users/52223/3

Eveeifyeve commented 2 weeks ago

It is not solved via sh <(curl -L https://nixos.org/nix/install) yet.. I still have to prepend NIX_FIRST_BUILD_UID=30001

I could have a look at making a pr that changes the users but that still doesn’t fix the issue, right?

abathur commented 2 weeks ago

@Eveeifyeve my linked PRs don't attempt to directly address this issue (nor is this issue directly related to the sequoia migration). My PRs just move macos installs to a different UID range.