Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brew cleanup: Error: Permission denied @ apply2files #45009

Closed
3 of 6 tasks
phdoerfler opened this issue Oct 8, 2019 · 34 comments
Closed
3 of 6 tasks

brew cleanup: Error: Permission denied @ apply2files #45009

phdoerfler opened this issue Oct 8, 2019 · 34 comments

Comments

@phdoerfler
Copy link

phdoerfler commented Oct 8, 2019

To help us debug your issue please explain:

  • What you were trying to do (and why)

brew cleanup

  • What happened (include command output)
/* Many many lines by TapLoader and FormulaLoader skipped */
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-science/Formula/qhull.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/qhull.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/handbrake.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FormulaLoader): loading /usr/local/Homebrew/Library/Taps/railwaycat/homebrew-emacsmacport/Formula/emacs-mac.rb
Error: Permission denied @ apply2files - /usr/local/lib/python3.5/site-packages/sphinx/locale/.DS_Store
/usr/local/Homebrew/Library/Homebrew/cleanup.rb:388:in `unlink'
/usr/local/Homebrew/Library/Homebrew/cleanup.rb:388:in `unlink'
/usr/local/Homebrew/Library/Homebrew/cleanup.rb:388:in `each'
/usr/local/Homebrew/Library/Homebrew/cleanup.rb:388:in `rm_ds_store'
/usr/local/Homebrew/Library/Homebrew/cleanup.rb:177:in `clean!'
/usr/local/Homebrew/Library/Homebrew/cmd/cleanup.rb:42:in `cleanup'
/usr/local/Homebrew/Library/Homebrew/brew.rb:102:in `<main>'
  • What you expected to happen

The command completing successfully

  • Step-by-step reproduction instructions (by running brew install commands)

brew cleanup or brew cleanup -d -v

@phdoerfler phdoerfler reopened this Oct 8, 2019
@SMillerDev
Copy link
Member

Could you fill out the issue template please? It's pretty essential in debugging issues. This issue can be reopened once we have all the information needed to start debugging.

@phdoerfler
Copy link
Author

phdoerfler commented Oct 8, 2019

@SMillerDev Yes of course. Sorry for the mess, I accidentally hit the enter key in the title and that submitted this form before I had a chance to fill it out

@phdoerfler
Copy link
Author

phdoerfler commented Oct 8, 2019

I noticed brew doctor complaining about the ruby version installed being way newer than what homebrew supports so this will be my working theory for now. We can keep this issue closed until I confirm otherwise I suppose.

Warning: Ruby version 2.6.3 is unsupported on 10.15. Homebrew
is developed and tested on Ruby 2.3.7, and may not work correctly
on other Rubies. Patches are accepted as long as they don't cause breakage
on supported Rubies.

@phdoerfler
Copy link
Author

OK now that I had my coffee I see that of course this is likely unrelated to the ruby version mismatch. My apologies. I would like to reopen the issue again so we can discuss if this permission issue is something brew should even address or if this is a fix on a case-by-case basis type of problem.

@phdoerfler phdoerfler changed the title brew cleanup brew cleanup: Error: Permission denied @ apply2files Oct 8, 2019
@SMillerDev SMillerDev reopened this Oct 8, 2019
@SMillerDev
Copy link
Member

What does brew doctor tell you?

@phdoerfler
Copy link
Author

Quite a lot I'm afraid. I'm chewing down on these items as we speak:

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
  /usr/local/miniconda3/bin/python3.7-config
  /usr/local/miniconda3/bin/python3.7m-config
  /usr/local/miniconda3/bin/python3-config
  /usr/local/miniconda3/bin/ncursesw6-config

Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  ghc@8.0
  ponysay-tool
  ponythink
  suite-sparse421
  qt@5.7
  gnupg

Warning: Some installed formulae are not readable:
  ghc@8.0: unknown version :lion

  qt@5.7: unknown version :mountain_lion

Warning: Ruby version 2.6.3 is unsupported on 10.15. Homebrew
is developed and tested on Ruby 2.3.7, and may not work correctly
on other Rubies. Patches are accepted as long as they don't cause breakage
on supported Rubies.

Warning: Your Xcode (11.0) is outdated.
Please update to Xcode 11.1 (or delete it).
Xcode can be updated from the App Store.

The Xcode update is downloading right now but it's taking its sweet little time. I'll report back once it's done.

@SMillerDev
Copy link
Member

You also seem to have a very old homebrew formula version that it's refering to :lion.

This doesn't say anything about permission issues though, which is good. What does ls -ld /usr/local/lib/python* say?

@phdoerfler
Copy link
Author

phdoerfler commented Oct 8, 2019

$ unalias ls
$ ls -ld /usr/local/lib/python*
drwxr-xr-x@ 3 phi  admin  96 20 Oct  2014 /usr/local/lib/python2.7
drwxr-xr-x@ 3 phi  admin  96 21 Oct  2014 /usr/local/lib/python3.4
drwxr-xr-x@ 3 phi  admin  96 14 Oct  2015 /usr/local/lib/python3.5
drwxr-xr-x@ 3 phi  admin  96 30 Dec  2016 /usr/local/lib/python3.6
drwxr-xr-x  3 phi  admin  96 20 Aug  2018 /usr/local/lib/python3.7

@michaelwalkerfl
Copy link

michaelwalkerfl commented Oct 10, 2019

I encountered this same error after upgrading to Catalina. I solved by uninstalling xcode and reinstalling from app store. Then deleted Library/Caches/Homebrew/.cleaned, afterwards brew behaves as expected for brew cleanup

@phdoerfler
Copy link
Author

I got brew doctor down to this now:

brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
  /usr/local/miniconda3/bin/python3.7-config
  /usr/local/miniconda3/bin/python3.7m-config
  /usr/local/miniconda3/bin/python3-config
  /usr/local/miniconda3/bin/ncursesw6-config

The issue persists.

And don't quite know how to best fix that last warning of brew doctor. I use miniconda and don't want to mess with it really.

I tried @michaelwalkerfl's suggestion but Xcode takes hours and hours to download (no idea why) and still has not finished and whilst I deleted aforementioned .cleaned file after I had uninstalled it this was not sufficient for brew cleanup to work. But, again, Xcode hasn't finished downloading yet so hopefully tomorrow I can tell more.

@phdoerfler
Copy link
Author

Xcode has since completed installation. The .cleaned file is still removed and whilst brew seems to be able to clean up some packages, it eventually still fails:

brew cleanup
Alias tip: brewc
Removing: /Users/phi/Library/Caches/Homebrew/pandoc--2.7.3.mojave.bottle.tar.gz... (13.7MB)
Removing: /Users/phi/Library/Caches/Homebrew/pstoedit--3.74.mojave.bottle.tar.gz... (797.9KB)
Removing: /Users/phi/Library/Caches/Homebrew/source-highlight--3.1.8_12.mojave.bottle.tar.gz... (2MB)
Error: Permission denied @ apply2files - /usr/local/lib/python3.5/site-packages/sphinx/locale/.DS_Store

Unfortunately the workaround presented by @michaelwalkerfl does not seem to solve the issue in my case.

@anasAlsalol
Copy link

this work for me . .. Remove and reinstall brew .
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

@doublesharp
Copy link

doublesharp commented Oct 18, 2019

@anasAlsalol Want to add that when you uninstall/reinstall it will also remove all of the packages installed by brew.

@phdoerfler I was able to fix this on my machine (OSX Mojave 10.14.6) by resetting the permissions in /usr/local:

sudo chown -R $(whoami):admin /usr/local/* \
&& sudo chmod -R g+rwx /usr/local/*

Once brew was running again I reinstalled all the packages with brew list | xargs brew reinstall. Seems to be working so far...

FWIW I mapped the Ruby 2.3 headers to get docker-sync running, from this post: castwide/vscode-solargraph#78 (comment)

@derwaldgeist
Copy link

derwaldgeist commented Oct 19, 2019

Same problem here, always related to the same file:

Error: Permission denied @ apply2files - /usr/local/share/Library/Caches/Yarn/v1/npm-micromatch-3.1.5-d05e168c206472dfbca985bfef4f57797b4cd4ba/lib/.DS_Store

I chmod'ed it to a+rwx, but still the problem persisted. Once I removed the file, the same problem appeared with another .DS_Store file in the Yarn caches folder. I was able to resolve this by removing the whole Yarn cache, i.e.

sudo rm -r /usr/local/share/Library/Caches/Yarn/v1/

Not sure if this causes unwanted side-effects, though.

@doublesharp
Copy link

@derwaldgeist you might have needed to change the ownership as well, but deleting that folder should be fine since it it will be rebuilt when you run yarn.

@mrshannonyoung
Copy link

This worked for me:


sudo yarn cache clean
brew cleanup

@bradparks
Copy link

bradparks commented Oct 25, 2019

The only thing that worked for me was to chmod the folder of the offending program so it could be deleted, so I dont think this was a brew issue, but a permissions issue I probably caused in some other way ...

e.g.

$ sudo chmod -R 777 /usr/local/lib/python3.6/site-packages/openpyxl-2.5.1.dist-info

@phdoerfler
Copy link
Author

I ended up with

sudo chown -R $(whoami):wheel /usr/local/lib/python3.5/site-packages/sphinx

which did the trick. Is there any chance of brew becoming smart enough to do on its own?

@SMillerDev
Copy link
Member

It does that on install. And at no other point will brew ever have the right to change permissions so it can't.

@rsclarke-vgw
Copy link

Similar problem;

==> `brew cleanup` has not been run in 30 days, running now...
Error: Permission denied @ apply2files - /usr/local/lib/docker/cli-plugins

Which was a symlink pointing to a non existent folder at /Applications/Docker.app/Contents/Resources/cli-plugins.

mkdir -p /Applications/Docker.app/Contents/Resources/cli-plugins
brew cleanup

All good :)

@archmagees
Copy link

This fix the bug:

sudo chown -R "$(whoami)":admin /usr/local/lib

If you are fish shell, this works

sudo chown -R (whoami):admin /usr/local/lib

First answer in stackoverflow is valid.

@jimtje
Copy link

jimtje commented Nov 29, 2019

I ran into the issue except it turned out that it's a nonexistent file.

Running:

touch /usr/local/lib/node_modules/node-red/node_modules/@node-red/nodes/.DS_Store

fixed it for me

@adamtheadmin
Copy link

sudo chown -R $(whoami) $(brew --prefix)/*

@SMillerDev
Copy link
Member

All these posted fixes are also documented in docs.brew.sh. Gonna close this since we don't need more copies

@Mattia541993
Copy link

@doublesharp worked for me! Thanks!

@MichelBras
Copy link

@rsclarke-vgw

Similar problem;

==> `brew cleanup` has not been run in 30 days, running now...
Error: Permission denied @ apply2files - /usr/local/lib/docker/cli-plugins

Which was a symlink pointing to a non existent folder at /Applications/Docker.app/Contents/Resources/cli-plugins.

mkdir -p /Applications/Docker.app/Contents/Resources/cli-plugins
brew cleanup

All good :)

Did the job for me! thanks

@porcupinenick
Copy link

@rsclarke-vgw I'm getting this problem:

Error: Permission denied @ apply2files - /usr/local/lib/ruby/gems/2.6.0/gems/fastlane-2.123.0/spaceship/lib/spaceship/connect_api/.DS_Store

  1. How did you know that the symlink was pointing to a non-existent folder?
  2. You are working with Docker, an application. My problem is with Ruby, not an application. Would I just create a folder within the /usr/local/lib/ruby directory?

@doublesharp
Copy link

@nickycutesc see my post above to reset the permissions, or you can just delete that file and try it again -

sudo rm /usr/local/lib/ruby/gems/2.6.0/gems/fastlane-2.123.0/spaceship/lib/spaceship/connect_api/.DS_Store

@porcupinenick
Copy link

@doublesharp will do, thanks!

@imeuro
Copy link

imeuro commented Jan 7, 2020

chown, chmod and mkdir -p didn't do it for me, i aggressively ended up with a sudo rm -rf the whole /usr/local/lib/docker/cli-plugins directory...
hope i didn't break anything else...

@mgifford
Copy link

If this is a symbolic link, the challenge could be with the destination directory:
/usr/local/lib/docker/cli-plugins -> /Applications/Docker.app/Contents/Resources/cli-plugins

@thubamamba
Copy link

Similar problem;

==> `brew cleanup` has not been run in 30 days, running now...
Error: Permission denied @ apply2files - /usr/local/lib/docker/cli-plugins

Which was a symlink pointing to a non existent folder at /Applications/Docker.app/Contents/Resources/cli-plugins.

mkdir -p /Applications/Docker.app/Contents/Resources/cli-plugins
brew cleanup

All good :)

Worked for me. Thank you.

@yabetsu93
Copy link

this command works for me

sudo chmod -R g+rwx /usr/local/*

all upgrade install smoothly, be careful when deleting the path where you found denied on brew.

@rob3c
Copy link

rob3c commented Feb 26, 2020

@SMillerDev These fixes may be buried in docs.brew.sh somewhere, but this is where google is clearly sending people like me. The brew docs don't even make first page results for the keywords that got me here (and likely others, too). I certainly appreciate the redundant copies here, so thanks everyone!

@Homebrew Homebrew locked as resolved and limited conversation to collaborators Feb 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests