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
0.kind: bugSomething is broken6.topic: darwinRunning or building packages on Darwin6.topic: haskellGeneral-purpose, statically typed, purely functional programming language
A tool like GHC will stash away a full path to clang to use for, eg, linking. But when this invocation to clang occurs outside of nix-shell, I get error messages about an invalid flag, -f, being passed to readlink. In nix-shell, everything is fine. So it seems as though a clang from the nix store is being invoked, but it, in turn, is invoking readlink on PATH which, on darwin, is different from the one in the nix stdenv.
Great! What would a proper invocation of readlink look like? cc @gridaphobe
This is handy to do as it lets you configure in one environment, and kick off a build from another. Perhaps such things are doomed, but it certainly makes nixpkgs adoption easier when it works.
Given that this is inside a shell script, you'll probably want @coreutils@ and to make sure the parent derivation sets that variable. Still think this is an important broader question, though.
Ah yes, @copumpkin is right, I didn't notice we were talking about a shell script instead of inline shell in a nix file.
To the broader issue, I think it would be a good practice to use absolute paths pointing to nix-owned binaries, at least when dealing with non-standard flags. I remember a discussion about this a few months ago (incidentally also prompted by readlink).
I suppose I'm not sure I understand @copumpkin's concern. Is the contention that one should never run a nix-built executable outside of nix-shell or an environment with that executable installed in it? So if I have GHC installed in my environment, I should also have the clang it knows of in my environment in order to use GHC?
Nope! It's that people write things like grep foo or readlink -f all the time in nix-managed scripts, and if those scripts ever get persisted and used outside of a nix build, that will cause potential breakage. It would just be nice to have a systematic way to avoid this, even if the particular instances are easy to fix.
I had stopped using GHC from haskellPackages, but I gave it a shot again today and see that this is still a problem. I don't think I've seen the @coreutils@ syntax before, so I'd probably get it wrong, but if this isn't going to be fixed in a wider way, perhaps the quick(er) fix is appropriate?
Could you please share your exact setup, the command you call, and the output given by that command when it fails? I'm particularly interested in the version of GHC that you're using.
This is with the GHC-7.10.2 one gets by running nix-env -i ghc on OS X 10.11.2
The readlink error output was upon linking a Criterion-based benchmark executable with GHC. In this case, typing cabal build after cabal configure --enable-benchmarks. I'll note that I couldn't reproduce with a simple "Hello World" executable.
It's likely what @copumpkin said above, but it's a bear to test as it takes nearly 12 hours for me to build everything after changing anything that low in the stack. I didn't do it properly in my first attempt, so I'm building again. I'll report back tomorrow if it works. If it still doesn't work, I'll try to find a reasonable reproducer with the regular nixpkgs release.
Well, ghc 7.10.2 has readlink in $PATH, so I don't see any way that it could be missing. If you could the actual command you've run and the actual output that command produced, then that would be very helpful.
Good news! Implementing @copumpkin's idea finally fixes this issue. I'll make a PR later today; I hope it's not looked on too negatively given how many rebuilds it necessitates.
(cabbage is a build tool I use that populates cabal sandboxes from the nix store)
I suspect the problem is with packages that have C components. Either GHC or cabal-install is invoking the C compiler in a way that can be a bit tricky to follow, at least for me. I ran into this recently when ensuring that nix frameworks are passed to the C compiler when building hsc files, for example. This subtlety only bit me recently due to the pure-darwin switchover, as, previously, I was apparently still picking up system frameworks on the somewhat infrequent occasions that an hsc file needs headers from a framework.
Thanks, @peti, but I think this is really a Mac issue at core. GHC tickled it, but I hope a reproducer will just involve clang as that's where the issue comes from.
0.kind: bugSomething is broken6.topic: darwinRunning or building packages on Darwin6.topic: haskellGeneral-purpose, statically typed, purely functional programming language
Activity
copumpkin commentedon Feb 19, 2015
I see an unadorned
readlink -finld-wrapper.sh.copumpkin commentedon Feb 19, 2015
We can fix this particular instance easily, but it seems like a broader issue if your runtime path isn't fully managed by nix.
acowley commentedon Feb 19, 2015
Great! What would a proper invocation of
readlinklook like? cc @gridaphobeThis is handy to do as it lets you configure in one environment, and kick off a build from another. Perhaps such things are doomed, but it certainly makes nixpkgs adoption easier when it works.
gridaphobe commentedon Feb 19, 2015
@acowley it should probably be
${coreutils}/bin/readlink -fcopumpkin commentedon Feb 19, 2015
Given that this is inside a shell script, you'll probably want @coreutils@ and to make sure the parent derivation sets that variable. Still think this is an important broader question, though.
gridaphobe commentedon Feb 19, 2015
Ah yes, @copumpkin is right, I didn't notice we were talking about a shell script instead of inline shell in a nix file.
To the broader issue, I think it would be a good practice to use absolute paths pointing to nix-owned binaries, at least when dealing with non-standard flags. I remember a discussion about this a few months ago (incidentally also prompted by
readlink).acowley commentedon Feb 19, 2015
I suppose I'm not sure I understand @copumpkin's concern. Is the contention that one should never run a nix-built executable outside of nix-shell or an environment with that executable installed in it? So if I have GHC installed in my environment, I should also have the clang it knows of in my environment in order to use GHC?
copumpkin commentedon Feb 19, 2015
Nope! It's that people write things like
grep fooorreadlink -fall the time in nix-managed scripts, and if those scripts ever get persisted and used outside of a nix build, that will cause potential breakage. It would just be nice to have a systematic way to avoid this, even if the particular instances are easy to fix.acowley commentedon Jun 5, 2015
I had stopped using GHC from
haskellPackages, but I gave it a shot again today and see that this is still a problem. I don't think I've seen the@coreutils@syntax before, so I'd probably get it wrong, but if this isn't going to be fixed in a wider way, perhaps the quick(er) fix is appropriate?peti commentedon Aug 9, 2015
d3ac5c5 fixes this issue.
acowley commentedon Dec 16, 2015
I still see this error on darwin.
peti commentedon Dec 16, 2015
@acowley, which version of Nixpkgs are you using?
acowley commentedon Dec 16, 2015
It's the
nixpkgs-unstablechannel, at commit 3087ef3peti commentedon Dec 16, 2015
Could you please share your exact setup, the command you call, and the output given by that command when it fails? I'm particularly interested in the version of GHC that you're using.
acowley commentedon Dec 17, 2015
This is with the GHC-7.10.2 one gets by running
nix-env -i ghcon OS X 10.11.2The readlink error output was upon linking a Criterion-based benchmark executable with GHC. In this case, typing
cabal buildaftercabal configure --enable-benchmarks. I'll note that I couldn't reproduce with a simple "Hello World" executable.It's likely what @copumpkin said above, but it's a bear to test as it takes nearly 12 hours for me to build everything after changing anything that low in the stack. I didn't do it properly in my first attempt, so I'm building again. I'll report back tomorrow if it works. If it still doesn't work, I'll try to find a reasonable reproducer with the regular nixpkgs release.
peti commentedon Dec 17, 2015
Well, ghc 7.10.2 has
readlinkin$PATH, so I don't see any way that it could be missing. If you could the actual command you've run and the actual output that command produced, then that would be very helpful.acowley commentedon Dec 17, 2015
Good news! Implementing @copumpkin's idea finally fixes this issue. I'll make a PR later today; I hope it's not looked on too negatively given how many rebuilds it necessitates.
@peti The commands are,
(
cabbageis a build tool I use that populates cabal sandboxes from the nix store)I suspect the problem is with packages that have C components. Either GHC or cabal-install is invoking the C compiler in a way that can be a bit tricky to follow, at least for me. I ran into this recently when ensuring that nix frameworks are passed to the C compiler when building hsc files, for example. This subtlety only bit me recently due to the pure-darwin switchover, as, previously, I was apparently still picking up system frameworks on the somewhat infrequent occasions that an hsc file needs headers from a framework.
peti commentedon Dec 17, 2015
Well, without the information I requested I cannot figure out what is going on since I don't have access to a Mac.
acowley commentedon Dec 17, 2015
Thanks, @peti, but I think this is really a Mac issue at core. GHC tickled it, but I hope a reproducer will just involve clang as that's where the issue comes from.
acowley commentedon Dec 17, 2015
I've opened the PR after verifying that it is reproducible without involving GHC or anything complicated at all.
cc-wrapper: fix on darwin