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 doctor reports new errors after using cask, uninstall/recovery unclear #47

Closed
mobilemind opened this issue Oct 11, 2012 · 27 comments
Closed

Comments

@mobilemind
Copy link

Please help.
How do I recover my brew configuration from problems relating to use of cask?

All I want is cask out of my system and brew back to normal.

Perhaps "brew cask UNinstall" commands, etc are needed.

For me, it seems like no combination of install/uninstall, tap/untap can recover brew & make the doctor happy.

Here's the issue I want to fix

$brew doctor
Error: Failed to import: chromium
Error: class "Create" expected but not found in create.rb
Double-check the name of the class in that formula.
Error: Failed to import: create
Error: Failed to import: thunderbird
Error: Failed to import: transmit

Here's the short version of how I got there...

  1. install cask, install the apps, decide cask isn't for me...
  2. rm -R /usr/local/Cellar/ the apps
  3. brew untap phinze/cask
    Now it seems like no combination of install/uninstall, tap/untap can recover brew

how I got there:

INSTALL CASK

$brew tap phinze/cask 
Cloning into '/usr/local/Library/Taps/phinze-cask'...
remote: Counting objects: 403, done.
remote: Compressing objects: 100% (256/256), done.
remote: Total 403 (delta 166), reused 376 (delta 141)
Receiving objects: 100% (403/403), 59.31 KiB, done.
Resolving deltas: 100% (166/166), done.
Tapped 1 formula
 $brew install brew-cask
==> Cloning https://github.com/phinze/homebrew-cask.git
Updating /Library/Caches/Homebrew/brew-cask--git
==> Checking out tag v0.3.3
/usr/local/Cellar/brew-cask/0.3.3: 61 files, 252K, built in 2 seconds

INSTALL APPS

$brew cask install google-chrome
==> Downloading https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg
######################################################################## 100.0%

==> Success! google-chrome installed to /usr/local/Cellar/google-chrome/stable-channel
$brew cask install thunderbird
==> Downloading http://download.mozilla.org/?product=thunderbird-15.0.1&os=osx&lang=en-US
######################################################################## 100.0%

==> Success! thunderbird installed to /usr/local/Cellar/thunderbird/15.0.1

$brew cask install transmit
==> Downloading http://www.panic.com/transmit/d/Transmit%204.2.zip
######################################################################## 100.0%

==> Success! transmit installed to /usr/local/Cellar/transmit/4.2

DELETE APPS
rm -R /usr/local/Cellar/google-chrome /usr/local/Cellar/thunderbird /usr/local/Cellar/transmit

UNINSTALL BREW-CASK

$brew uninstall brew-cask
Uninstalling /usr/local/Cellar/brew-cask/0.3.3...
tking@ember: ~ $brew untap phinze/cask 
Untapped 1 formula
@phinze
Copy link
Contributor

phinze commented Oct 11, 2012

Hey bud, sorry that this is giving you trouble.

Just wanted to let you know I'm looking at this now - I'll follow up when I've got more for ya.

@phinze
Copy link
Contributor

phinze commented Oct 11, 2012

Okay can't immediately reproduce here.

  1. Is your homebrew relatively recently updated? Output of git log -n1 /usr/local will verify that.
  2. Casks are also Kegs, so they can be uninstalled via the normal brew uninstall. Gotta document that in the readme and possibly also alias brew cask uninstall to help discoverability.

I'm still working on permutations here.

@phinze
Copy link
Contributor

phinze commented Oct 11, 2012

Note that the "expected" (yet to be resolved) output of brew doctor is something like the following:

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:        

    adium                                                                       
    alfred                                                                      
    ...
    (all casks you have installed)

@phinze
Copy link
Contributor

phinze commented Oct 11, 2012

Looking like no repro here just yet. Here's some help to what those error messages are pointing to though:

Error: class "Create" expected but not found in create.rb
Double-check the name of the class in that formula.

There's a stray create.rb in /usr/local. Probably under /usr/local/Library/Formula/. You can find it with:

find /usr/local -name 'create.rb'

The contents and location of that file should point to the problem.

Error: Failed to import: {chromium, thunderbird, transmit}

I'm wondering if the cask source files somehow made it directly in your Formula directory? brew-cask wouldn't do this, but you should be able to track them down via the same strategy:

find /usr/local -name 'chromium*'

Don't worry - we'll get this sorted out for you.

@ghost ghost assigned phinze Oct 11, 2012
@passcod
Copy link
Contributor

passcod commented Oct 11, 2012

This is a problem even without uninstalling, as it seems something somewhere creates symlinks for all .rb files in the phinze-cask tap into Library/Formula. Until the root cause is discovered, and fixed, this fixes the problem:

cd /usr/local/Library/Formula
ls -shal |grep "phinze-cask" |grep -oP "(?<=\d{2}:\d{2}\s)[\w\.\-]+" |xargs rm
#        Find all cask symlinks      Extract the filename out          Delete

Unfortunately, that won't work with OS X's grep (I use brew's grep for its -P support) but you should be able to whip up something using cut or a simpler -E regexp.

@phinze
Copy link
Contributor

phinze commented Oct 11, 2012

ick - lemme track that down.

@phinze
Copy link
Contributor

phinze commented Oct 11, 2012

Yay, repro!

Homebrew/legacy-homebrew@e613cbe

@passcod @mobilemind can you tell me if your homebrew installation comes from a sha before or after that commit?

if i check out that commit's parent, i get the old liberal Tap linking code that makes symlinks all over the place. 👎

code newer than that commit works just peachy. 🍑

@phinze
Copy link
Contributor

phinze commented Oct 11, 2012

also here's a cleanup one-liner that doesn't rely on brew's grep:

ls -l /usr/local/Library/Formula | grep phinze-cask | awk '{print $9}' | for evil_symlink in $(cat -); do rm -v /usr/local/Library/Formula/$evil_symlink; done

@mobilemind
Copy link
Author

I believe mine was an earlier commit, based on commit time stamp & my recollection. I did a complete uninstall of brew and all bottles, kegs, taps, app casks & formulae. I'm willing to test a future release of cask.

@ghost
Copy link

ghost commented Oct 13, 2012

+1 for aliasing brew cask uninstall

phinze added a commit that referenced this issue Oct 20, 2012
this delegates to homebrew's uninstall to get its work done. vanilla
`brew uninstall` actually works, but this gives us a more consistent
interface.

as discussed in #47
phinze added a commit that referenced this issue Oct 20, 2012
homebrew does internal caching in ARGV that prevents us from doing the
`ARGV.clear; ARGV << 'newarg'` trick twice.

rather than try to further reach in to homebrew's innards, i figure it's
better to just pass multiple arguments down to homebrew code at once,
since it already supports that

refs #47
@phinze
Copy link
Contributor

phinze commented Oct 20, 2012

Okay I just cut 'v0.4.0' which includes a brew cask uninstall command, and I also added a notation to the README stating that we depend on Homebrew 0.9 and higher, which should hopefully prevent people from running into this problem again.

I think that takes care of everything on this thread. I'm gonna close this issue - feel free to reopen if I missed something.

@passcod
Copy link
Contributor

passcod commented May 7, 2013

This is appearing again, reopening.

@passcod passcod reopened this May 7, 2013
@bcomnes
Copy link
Contributor

bcomnes commented May 8, 2013

I had this error, and I un-tapped and uninstalled cask, which did not clear up the error in brew docotor. A quick brew cleanup fixed the brew doctor errors. I have not re-installed cask yet.

@phinze
Copy link
Contributor

phinze commented May 12, 2013

I had a couple of these hanging out in brew doctor. Running the above command cleaned them out, then I untapped and retapped to see if the links came back, and everything is back to normal.

Last time this happened it was homebrew's over-zealous formula linking. I took a look at the git log on tap and pathname, and I didn't see anything new that would be problematic.

Is it possible that we just have more people installing homebrew-cask with super-old versions of homebrew on their machines? Or is there some other cause?

People experiencing this, any more details you can provide would be helpful. 🚁

@vitorgalvao
Copy link
Member

As far as I can tell, this happens only when (and every time) a new cask is added. After you run the command that removes the links, it stops acting on those until a new cask is contributed, at which point it’ll start showing the error on that one.

@phinze
Copy link
Contributor

phinze commented May 12, 2013

Ooooh @vitorgalvao that helps. That would mean the problem is in the brew update code path. There's a lot of code to dig into around Report#new_tapped_formula that I think might hold the source of the problem.

@ghost
Copy link

ghost commented May 12, 2013

Seconding @vitorgalvao's observation. I cleaned everything out about a week ago and started over and although it was fine at first, it's started showing up again. Hopefully the cause has been pinpointed.

@phinze
Copy link
Contributor

phinze commented May 13, 2013

@darinmorrison yeah I'm pretty sure I've got the problem isolated; we'll see if the homebrew folks concur over at Homebrew/legacy-homebrew#19743

basically the brew update code considers **/*.rb to all be tapped formulas, while brew tap only considers .rb files in certain folders to be valid formulas. so when a new Cask shows up in an update, it gets linked as a formula. bad homebrew! 🐶

since the problem stems from homebrew code - i'd like to avoid trying to work around it in our codebase. but we'll have to see if i can get any traction on that issue. 🚜

@bryanstedman
Copy link
Contributor

I had this issue and ran the above command to solve it. I am getting another error when running brew cask list and iterm2 is crashing a lot now. Here is the out put for brew cask list:

Error: undefined method `link' for Acorn:Class
Please report this bug:
    https://github.com/mxcl/homebrew/wiki/troubleshooting
/usr/local/Library/Taps/phinze-cask/Casks/acorn.rb:6
/usr/local/Cellar/brew-cask/0.6.0/rubylib/cask.rb:46:in `require'
/usr/local/Cellar/brew-cask/0.6.0/rubylib/cask.rb:46:in `load'
/usr/local/Cellar/brew-cask/0.6.0/rubylib/cask/scopes.rb:26:in `installed'
/usr/local/Cellar/brew-cask/0.6.0/rubylib/cask/scopes.rb:26:in `select'
/usr/local/Cellar/brew-cask/0.6.0/rubylib/cask/scopes.rb:26:in `installed'
/usr/local/Cellar/brew-cask/0.6.0/rubylib/cask/cli/list.rb:3:in `run'
/usr/local/Cellar/brew-cask/0.6.0/rubylib/cask/cli.rb:21:in `process'
/usr/local/bin/brew-cask.rb:6
/usr/local/Library/brew.rb:51:in `require'
/usr/local/Library/brew.rb:51:in `require?'
/usr/local/Library/brew.rb:93 

Is this related or a separate issue? Thanks!

@vitorgalvao
Copy link
Member

It seems unlikely the iTerm2 crashes would be related — homebrew-cask can install it, but after that it’s left to its own devices. Have you updated recently (brew update && brew upgrade brew-cask)?

@bryanstedman
Copy link
Contributor

You are right - iTerm crashing was unrelated. I had some zsh config messed up. Sorry for the unnecessary post.

@vitorgalvao
Copy link
Member

It’s not unnecessary if you’re still having the problem — the iTerm issue might’ve been unrelated, but the brew cask one shouldn’t be. Did you run the update command, and if yes, did it make any difference?

@bryanstedman
Copy link
Contributor

Thanks for the follow up @vitorgalvao I had run the update command before posting and it didn't help. While I was trying to fix the zsh issue I ended up uninstalling and reinstalling brew-cask and that solved my issue.

@phinze
Copy link
Contributor

phinze commented Jul 9, 2013

Working on a PR for papa homebrew for this tonight.

@phinze
Copy link
Contributor

phinze commented Jul 9, 2013

okay Homebrew/legacy-homebrew#21087 is up; now it's all up to the gods of homebrew. 🙏 😀

@phinze
Copy link
Contributor

phinze commented Jul 10, 2013

Alright folks - lets cross our fingers and close this issue. Then hopefully it'll never happen again! 🎲

@phinze phinze closed this as completed Jul 10, 2013
@fuadsaud
Copy link
Contributor

hooray!

@sudomakesandwich
Copy link

I had the same problem. A warning while brew doctor. Working on the latest Version of OSC 10.9 XCode and homebrew. But the ls command mentioned at the beginning fixed it for me. If you need further dates to help you find a solution let me know what you need

fharbe pushed a commit to fharbe/homebrew-cask that referenced this issue Mar 11, 2014
Move IntelliJ Ultimate 12 to caskroom
@Homebrew Homebrew locked and limited conversation to collaborators May 8, 2018
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

8 participants