You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
curl doesn't work in nix-shell because of $SSL_CERT_FILE=/no-cert-file.crt default #13744
I added some system information. This happens for me before 39609a0, too. Indeed, with this new commit there's a new workaround to set SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt in configuration.nix or something smiliar.
This seems to be a good workaround, since nix-build etc. and nix-shell --pure still behave as before (as they should) but nix-shell doesn't override $SSL_CERT_FILE.
Still it would be even better when this would work without setting SSL_CERT_FILE.
Well, the thing is that nix-shell cannot possibly know the right set of trusted CA certificates that you would like to use, so not using any is a perfectly good choice, IMHO.
Well, we could do something, like don't set $SSL_CERT_FILE when there's a $IN_NIX_SHELL (which wouldn't exactly do the right thing either, because it also triggers in nix-shell --pure).
There certainly is an asymmetry here in the way nix-shell handles certificates. If you set $SSL_CERT_FILE explicitly, then your settings are inherited and everything works as expected. If you don't set $SSL_CERT_FILE, however, then you say, basically, that you want to use the defaults that have been compiled into the programs, but nix-shell undermines that choice by setting $SSL_CERT_FILE to a bogus location for you, thereby preventing tools like curl from using their built-in default behavior. My intuition says that if $SSL_CERT_FILE isn't set outside of nix-shell, then it shouldn't be set inside of it either -- at least that seems like the most consistent behavior to me. Whether that choice would have other unintended consequences or not, I cannot say right now.
Reacted by Matthias Beyer, Vladimír Čunát, Nikolay Amiantov, George Miroshnykov, Joachim Schiele, Profpatsch, Arian van Putten, Greenskid and leslie
changed the title [-]curl doesn't work in nix-shell because of SSL_CERT_FILE[/-][+]curl doesn't work in nix-shell because of $SSL_CERT_FILE=/no-cert-file.crt default[/+]on Mar 19, 2016
I think that we can skip setting SSL_CERT_FILE if we are in a shell. It can certainly improve purity when we are actually building a package, because in general SSL libraries try to read CA bundles from standard locations so something from them might sneak into the result. On the other hand, nix-shell is used for 1) development; 2) prelimitary testing of the build. In both of those cases having SSL certificates available is more desirable IMHO (we don't limit network in a shell, so why should we limit certificates?).
Also to be honest, I'm generally annoyed by having to run unset each time I want to develop in a shell _.
if [ -z "$SSL_CERT_FILE" -a ( -z $IN_NIX_SHELL -o -n $IN_PURE_NIX_SHELL ) ]; then
This way we get the desired behavior in nix-shell while still being as pure as in a normal build when using nix-shell --pure (which is to be expected when using --pure).
Also, in the meantime, when people still use versions of nix that don't have $IN_PURE_NIX_SHELL yet, nix-shell --pure wouldn't be as pure as it could be, but this bug would be fixed (which is more important IMHO).
Activity
fkz commentedon Mar 7, 2016
This relates to NixOS/nix#777
matthiasbeyer commentedon Mar 8, 2016
Can confirm that this is not only an issue with
curl, but for me also withgitandcomposer(php),cargoand maybe even some other tools.Can someone please fix this?
matthiasbeyer commentedon Mar 8, 2016
Maybe even by reverting 39609a0 ?
fkz commentedon Mar 8, 2016
I added some system information. This happens for me before 39609a0, too. Indeed, with this new commit there's a new workaround to set
SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crtinconfiguration.nixor something smiliar.fkz commentedon Mar 8, 2016
This seems to be a good workaround, since
nix-buildetc. andnix-shell --purestill behave as before (as they should) butnix-shelldoesn't override$SSL_CERT_FILE.Still it would be even better when this would work without setting
SSL_CERT_FILE.globin commentedon Mar 19, 2016
This breaks cargo, too.
cc @wizeman, @edolstra
peti commentedon Mar 19, 2016
According to my reading of 39609a0, the value of
$SSL_CERT_FILEthat's set at the timenix-shellis invoked get's preserved:That seems like perfectly reasonable behavior, no?
fkz commentedon Mar 19, 2016
@peti yes, but it doesn't work when SSL_CERT_FILE is unset.
peti commentedon Mar 19, 2016
Well, the thing is that
nix-shellcannot possibly know the right set of trusted CA certificates that you would like to use, so not using any is a perfectly good choice, IMHO.fkz commentedon Mar 19, 2016
Well, we could do something, like don't set
$SSL_CERT_FILEwhen there's a$IN_NIX_SHELL(which wouldn't exactly do the right thing either, because it also triggers innix-shell --pure).I've now set
in
configuration.nixand that works quite well for me.Maybe we should set something like that in default nixos.
peti commentedon Mar 19, 2016
There certainly is an asymmetry here in the way
nix-shellhandles certificates. If you set$SSL_CERT_FILEexplicitly, then your settings are inherited and everything works as expected. If you don't set$SSL_CERT_FILE, however, then you say, basically, that you want to use the defaults that have been compiled into the programs, butnix-shellundermines that choice by setting$SSL_CERT_FILEto a bogus location for you, thereby preventing tools likecurlfrom using their built-in default behavior. My intuition says that if$SSL_CERT_FILEisn't set outside ofnix-shell, then it shouldn't be set inside of it either -- at least that seems like the most consistent behavior to me. Whether that choice would have other unintended consequences or not, I cannot say right now.[-]curl doesn't work in nix-shell because of SSL_CERT_FILE[/-][+]curl doesn't work in nix-shell because of $SSL_CERT_FILE=/no-cert-file.crt default[/+]abbradar commentedon Mar 21, 2016
I think that we can skip setting
SSL_CERT_FILEif we are in a shell. It can certainly improve purity when we are actually building a package, because in general SSL libraries try to read CA bundles from standard locations so something from them might sneak into the result. On the other hand,nix-shellis used for 1) development; 2) prelimitary testing of the build. In both of those cases having SSL certificates available is more desirable IMHO (we don't limit network in a shell, so why should we limit certificates?).Also to be honest, I'm generally annoyed by having to run
unseteach time I want to develop in a shell_.fkz commentedon Mar 21, 2016
I suggest the following:
Add environment variable
$IN_PURE_NIX_SHELLin nix-shell which is set when we're callingnix-shell --pure(in addition to $IN_NIX_SHELL)change the condition in https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L387 to (modulo my mistakes of bash syntax)
if [ -z "$SSL_CERT_FILE" -a ( -z $IN_NIX_SHELL -o -n $IN_PURE_NIX_SHELL ) ]; then
This way we get the desired behavior in
nix-shellwhile still being as pure as in a normal build when usingnix-shell --pure(which is to be expected when using--pure).Also, in the meantime, when people still use versions of
nixthat don't have$IN_PURE_NIX_SHELLyet,nix-shell --purewouldn't be as pure as it could be, but this bug would be fixed (which is more important IMHO).matthiasbeyer commentedon Mar 31, 2016
Any progress in this?
jagajaga commentedon May 12, 2016
This issue is still relevant.
abbradar commentedon May 12, 2016
Funny, I've bumped into this again right when you posted this comment.
sorpaas commentedon May 16, 2016
+1
abbradar commentedon May 20, 2016
PR: #15571
Hackily work around a curl issue.
teto commentedon Oct 4, 2017
hum when building a custom derivation (fcitx), curl fails with this error during a nix-build.
nix-build -A fcitx-master '<nixpkgs>'while in nix-shell it was ok.What would be the recommanded way to make the build work within nix-build ?
Note: the previous changes have now moved to these lines https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L458
arianvp commentedon Mar 12, 2019
Euh since a fix for this landed almost three years ago I think we can close this no? #15571