ruby-install icon indicating copy to clipboard operation
ruby-install copied to clipboard

If installed using Homebrew, ruby-install errors because sudo installs are no longer allowed

Open jeremy-hanna opened this issue 7 years ago • 7 comments

Env:

  • mac OS X: 10.12.2
  • Homebrew: 1.1.8
  • ruby-install: 0.6.1

screen shot 2017-01-25 at 5 11 25 pm

As of Nov 1st, it appears that homebrew added this restriction: here

https://github.com/postmodern/ruby-install/blob/cc831fcfb8a96a04a38f961b69b2d1172330cefd/share/ruby-install/util.sh#L98-L99

jeremy-hanna avatar Jan 25 '17 23:01 jeremy-hanna

My temp fix:

  • downloaded the source and make installed it - failed in the same fashion
  • removed sudo -u "$brew_owner" from the two lines linked above and make installed it - failed for permissions
  • sudo make install built it and works

Probably because this /usr/bin/stat -f %Su "$(command -v brew)")" evaluates to root based on my system install

jeremy-hanna avatar Jan 25 '17 23:01 jeremy-hanna

I guess this is more environment configuration than a bug with ruby-install, would it make sense to have a warning thrown if $brew_owner is ever root?

jeremy-hanna avatar Jan 25 '17 23:01 jeremy-hanna

the problem for me is that

$ ls -l /usr/local/bin/brew
lrwxr-xr-x  1 root  wheel  28 Jan  4 14:03 /usr/local/bin/brew -> /usr/local/Homebrew/bin/brew

/usr/local/Homebrew/bin/brew has myself as its owner.

josephholsten avatar Feb 08 '17 00:02 josephholsten

http://docs.brew.sh/Troubleshooting.html

@josephholsten, from that page try running

cd /usr/local && sudo chown -R $(whoami) bin etc include lib sbin share var Frameworks

I prefer:

sudo chown -R $(whoami) /usr/local

I'm not sure what causes it, but sometimes the /usr/local directory becomes owned by root.

jpickwell avatar Apr 19 '17 13:04 jpickwell

@havenwood it's not macOS-only anymore, as Homebrew is officially supported on Linux too now. I have it installed on my Solus, as I needed to install something with it, and now have the same issue. However, I can use --no-install-deps to skip that step, and move on as usual.

FunkyloverOne avatar Nov 25 '19 09:11 FunkyloverOne

Is this still an issue? 0.8.2 added better logic for when and when-not-to use sudo with brew. See 093608aed1d189ec6f8a919fe95b9b7e1812e252

postmodern avatar Jan 07 '22 03:01 postmodern

I did manage to get this a couple of times; this last time, first time on an M2 macbook, for some reason, /opt/homebrew/bin/brew was a symlink to /opt/homebrew/Homebrew/bin/brew, and whilst my user owned the latter, target executable, the symlink was marked as owned by root, which made ruby-install attempt sudo -u root .... for it's commands

Fixing the symlink removed the issue, but wanted to note it here in case it helps others. Or me, in 4-6 months time, most likely.

phantomwhale avatar Apr 11 '23 05:04 phantomwhale