Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

findutils/xargs has a subtle undeclared runtime dependency on an external echo command #89055

Closed
abathur opened this issue May 27, 2020 · 4 comments · Fixed by #89063
Closed
Labels
0.kind: bug 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md

Comments

@abathur
Copy link
Member

abathur commented May 27, 2020

Describe the bug
If you run xargs without specifying the command argument, it falls back on running echo (this is roughly documented in the man page, but the note there mistakenly claims the default is /bin/echo, but this was changed back in 2011...). If it can't find echo, xargs throws a .../bin/xargs: echo: No such file or directory error.

To Reproduce
This example is a little synthetic (not very similar to how I found the issue), but a simple way to demonstrate it is: nix-shell -p findutils --run 'echo heh | env -i PATH= $(type -p xargs)'

Additional context
The checkPhase of the CI build for my shell-script dependency resolver invokes a test script like env -i <script> to demonstrate that it's depending on resolved executable paths--not the environment. The test script in turn sources a resolved copy of shunit2 (which contains a bare xargs invocation). This has been running okay in macOS and Linux (but obviously, with a hidden dependency leaking in), but I noticed today that it errors on NixOS.

It's not hard to patch this with substitute:

find_some_utils = pkgs.findutils.overrideAttrs (oldAttrs: rec {
    prePatch = ''
      substituteInPlace xargs/xargs.c --replace 'char default_cmd[] = "echo";' 'char default_cmd[] = "${coreutils}/bin/echo";'
    '';
  });

I'm not, however, sure if it is "right" to try to fix this at all, nor if this is the right approach.

Notify maintainers
@veprbl @disassembler @vcunat

@veprbl
Copy link
Member

veprbl commented May 27, 2020

@abathur Open a PR for this?

@abathur
Copy link
Member Author

abathur commented May 27, 2020

@veprbl Sure. Still counting on someone else to make sure this is appropriate, though.

abathur added a commit to abathur/resholve that referenced this issue May 31, 2020
Hopefully temporary. Can cut workaround after:
NixOS/nixpkgs#89055
@stale
Copy link

stale bot commented Nov 24, 2020

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

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 24, 2020
@abathur
Copy link
Member Author

abathur commented Nov 24, 2020

This was fixed by #89063

@abathur abathur closed this as completed Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants