cabal icon indicating copy to clipboard operation
cabal copied to clipboard

`ar` permission errors on OS X 10.11 `El Capitan` with GHC 7.8.4

Open lukehoersten opened this issue 11 years ago • 69 comments

When running cabal operations, things fail with ar permission errors:

$ cabal install cabal-install
cabal: /usr/bin/ar: permission denied

This started happening after upgrading to OS X 10.11. Running with -v3 does not give any more information including the file that ar is being run on.

$ ls -al `which ar`
-rwxr-xr-x  1 root  wheel  18160 Jun  3 07:10 /usr/bin/ar

Permissions on the ar binary are fine and can be run directly with no issue. I suspect the file ar is being run on doesn't have read permissions.

lukehoersten avatar Jun 10 '15 21:06 lukehoersten

I encountered a similar error a year ago when building on Heroku. Although I don't remember what ultimately solved the problem, one thing you can experiment with is to copy the ar program to a new place (maybe your home directory) then pass --with-ar=/path/to/ar to the build. Just to see if the path itself somehow affects anything.

begriffs avatar Jun 10 '15 22:06 begriffs

I tried copying to my home dir and it still had the permission issue.

lukehoersten avatar Jun 10 '15 22:06 lukehoersten

OK something else is going on here: When I use the --with-ar setup it has a new error: cabal: /usr/bin/gcc: permission denied

@begriffs seems this is more similar to your issue than I thought. Perhaps there's an issue with running commands from /usr/bin.

lukehoersten avatar Jun 10 '15 22:06 lukehoersten

/usr/bin appears read-only on 10.11.

iangcarroll avatar Jun 11 '15 03:06 iangcarroll

Doesn't look like that's the case for me: drwxr-xr-x 1068 root wheel 36312 Jun 8 19:31 bin

Also, I'm able to run ar directly just fine. Same with gcc.

lukehoersten avatar Jun 11 '15 13:06 lukehoersten

/usr/bin/ar also seems to be affected by the new rootless "feature" introduced in 10.11. sudo chmod +x /usr/bin/ar (just as an example) says I do not have the permissions to modify this file.

However, disabling rootless (sudo nvram boot-args="rootless 0") does not solve the issue with cabal...

Codas avatar Jun 11 '15 14:06 Codas

Weirdly I was unable to move the binary with sudo. Is this a part of rootless as well? I've not yet heard of this feature.

lukehoersten avatar Jun 11 '15 16:06 lukehoersten

@Codas, are you sure that rootless really got disabled? there has been a bug with disabling it.

samfoy avatar Jun 11 '15 16:06 samfoy

You were right, rootless was not disabled as I thought it was. The problem is that sudo nvram boot-args="rootless 0" should really be sudo nvram boot-args="rootless=0".

Now everything seems to be working as expected.

Codas avatar Jun 11 '15 16:06 Codas

sudo nvram boot-args="rootless=0" worked for me as well. So we know what the problem is but now, how to fix this?

lukehoersten avatar Jun 11 '15 19:06 lukehoersten

You have to build to install using components that do not require root access. (and/or file a bug with Apple)

uchuugaka avatar Jun 21 '15 01:06 uchuugaka

@uchuugaka can you be more specific about what you mean by "build to install using components that do not require root access"?

lukehoersten avatar Jun 21 '15 17:06 lukehoersten

Simply disabling rootless isn't enough for everything. Many projects are waking up to realizing they need to find new places they can put things. Directories that are not locked down. I'm still looking into it. macports for example is finding they may need a new directory as their root.

uchuugaka avatar Jun 21 '15 17:06 uchuugaka

@uchuugaka Disabling rootless is only a workaround until a real fix is implemented. It doesn't sound like filing a bug with Apple is appropriate at this point.

lukehoersten avatar Jun 22 '15 18:06 lukehoersten

sudo nvram boot-args="rootless=0" did the trick for me on 10.11, but I'm not sure if it was a good idea.. haha

maddie927 avatar Jun 30 '15 05:06 maddie927

i had a problem making an alias for X11 in /usr, disabling rootless solved my problem, thanks all

PupaRebbe avatar Jul 06 '15 16:07 PupaRebbe

Rootless: Bans writing to /System, /usr, /bin, /sbin - So far /usr/local isn't write-protected.

Homebrew has to contend with the same thing: https://github.com/Homebrew/homebrew/issues/40837

lukehoersten avatar Jul 07 '15 16:07 lukehoersten

I don't understand how write-protection is preventing ar and gcc from being invoked, since we want to execute, not write. Can someone elaborate?

alexbiehl avatar Jul 11 '15 05:07 alexbiehl

It is strange that cabal install cabal-install works fine on my El Capitan but when I used stack it reported a similar error (see the issue mentioned by @alexbiehl ). Can you give me details about your settings @LukeHoersten ?

notcome avatar Jul 11 '15 18:07 notcome

@notcome settings for what in particular?

lukehoersten avatar Jul 13 '15 15:07 lukehoersten