Skip to content
Advertisement

Unable to change file mode on bin: Operation not permitted

I’m trying to install Composer globally on Mac OS.

I tried to move the composer.phar file by using this command in Terminal as instructed in the Getting Started section:

JavaScript

I get this error:

JavaScript

When I try create the directory it says the operation is not permitted:

JavaScript

I even tried to navigate to the “bin” directory and it says:

JavaScript

I’ve enabled root successfully but still I try and alter the permissions:

JavaScript

What am I doing wrong here?

Thanks in advance!

EDIT:

Thanks for the responses!

When I type the following command:

JavaScript

It prints:

JavaScript

Advertisement

Answer

Background: /usr/bin is generally for “standard” binaries, not things you install yourself; those generally belong someplace like /usr/local/bin. In recent versions of macOS, this is enforced by System Integrity Protection and by keeping “system” files/directories on a separate, read-only volume.

The problem: It looks like on your system, there’s a file named /usr/local/bin rather than a directory. This can happen if some installer tries to install a program to /usr/local/bin (e.g. with mv someprogram /usr/local/bin) without first making sure a directory by that name exists.

How to solve it: The first thing to do is to move/rename whatever file got installed as /usr/local/bin, and then create it as a directory:

JavaScript

Once that’s straightened out, you should be able to install composer normally. According to this (and adding sudo to get access to the directory), you’d do that with:

JavaScript

Finally, if you want to, you can try to figure out what program got installed as (rather than in) /usr/local/bin. Or just delete the /usr/local/bin-moved file and don’t worry about it.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement