`ar` permission errors on OS X 10.11 `El Capitan` with GHC 7.8.4
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.
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.
I tried copying to my home dir and it still had the permission issue.
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.
/usr/bin appears read-only on 10.11.
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.
/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...
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.
@Codas, are you sure that rootless really got disabled? there has been a bug with disabling it.
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.
sudo nvram boot-args="rootless=0" worked for me as well. So we know what the problem is but now, how to fix this?
You have to build to install using components that do not require root access. (and/or file a bug with Apple)
@uchuugaka can you be more specific about what you mean by "build to install using components that do not require root access"?
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 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.
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
i had a problem making an alias for X11 in /usr, disabling rootless solved my problem, thanks all
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
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?
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 settings for what in particular?