15

I run brew search stdbuf and get

No formula found for "stdbuf".
Searching pull requests...
Closed pull requests:
coreutils: upstream fix for stdbuf (https://github.com/Homebrew/homebrew/pull/32955)

I run brew install coreutils but get Warning: coreutils-8.23_1 already installed.

I do but see no stdbuf in my system.

$ std [tab]
stdethers  stdhosts   

My PATH is

/usr/local/bin:/usr/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:
/sbin:/opt/X11/bin:/usr/local/git/bin:/usr/texbin:/Users/masi/.cabal/bin

Uninstall Macports

Using Macports and Homebrew together cause conflicts. Final solution is to uninstall Macports which is immature. Regardless of what your PATH is, Macports causes conflicts with programs in the PATH. I realised the core of the problem here at the end of the body about How to Enlarge Disk Image in VirtualBox?


How can you use stdbuf in OSX Yosemite?

4
  • 1
    Why do you have /usr/local/bin and /usr/bin in your $PATH twice? Commented Jun 26, 2015 at 9:54
  • Not anymore when I combined export in .bash_profile and .bashrc. Commented Jun 26, 2015 at 10:48
  • Can someone report this issue to homebrew? The stdbuf util should be in the standard path, while the libstdbuf.so shared lib should be in the libexec location. Commented Jan 1, 2016 at 17:42
  • What do you mean "MacPorts is immature"? MacPorts does have all GNU utils, they are just prefixed with a g, gls, gcp, gstdbuf etc.
    – d-b
    Commented Nov 4, 2023 at 13:56

3 Answers 3

8

You have to alter your path adding coreutils dir before /usr/bin. You can do something like this:

export PATH=/usr/local/opt/coreutils/libexec/gnubin:$PATH

And should looks like the following after the changes:

/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/bin:
/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:
/sbin:/opt/X11/bin:/usr/local/git/bin:/usr/texbin:
/Users/masi/.cabal/bin

After that, you must be able to use stdbuf.

3
  • My PATH is now /usr/local/bin:/usr/bin:/opt/local/sbin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/usr/texbin:/Users/masi/.cabal/bin after the change. I put the export to my .bashrc. There must be something else which is inserting the beginning to my PATH. Commented Jun 26, 2015 at 8:43
  • Did you source your .bashrc file from your .bash_profile? Check your PATH on .bash_profile too.
    – jherran
    Commented Jun 26, 2015 at 8:46
  • I had this export PATH=/usr/local/bin:/usr/bin:/opt/local/sbin:$PATH:$HOME/.cabal/bin in .bash_profile. So I removed it in .bash_profile and added simply to .bashrc simply export PATH=/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/bin:/opt/local/sbin:$PATH:$HOME/.cabal/bin. Commented Jun 26, 2015 at 9:08
16

coreutils on OS X adds the prefix g to all the commands so as to not mess up with default programs on OS X.

It prints this when you run brew install coreutils

==> Caveats
All commands have been installed with the prefix 'g'.

If you really need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:

    PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"

So unless you really need to use it as stdbuf, there is no real reason to update your path, you can simply run gstdbuf instead:

$ gstdbuf --help                                                         
Usage: gstdbuf OPTION... COMMAND 
1

If you don't want to mess with your PATH and all you need is stdbuf:

cd /usr/local/bin
sudo ln -s ../opt/coreutils/libexec/gnubin/stdbuf stdbuf

For whatever reason I also already had coreutils brewed, but only certain binaries linked - not remembering why, this seemed like the safest option

1
  • It would be great to understand why this linking is not done. I do not like putting too much in PATH and messing it up. Commented Dec 24, 2015 at 8:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .