LoginSignup
9
8

More than 5 years have passed since last update.

Alfred と brew cask が壊れた

Last updated at Posted at 2014-12-20

uninstall できない。Alfred でアプリを呼び出せないなど。

問題点

数ヶ月前からインストールやアップデートの挙動がおかしくなり、しばらく放置していた。

  1. .dmg や AppStore で /Applications へインストールしたアプリが Alfred.app から呼び出せない。
  2. brew cask で ~/Applications へインストールした 新しいアプリ が Alfred.app から呼び出せない。
  3. brew cask uninstall で 古いアプリ が消せない。

不便きわまりないので解決策を模索する。

原因

おそらく下記の絶妙なタイミングで、brew cask や Alfred.app をいろいろ触ってしまい、カオスになっている。

brew 0.9.5 changed tap directory structure and now no casks are found · Issue #4026 · caskroom/homebrew-cask

ひとつずつ確認しながら、解決してゆく。

状況

brew doctor はエラーなし。

% brew cask doctor
==> OS X Version:
10.9.5
==> Hardware Architecture:
intel-64
==> Ruby Version:
2.0.0-p481
==> Ruby Path:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
==> Homebrew Version:
0.9.5
==> Homebrew Executable Path:
/usr/local/bin/brew
==> Homebrew Cellar Path:
/usr/local/Cellar
==> Homebrew Repository Path:
/usr/local
==> Homebrew Origin:
https://github.com/Homebrew/homebrew
==> Homebrew-cask Version:
0.51.1
==> Homebrew-cask Install Location:
/usr/local/Cellar/brew-cask/0.51.1
==> Homebrew-cask Staging Location:
/opt/homebrew-cask/Caskroom
==> Homebrew-cask Cached Downloads:
/Library/Caches/Homebrew
/Library/Caches/Homebrew/Casks
0 files
0.00 megs
==> Homebrew-cask Default Tap Path:
/usr/local/Library/Taps/caskroom/homebrew-cask
==> Homebrew-cask Alternate Cask Taps:
/usr/local/Library/Taps/caskroom/homebrew-fonts
/usr/local/Library/Taps/caskroom/homebrew-versions
==> Homebrew-cask Default Tap Cask Count:
2178
==> Contents of $LOAD_PATH:
/usr/local/Cellar/brew-cask/0.51.1/rubylib
/usr/local/Cellar/brew-cask/0.51.1/rubylib/homebrew-fork/Library/Homebrew
/Library/Ruby/Site/2.0.0
/Library/Ruby/Site/2.0.0/x86_64-darwin13
/Library/Ruby/Site/2.0.0/universal-darwin13
/Library/Ruby/Site
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/vendor_ruby/2.0.0
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/vendor_ruby/2.0.0/x86_64-darwin13
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/vendor_ruby/2.0.0/universal-darwin13
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/vendor_ruby
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/x86_64-darwin13
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/universal-darwin13
==> Contents of $RUBYLIB Environment Variable:
<NONE>
==> Contents of $RUBYOPT Environment Variable:
<NONE>
==> Contents of $RUBYPATH Environment Variable:
<NONE>
==> Contents of $RBENV_VERSION Environment Variable:
<NONE>
==> Contents of $CHRUBY_VERSION Environment Variable:
<NONE>
==> Contents of $GEM_HOME Environment Variable:
<NONE>
==> Contents of $GEM_PATH Environment Variable:
<NONE>
==> Contents of $BUNDLE_PATH Environment Variable:
<NONE>
==> Contents of $PATH Environment Variable:
PATH="/Users/****/.rbenv/shims:/Users/****/bin:/Users/****/perl5/bin:/Users/****/.composer/vendor/bin:/usr/local/bin:/usr/sbin:/sbin:/usr/bin:/bin:/usr/local/Libr
ry/ENV/scm"
==> Contents of $SHELL Environment Variable:
SHELL="/usr/local/bin/zsh"
==> Contents of Locale Environment Variables:
LANG="ja_JP.UTF-8"
==> Running As Privileged User:
No

現行バージョンでは直っているはずだが状況は変わらない。

brew 0.9.5 changed tap directory structure and now no casks are found · Issue #4026 · caskroom/homebrew-cask

% brew update && brew upgrade brew-cask           
Already up-to-date.
Error: brew-cask-0.51.1 already installed
% brew tap
caskroom/cask
caskroom/fonts
caskroom/versions
sanemat/font
  • Alfred も動かない。
  • Alfred の Power pack は利用していない。
  • /opt/homebrew-cask/Caskroom を Alfred の Search Scope にいれても認識されない。
% brew cask alfred unlink && brew cask alfred link
==> 2014-12-19 16:37:27.314 defaults[8488:507] 
==> The domain/default pair of (/Users/****/Library/Preferences/com.runningwithcrayons.Alfred-Preferences, syncfolder) does not exist
Error: Alfred 2.4+ detected, but local preferences file not found. Try running Alfred first.
  • 過去に入れたアプリは認識されておらず、アンインストールもできない。
  • Alfred Search からは古いバージョンが認識されている。
% ls /opt/homebrew-cask/Caskroom/rubymine/        
6.3.1/ 7.0/
% brew cask uninstall rubymine                    
Error: rubymine is not installed

こういう問題もあるらしい。

Alfred 2.4+ detected, but local preferences file not found · Issue #8052 · caskroom/homebrew-cask

.dmg インストールしたアプリを呼び出す

まず以下を確認する。

  • .dmg や AppStore で /Applications へインストールしたアプリが Alfred.app から呼び出せない。

アプリをアンインストールする

まず brew cask uninstall できないアプリを手動アンインストールする。

  • ~/Applications 以下のエイリアスを削除。
  • Caskroom のアプリを削除。

ここでは Alfred と Rubymine を削除してみた。

% rm -rf /opt/homebrew-cask/Caskroom/rubymine
% ls /opt/homebrew-cask/Caskroom/alfred
2.1.1_227/
% rm -rf /opt/homebrew-cask/Caskroom/alfred

アプリをインストールし、設定を確認する

Rubymine と Alfred を .dmg からインストール。
Alfred の設定を確認する。

Alfred Preferences を開き、「Features > Serch Scope > Reset」を行う。

kobito.1418990208.734098.png

同じく「Advanced > Clear Application Cache」と「Advanced > Rebuild OS X Metadata」を実行してみる。

kobito.1418990310.786450.png

OS X の Spotlight うんぬんの表示がされるので、「システム環境設定 > Spotlight > プライバシー」を確認する。

kobito.1418990495.585787.png

自分のケースでは、身に覚えがないけれども何かの拍子に追加してしまったと思われる設定が見つかる。
具体的には システムディスクがまるごと除外対象 になっていた。。。

  • Spotlight の検索除外設定を消して、Alfred から /Applications にインストールした Rubymine、その他が呼び出せることを確認。
  • また、Search Scope に /opt/homebrew-cask/Caskroom/ を追加することで、cask アプリを呼び出せることを確認。

brew cask インストールしたアプリを呼び出す

次に以下を確認する。

  • brew cask で ~/Applications へインストールした 新しいアプリ が Alfred.app から呼び出せない。

brew cask でインストールする

  • Alfred と Rubymine を終了。
  • AppCleaner で念のためアンインストール(通常は設定やデータが消えるので行わない)。
  • brew cask で新規にインストールし直す。
% brew cask install alfred
==> Downloading https://cachefly.alfredapp.com/Alfred_2.5.1_308.zip
######################################################################## 100.0%
==> Symlinking App 'Alfred 2.app' to '/Users/****/Applications/Alfred 2.app'
==> Symlinking App 'Alfred Preferences.app' to '/Users/****/Applications/Alfred Preferences.app'
 alfred staged at '/opt/homebrew-cask/Caskroom/alfred/2.5.1_308' (267 files, 7.3M)
% brew cask install rubymine
==> Downloading http://download-cf.jetbrains.com/ruby/RubyMine-7.0.2.dmg
######################################################################## 100.0%
==> Symlinking App 'RubyMine.app' to '/Users/****/Applications/RubyMine.app'
 rubymine staged at '/opt/homebrew-cask/Caskroom/rubymine/7.0.2' (3726 files, 414M)
  • ~/Applications に Symlink ができたことを確認。
  • Alfred.app を起動し、リンクを張り直す。

以下のエラーが出たことを確認。

% brew cask alfred unlink && brew cask alfred link                                  
==> 2014-12-19 21:18:05.986 defaults[20709:507] 
==> The domain/default pair of (/Users/****/Library/Preferences/com.runningwithcrayons.Alfred-Preferences, syncfolder) does not exist
Error: Alfred 2.4+ detected, but local preferences file not found. Try running Alfred first.

このイシューに関連する問題か。

Alfred 2.4+ detected, but local preferences file not found · Issue #8052 · caskroom/homebrew-cask

設定を追加する

  • Alfred.app の Search Scope に /opt/homebrew-cask/Caskroom/ を追加することで、ひとまず cask アプリを呼び出すことができる。

kobito.1418992587.908131.png

brew cask が cask アプリを認識していない

最後に以下を確認する。

  • brew cask uninstall で 古いアプリ が消せない。

brew cask info を確認する

ここまで進めた状況で確認すると、brew cask info で認識される cask と、されない cask があることが分かった。

以前 rubymine も同じように Not installed と認識されていなかったが、前述の通りインストールし直したら認識した。

対象 cask を手動で消して、再インストールする。

認識されていない cask を再インストールする

手動だと間違えそうなのと今後も起こりえるので、こんなスクリプトを用意して実行する。

% ruby brew-cask-reinstall.rb           

brew cask list
["alfred", "appcleaner",
     : 
 "vagrant", "virtualbox", "xquartz"]

error casks
["sourcetree", "thunderbird-ja", "vagrant", "virtualbox"]

reinstall sourcetree? [y/n] y
remove sourcetree
install sourcetree
==> Caveats
Cask sourcetree installs files under "/usr/local".  The presence of such
files can cause warnings when running "brew doctor", which is considered
to be a bug in homebrew-cask.

==> Downloading https://downloads.atlassian.com/software/sourcetree/SourceTree_2.0.3.dmg
###############################################################################################################################
==> Symlinking App 'SourceTree.app' to '/Users/****/Applications/SourceTree.app'
==> Symlinking Binary 'stree' to '/usr/local/bin/stree'
 sourcetree staged at '/opt/homebrew-cask/Caskroom/sourcetree/2.0.3' (2163 files, 102M)
    :

もう一度実行して、no error が表示されれば完了。

% ruby brew-cask-reinstall.rb

brew cask list
["alfred", "appcleaner",
     : 
 "vagrant", "virtualbox", "xquartz"]

error casks
[]

no error

なお、この例では thunderbird-ja の古い cask が下記のように残ったので sudo で消した。

reinstall thunderbird-ja? [y/n] y
remove thunderbird-ja
rm: /opt/homebrew-cask/Caskroom/thunderbird-ja/24.2.0: Directory not empty
rm: /opt/homebrew-cask/Caskroom/thunderbird-ja: Directory not empty
install thunderbird-ja
==> Downloading https://download.mozilla.org/?product=thunderbird-31.1.1&os=osx&lang=ja-JP-mac

まとめ

  • Alfred.app の Search Scope は、OS X の Spotlight の影響を受けるので、 Spotlight の設定もあわせて確認 する。
  • brew cask したアプリが呼び出せない問題は、Alfred.app の対応待ち? Alfred.app の Search Scope に /opt/homebrew-cask/Caskroom/ を追加 して暫定対応する。
  • brew cask で認識できなくなったアプリは、 /opt/homebrew-cask/Caskroom/ から remove し、再インストール する。
  • バックアップを取ってから実行 すること。

補遺

下記を参考にさせて頂きました。

9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8