8

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?

  • 1
    Why do you have /usr/local/bin and /usr/bin in your $PATH twice? – user3439894 Jun 26 '15 at 9:54
  • Not anymore when I combined export in .bash_profile and .bashrc. – Léo Léopold Hertz 준영 Jun 26 '15 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. – Pádraig Brady Jan 1 '16 at 17:42
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.

  • 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. – Léo Léopold Hertz 준영 Jun 26 '15 at 8:43
  • Did you source your .bashrc file from your .bash_profile? Check your PATH on .bash_profile too. – jherran Jun 26 '15 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. – Léo Léopold Hertz 준영 Jun 26 '15 at 9:08
11

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

  • 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. – Léo Léopold Hertz 준영 Dec 24 '15 at 8:40

You must log in to answer this question.

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