Repository navigation
Open
Labels
0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: darwinRunning or building packages on Darwin
Description
Edit: related: NixOS/nix#12698
Nixpkgs version
- Unstable (25.05)
Describe the bug
When trying to build my package lintspec on macOS x86, the build fails because of the tooling. The culprit seems to be fetch-cargo-vendor-util which tries to use python's requests package and fails to build with PermissionError: [Errno 1] Operation not permitted
Steps to reproduce
- checkout nixpkgs on macOS intel (x86_64) machine
- nix build .#lintspec
- error
Expected behaviour
The package should build or at least get past the cargo vendor stuff
Screenshots
No response
Relevant log output
Running phase: unpackPhase
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking source archive /nix/store/0wfj7a0bkgjbzsw7c3zidpc4rmx1kfci-source
source root is source
Running phase: patchPhase
@nix { "action": "setPhase", "phase": "patchPhase" }
Running phase: buildPhase
@nix { "action": "setPhase", "phase": "buildPhase" }
Traceback (most recent call last):
File "/nix/store/xgbpy30i497qw8q8mdsknzpp7ngns76v-fetch-cargo-vendor-util/bin/fetch-cargo-vendor-util", line 15, in <module>
import requests
File "/nix/store/fryx95sbwrjrbah4a7xg5lqkl3l12dyf-python3-3.12.9-env/lib/python3.12/site-packages/requests/__init__.py", line 164, in <module>
from .api import delete, get, head, options, patch, post, put, request
File "/nix/store/fryx95sbwrjrbah4a7xg5lqkl3l12dyf-python3-3.12.9-env/lib/python3.12/site-packages/requests/api.py", line 11, in <module>
from . import sessions
File "/nix/store/fryx95sbwrjrbah4a7xg5lqkl3l12dyf-python3-3.12.9-env/lib/python3.12/site-packages/requests/sessions.py", line 15, in <module>
from .adapters import HTTPAdapter
File "/nix/store/fryx95sbwrjrbah4a7xg5lqkl3l12dyf-python3-3.12.9-env/lib/python3.12/site-packages/requests/adapters.py", line 81, in <module>
_preloaded_ssl_context.load_verify_locations(
PermissionError: [Errno 1] Operation not permittedAdditional context
macOS Sonoma 14.6.1 on MacBook Pro 15-inch 2019
System metadata
- system:
"x86_64-darwin" - host os:
Darwin 23.6.0, macOS 10.16 - multi-user?:
yes - sandbox:
yes - version:
nix-env (Nix) 2.15.1 - channels(root):
"" - channels(valentin):
"home-manager, nixpkgs" - nixpkgs:
/Users/valentin/.nix-defexpr/channels/nixpkgs
Are you using nix-darwin?
No, I am not using nix-darwin.
Notify maintainers
Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)
I assert that this issue is relevant for Nixpkgs
- I assert that this is a bug and not a support request.
- I assert that this is not a duplicate of an existing issue.
- I assert that I have read the NixOS Code of Conduct and agree to abide by it.
Is this issue important to you?
Add a 👍 reaction to issues you find important.
Reacted by Austin Horstman, Vladislav Sukhmel, Jonas Fierlings, Alex David and Maxwell Anderson
Metadata
Metadata
Assignees
Labels
0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: darwinRunning or building packages on Darwin
Activity
beeb commentedon Feb 26, 2025
@TomaSajt I think you wrote that util?
TomaSajt commentedon Feb 26, 2025
Does this happen with any other package that uses
fetchCargoVendor?(So most packages that use
buildRustPackage)E.g. you can run this to check if the
cargo-auditablepackage can fetch its deps:nix-build -A cargo-auditable.cargoDeps.vendorStaging --checkbeeb commentedon Feb 26, 2025
Thanks for the quick reply. Same error with cargo-auditable and the command you provided.
TomaSajt commentedon Feb 26, 2025
The issue is probably related to how
cacertis loaded.No idea why this hasn't happen for others.
The relevant lines of the
requestslibrary:DEFAULT_CA_BUNDLE_PATH = requests.certs.where()requests.certs.whereis an alias tocertifi.wherein any case, try running this (inside the repo root):
nix-shell -p -I nixpkgs=./. 'cacert' 'python3.withPackages (ps: [ps.requests])' --run 'python3 -m requests.certs'It should print something similar:
Could you send the output?
Also, try reading the
.crtfile, since it looks like there is some issue with the permissions.beeb commentedon Feb 26, 2025
Cool, thanks for helping out!
Here's the command output:
I can read the file at
/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crtjust fine apparently.Permissions:
.rwxr-xr-x, owner isrootTomaSajt commentedon Feb 26, 2025
Looks like it's not using the value from the
cacertpackage.Here are the relevant lines:
nixpkgs/pkgs/data/misc/cacert/setup-hook.sh
Lines 1 to 7 in 93a1850
It will set the
NIX_SSL_CERT_FILEto the one fromcacert, unless you already have set theNIX_SSL_CERT_FILEvariable.That variable is allowed to be inherited from the user by fetchers, such as
fetchCargoVendor.Maybe you have the
NIX_SSL_CERT_FILEenv-var set in your environment.Are you perhaps behind a proxy?
beeb commentedon Feb 26, 2025
Oh you're right, this environment variable is somehow set to that path when I run
env! I have no idea where it comes from. Not behind a proxy either.Where would I start looking to find what sets it?
beeb commentedon Feb 26, 2025
I
unsetthe variable and ran the command again, and now I get:The permissions are
.r-xr-xr-xwith ownerroot. Still have the same error while building.TomaSajt commentedon Feb 26, 2025
Please make the following changes to your nixpkgs repo:
and run
nix-build -A cargo-auditable.cargoDeps.vendorStaging --checkThe question is: does it successfully do the
catstep or does it just fail.beeb commentedon Feb 26, 2025
Ok did the change, ran the command, and it fails before the cat:
The error seems to happen on the line
cert=$(python3 -m requests.certs).TomaSajt commentedon Feb 26, 2025
Let's try this one:
beeb commentedon Feb 26, 2025
Interesting:
Although I unset my environment variable just before running the command, it somehow still goes looking for it in the nix profile. It's getting late here but I'll answer tomorrow if you have any other ideas!
TomaSajt commentedon Feb 26, 2025
Hmm, something is re-setting this env-var.
Next step would be to look at
/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crtand check what kind of file it is?Is it a plain file?
Is it a symlink?
If yes does it just point to
/nix/store/...-nss-cacert-3.108/etc/ssl/certs/ca-bundle.crt?What might possibly be setting this variable?
I'll ask others on Matrix.
10 remaining items
TomaSajt commentedon Mar 6, 2025
Another solution according to the matrix chat is to relax the sandbox. (I don't know how that's done).
wattmto commentedon Mar 6, 2025
Thanks,
sandbox = "relaxed"seems works!beeb commentedon Mar 13, 2025
Sandbox relaxed does not seem to help here. I'll try with the re-install but it will take me some time on the very slow intel mac and I don't have a lot of time these days.
n8henrie commentedon Mar 19, 2025
Sandbox relaxed works here (for nushell as well as espanso) but will be nice to go back to the full sandbox.
Recognizing that darwin isn't tier 1, it's still kind of a bummer to break so many builds for sandboxed darwin users -- was this recognized as an issue before merging? I should probably know this, but are hydra darwin builds done with sandbox enabled?
(I am grateful for the work done and recognize that many folks don't have access to darwin machines for testing.)
TomaSajt commentedon Mar 19, 2025
This mass migration to fetchCargoVendor was something we were pretty much forced into. I myself wasn't expecting the migration to happen so soon. I had tested it in my darwin VM, but I never configured it to have sandboxed builds. Noone else complained, so I thought it was fine.
Also, this issue is very likely a nix bug. It hasn't been reported yet. If you have a step by step way to reproduce the issue maybe consider opening an nix issue.
But before that: I wanted to confirm this: does
fetchgitalso fail for people who have this issue? I would assume yes, but I'd like some confirmation.(fetchgit is not fetchFromGitHub) (don't forget that you mustn't use an already cached source)
n8henrie commentedon Mar 19, 2025
No worries, I appreciate the explanation and really am grateful for your efforts here. The fact that you went so far as to test in a darwin vm is awesome.
fetchgit seems fine in the repl at least.EDIT: Sorry, I tested in the wrong shell session / machine.
fetchgitis not working:TomaSajt commentedon Mar 19, 2025
Okay, thanks for testing, that is reassurring to hear.
At least it's consistently broken.
Also fetchgit is arguably more important to be working properly than a cargo fetcher, so more reason to figure it out.
TomaSajt commentedon Mar 19, 2025
I have opened NixOS/nix#12698
If you're having this issue, it would be very appreciated if you headed over to the opened issue and provided some details as I myself have not reproduced the problem yet.
beeb commentedon Mar 21, 2025
Re-installing nix from scratch with the determinate-systems installer helped! I had to manually delete some users and groups before re-installing but managed in the end. I can now build packages even with sandbox enabled. So I'm afraid I can't help to reproduce the issue.
sybereal commentedon Apr 25, 2025
I experienced what may be the same issue on a Linux host, although the error message is slightly different:
For me, setting the sandbox to relaxed as suggested by others in this thread resolved the issue.
TomaSajt commentedon Apr 25, 2025
Hmm, interesting...
@sybereal if it's OK, I would like to learn more about your setup.
ssl-cert-pathif you runnix config show/etc/nix/nix.conf?$NIX_SSL_CERT_FILEset in your normal shell environment$NIX_SSL_CERT_FILEset in FOD-based fetchers?and then running
nix-build -A mdbook.cargoDeps.vendorStaging --checksybereal commentedon May 10, 2025
This occurred on my work laptop, which I don't have access to right now, but it worked without changing the sandbox settings on another machine. The key difference between the two is that the machine that errored is a single-user Nix install in WSL2, from before systemd was available. On the machine that works, it's also WSL2, but a regular multi-user install, since it was configured after systemd support was released.
On the machine where it works:
sh <(curl -L https://nixos.org/nix/install) --daemonssl-cert-pathif you runnix config show? There is nossl-cert-path, onlyssl-cert-file, which is set to/etc/ssl/ca-bundle.pem.$NIX_SSL_CERT_FILEset in your normal shell environment? Yes, to/etc/ssl/ca-bundle.pem.$NIX_SSL_CERT_FILEset in FOD-based fetchers?/nix/store/2wmmwdbxp6myhdbrqsan7nbpsfazszvl-nss-cacert-3.108/etc/ssl/certs/ca-bundle.crtI will edit this comment once I am on my work machine again and check there.
Update for the machine where it doesn't work:
sh <(curl -L https://nixos.org/nix/install) --no-daemonssl-cert-pathif you runnix config show? There is nossl-cert-path, onlyssl-cert-file, which is set to/etc/ssl/ca-bundle.pem.$NIX_SSL_CERT_FILEset in your normal shell environment? Yes, to/etc/ssl/ca-bundle.pem.$NIX_SSL_CERT_FILEset in FOD-based fetchers?/etc/ssl/ca-bundle.pemsybereal commentedon May 13, 2025
@TomaSajt Updated my previous comment with new information.
TomaSajt commentedon May 13, 2025
Thank you, now I see why it's not working for your second machine: the build environment inherits env vars from the daemon if possible (its unset by default), but in single user mode it inherits from the user running the command...
We'll merge one of the half-fix PRs soon, so it should work afterwards, but we will try to figure out a more permanent solution with cooperation with people on the nix development side.