not able to install anything because of brew no such file or directory error
Asked Answered
A

9

42

I am trying to install do brew install python3 on my mac but i keep getting the following errors:

this is the first error:

No such file or directory @ dir_chdir - /usr/local/Cellar

then a bit later i get this error:

An exception occurred within a child process: Errno::EPERM: Operation not permitted @ dir_s_mkdir - /usr/local/Cellar

I have ran brew update then brew doctor the brew cleanup but keep getting the error.
I have also checked to see if xcode is up-to-date but according to the appstore all my apps are up-to-date.

How do i fix this problem?

PS i also get these errors when trying to install other packages from brew.

Aggregate answered 5/2, 2019 at 21:58 Comment(0)
A
31

Try uninstalling Homebrew and then re-installing solved issue for me.

Uninstall Homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

Re-install Homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Performed in MacOS Mojave (10.14.4)

Acheron answered 9/4, 2019 at 7:13 Comment(8)
This make me resintall tmuxZany
Dont do this, it will make you reinstall a lot of stuffAryn
Uninstalling Homebrew will also uninstall a lot of your installed packages.Tumpline
that means uninstalling all formaulae with it..!Allspice
Worked for me on linux. After uninstalling and before reinstalling, I threw in a rm -rf /home/linuxbrew for good measure.Burgonet
When doing this, and not removing all applications, brew returns after the reinstall a empty list. Even when applications are installed which where installed by brew. Not a good solution.Streamlined
DO NOT DO THIS. THIS WILL UNINSTALL A LOT OF THINGSBenford
DO NOT DO this - makes things worseCopley
I
55

Happened to me when uninstalling Laravel Valet.

Fixed by running: brew doctor, then brew cleanup after. After that - brew install php worked just fine.

Ibbie answered 4/11, 2022 at 22:34 Comment(4)
This is it, Try it out and it'll work.Loan
Yep this worked perfectly... should be best answerMalayan
It works for me, but it's not the answer to this question because OP has done these already.Merril
The best answer!Shall
A
31

Try uninstalling Homebrew and then re-installing solved issue for me.

Uninstall Homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

Re-install Homebrew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Performed in MacOS Mojave (10.14.4)

Acheron answered 9/4, 2019 at 7:13 Comment(8)
This make me resintall tmuxZany
Dont do this, it will make you reinstall a lot of stuffAryn
Uninstalling Homebrew will also uninstall a lot of your installed packages.Tumpline
that means uninstalling all formaulae with it..!Allspice
Worked for me on linux. After uninstalling and before reinstalling, I threw in a rm -rf /home/linuxbrew for good measure.Burgonet
When doing this, and not removing all applications, brew returns after the reinstall a empty list. Even when applications are installed which where installed by brew. Not a good solution.Streamlined
DO NOT DO THIS. THIS WILL UNINSTALL A LOT OF THINGSBenford
DO NOT DO this - makes things worseCopley
A
10

I experienced a similar error with a different package - brew install llvm.

Uninstalling homebrew and reinstalling led to more catastrophic issues that lasted for hours before I had to reach for my backup drive and restore everything. What eventually worked was just creating the missing directory and everything worked. So in this case:

sudo mkdir /usr/local/Cellar/dir_chdir

should solve the issue without too much hustle.

Autotrophic answered 9/6, 2020 at 11:17 Comment(0)
C
2

It worked for me after running below commands

sudo mkdir /usr/local/Cellar/dir_chdir
sudo chown -R $(whoami) /usr/local/Cellar
chmod u+w /usr/local/Cellar
Clemmy answered 27/1, 2021 at 7:39 Comment(0)
F
2

After doing sudo i was getting this error: bash: /bin/brew: No such file or directory.

i fixed it like this. Open your .bashrc file.

vim ~/.bashrc

and close the last line as a comment.

#eval "$(/bin/brew shellenv)"
Fourth answered 22/2 at 7:36 Comment(0)
M
1

I had this problem as well - it was partly coming from brew being installed under a different user on my mac I had set up for a past project. I had to follow the uninstall instructions (found in the homebrew github) with a little bit of sudo help and it cleared up the issue. Was able to install and properly run packages after.

Manse answered 1/1, 2022 at 19:5 Comment(0)
S
0

uninstall brew :

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

and again reinstall brew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 

executed this same as it is on your terminal, it will really work.

Sportscast answered 4/2, 2023 at 5:52 Comment(0)
S
0

These commands worked for me!

brew doctor
brew autoremove
brew cleanup
Shall answered 30/12, 2023 at 3:11 Comment(0)
T
-1

enter image description here

For ubuntu just go to the location which u are getting error. Then open the contained file using a suitable application. In my case, it is getting as follows in the image view.

enter image description here

In this case, the error is showing in 36's lines.

enter image description here

yes. There is no location such as. I have to find out the location which contains brew. It was in /home/linuxbrew/.linuxbrew//bin/brew shellenv

So update your .profile file as in the brew file contains location as follows image shown.

enter image description here

Traject answered 20/7, 2020 at 15:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.