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

Fix stray stderr output on machines with GNU which #124

Merged
merged 2 commits into from
Sep 6, 2024

Conversation

phinze
Copy link

@phinze phinze commented Sep 5, 2024

On a NixOS machine I was getting a message like the following on every Rails boot:

which: no bun in (... [my path] ...)

I chased it down to this library's usage of which to find the mjml binary. Using backticks to call it meant stderr was passing through to the terminal.

Ubuntu and MacOS use different versions of which that do not print to stderr, so it's likely not many people have run into this issue.

On a NixOS machine I was getting a message like the following on every
Rails boot:

> which: no bun in (... [my path] ...)

I chased it down to this library's usage of `which` to find the mjml
binary. Using backticks to call it meant stderr was passing through to
the terminal.

Ubuntu and MacOS use different versions of `which` that do not
print to stderr, so it's likely not many people have run into this
issue.
@phinze
Copy link
Author

phinze commented Sep 5, 2024

Here's a fun history lesson I stumbled on while researching this issue:

3BSD first implemented 'which': https://minnie.tuhs.org/cgi-bin/utree.pl?file=3BSD/usr/man/man1/which.1 (1979). This was csh-specific and I think it later became built-into csh.

FreeBSD 2.1 introduced a new non-built-in implementation: https://www.freebsd.org/cgi/man.cgi?query=which&apropos=0&sektion=0&manpath=FreeBSD+2.1.0-RELEASE&arch=default&format=html (1995). This was written in Perl and then rewritten in C a few years later.

Debian's implementation started out in 1995 or 1996 as a shell script calling 'type', and remains a shell script.

Red Hat has yet another implementation: https://www.freebsd.org/cgi/man.cgi?query=which&apropos=0&sektion=0&manpath=CentOS+7.1&arch=default&format=html, https://carlowood.github.io/which/ (1999 or earlier). This is written in C.

So 'which' has a very long history in csh, which was the default interactive shell in many versions of Unix. Its availability to other shells dates back to the 90s (at least) but is not portable due to there being multiple very different implementations.

Via https://groups.google.com/g/linux.debian.devel/c/1h7vtg5ty0U/m/ZX-fU2daAQAJ

@sighmon
Copy link
Owner

sighmon commented Sep 6, 2024

@phinze Thanks so much Paul! Really loved the history of which which is which.

p.s. I'd love to hear more about how your transition to climate-related work is going.

@sighmon sighmon merged commit 8de7a87 into sighmon:master Sep 6, 2024
16 checks passed
@phinze phinze deleted the phinze/silence-stderr-from-gnu-which branch September 10, 2024 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants