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:

mv composer.phar /usr/bin/composer

I get this error:

mv: rename composer.phar to /usr/bin/composer: No such file or
directory

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

bash-3.2# mkdir -p /usr/bin/composer mkdir: /usr/bin/composer:
Operation not permitted

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

bash-3.2# mkdir composer mkdir: composer: Operation not permitted

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

bash-3.2# chmod ugo+rwx "bin" chmod: Unable to change file mode on
bin: Operation not permitted bash-3.2#

What am I doing wrong here?

Thanks in advance!

EDIT:

Thanks for the responses!

When I type the following command:

ls -leO@d /usr/local/bin

It prints:

-rwxrwxr-x 1 username staff  - 2212003 27 Mar 17:00 /usr/local/bin

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:

sudo mv /usr/local/bin /usr/local/bin-moved
sudo mkdir -p /usr/local/bin

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:

sudo mv composer.phar /usr/local/bin/composer

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