[Mac] 將 Homebrew Cask 安裝的 app 搬移到新的路徑 /usr/local/Caskroom 下

[Mac] 將 Homebrew Cask 安裝的 app 搬移到新的路徑 /usr/local/Caskroom 下

最近用 Homebrew Cask 的時候,常常會出現下面的警告訊息,

說用 Homebrew Cask 安裝的 app 的預設路徑已經被改到 /usr/local/Caskroom 了:

Warning: The default Caskroom location has moved to /usr/local/Caskroom.
Please migrate your Casks to the new location and delete /opt/homebrew-cask/Caskroom,
or if you would like to keep your Caskroom at /opt/homebrew-cask/Caskroom, add the
following to your HOMEBREW_CASK_OPTS:
--caskroom=/opt/homebrew-cask/Caskroom
For more details on each of those options, see https://github.com/caskroom/homebrew-cask/issues/21913.

 

連到訊息下面的網址 (也就是 caskroom: How to migrate to the new location?) 看一下討論,

原本 Homebrew Cask 會將 app 裝在 /opt/homebrew-cask/Caskroom 下面,

然後在 ~/Applications 下建立對應的 symbolic link:

testuser@localhost ~ $ ll ~/Applications/
total 168
lrwxr-xr-x   1 testuser  staff   81 May 17 08:08 Android Studio.app@ -> /opt/homebrew-cask/Caskroom/android-studio/2.1.1.0,143.2821654/Android Studio.app
lrwxr-xr-x   1 testuser  staff   59 Oct 13  2015 AppCleaner.app@ -> /opt/homebrew-cask/Caskroom/appcleaner/3.0.2/AppCleaner.app
lrwxr-xr-x   1 testuser  staff   51 Aug 27  2015 Appium.app@ -> /opt/homebrew-cask/Caskroom/appium/1.3.7/Appium.app
lrwxr-xr-x   1 testuser  staff   73 Jun 29  2015 Beyond Compare.app@ -> /opt/homebrew-cask/Caskroom/beyond-compare/4.0.7.19761/Beyond Compare.app
drwx------@ 16 testuser  staff  544 Jul 16 12:26 Chrome Apps.localized/
lrwxr-xr-x   1 testuser  staff   63 Jul  3  2015 ControlPlane.app@ -> /opt/homebrew-cask/Caskroom/controlplane/1.5.7/ControlPlane.app
lrwxr-xr-x   1 testuser  staff   55 Nov 27  2015 DiskWave.app@ -> /opt/homebrew-cask/Caskroom/diskwave/0.4.0/DiskWave.app
lrwxr-xr-x   1 testuser  staff   54 Jun 29  2015 Dropbox.app@ -> /opt/homebrew-cask/Caskroom/dropbox/latest/Dropbox.app
lrwxr-xr-x   1 testuser  staff   60 Sep 10  2015 Evernote.app@ -> /opt/homebrew-cask/Caskroom/evernote/6.1_452115/Evernote.app
lrwxr-xr-x   1 testuser  staff   60 Jul  6  2015 FileZilla.app@ -> /opt/homebrew-cask/Caskroom/filezilla/3.11.0.2/FileZilla.app
lrwxr-xr-x   1 testuser  staff   52 Jul  7  2015 Firefox.app@ -> /opt/homebrew-cask/Caskroom/firefox/39.0/Firefox.app
lrwxr-xr-x   1 testuser  staff   59 Sep  7  2015 ImageOptim.app@ -> /opt/homebrew-cask/Caskroom/imageoptim/1.6.0/ImageOptim.app
lrwxr-xr-x   1 testuser  staff   60 Oct 28  2015 LiveReload.app@ -> /opt/homebrew-cask/Caskroom/livereload/2.3.74/LiveReload.app
lrwxr-xr-x   1 testuser  staff   47 Jan 18  2016 Pinta.app@ -> /opt/homebrew-cask/Caskroom/pinta/1.6/Pinta.app
lrwxr-xr-x   1 testuser  staff   56 Feb 14 00:43 Seashore.app@ -> /opt/homebrew-cask/Caskroom/seashore/latest/Seashore.app
lrwxr-xr-x   1 testuser  staff   53 Feb  7 11:54 ShiftIt.app@ -> /opt/homebrew-cask/Caskroom/shiftit/1.6.3/ShiftIt.app
lrwxr-xr-x   1 testuser  staff   57 May 24 00:41 SourceTree.app@ -> /opt/homebrew-cask/Caskroom/sourcetree/2.3/SourceTree.app
lrwxr-xr-x   1 testuser  staff   45 Mar 18 13:16 VLC.app@ -> /opt/homebrew-cask/Caskroom/vlc/2.2.2/VLC.app
lrwxr-xr-x   1 testuser  staff   64 Dec  5  2015 XMind.app@ -> /opt/homebrew-cask/Caskroom/xmind/3.6.0.R-201511090408/XMind.app
lrwxr-xr-x   1 testuser  staff   62 Feb 28 22:31 iTerm.app@ -> /opt/homebrew-cask/Caskroom/iterm2-beta/2.9.20160206/iTerm.app
lrwxr-xr-x   1 testuser  staff   54 Sep 17  2015 p4v.app@ -> /opt/homebrew-cask/Caskroom/p4v/2014.3-1007540/p4v.app
lrwxr-xr-x   1 testuser  staff   67 May  5 15:32 unetbootin.app@ -> /opt/homebrew-cask/Caskroom/unetbootin/613,212083654/unetbootin.app

 

現在等於是要把 /opt/homebrew-cask/Caskroom 改到 /usr/local/Caskroom,

然後也要將 symbolic link 重新指向新的位置~

有人已經提供寫好的 shell 指令來做這件事情:

mv /opt/homebrew-cask/Caskroom /usr/local
for f in ~/Applications/*.app; do oldloc="$(readlink "$f")"; [[ -e $oldloc ]] || ln -sf "/usr/local${oldloc#/opt/homebrew-cask}" "$f"; done

 

執行之後,再看一下 symbolic link,的確都指向新的位置了:

testuser@localhost ~ $ ll ~/Applications/
total 168
lrwxr-xr-x   1 testuser  staff   73 Jul 26 14:26 Android Studio.app@ -> /usr/local/Caskroom/android-studio/2.1.1.0,143.2821654/Android Studio.app
lrwxr-xr-x   1 testuser  staff   51 Jul 26 14:26 AppCleaner.app@ -> /usr/local/Caskroom/appcleaner/3.0.2/AppCleaner.app
lrwxr-xr-x   1 testuser  staff   43 Jul 26 14:26 Appium.app@ -> /usr/local/Caskroom/appium/1.3.7/Appium.app
lrwxr-xr-x   1 testuser  staff   65 Jul 26 14:26 Beyond Compare.app@ -> /usr/local/Caskroom/beyond-compare/4.0.7.19761/Beyond Compare.app
drwx------@ 16 testuser  staff  544 Jul 16 12:26 Chrome Apps.localized/
lrwxr-xr-x   1 testuser  staff   55 Jul 26 14:26 ControlPlane.app@ -> /usr/local/Caskroom/controlplane/1.5.7/ControlPlane.app
lrwxr-xr-x   1 testuser  staff   47 Jul 26 14:26 DiskWave.app@ -> /usr/local/Caskroom/diskwave/0.4.0/DiskWave.app
lrwxr-xr-x   1 testuser  staff   46 Jul 26 14:26 Dropbox.app@ -> /usr/local/Caskroom/dropbox/latest/Dropbox.app
lrwxr-xr-x   1 testuser  staff   52 Jul 26 14:26 Evernote.app@ -> /usr/local/Caskroom/evernote/6.1_452115/Evernote.app
lrwxr-xr-x   1 testuser  staff   52 Jul 26 14:26 FileZilla.app@ -> /usr/local/Caskroom/filezilla/3.11.0.2/FileZilla.app
lrwxr-xr-x   1 testuser  staff   44 Jul 26 14:26 Firefox.app@ -> /usr/local/Caskroom/firefox/39.0/Firefox.app
lrwxr-xr-x   1 testuser  staff   51 Jul 26 14:26 ImageOptim.app@ -> /usr/local/Caskroom/imageoptim/1.6.0/ImageOptim.app
lrwxr-xr-x   1 testuser  staff   52 Jul 26 14:26 LiveReload.app@ -> /usr/local/Caskroom/livereload/2.3.74/LiveReload.app
lrwxr-xr-x   1 testuser  staff   39 Jul 26 14:26 Pinta.app@ -> /usr/local/Caskroom/pinta/1.6/Pinta.app
lrwxr-xr-x   1 testuser  staff   48 Jul 26 14:26 Seashore.app@ -> /usr/local/Caskroom/seashore/latest/Seashore.app
lrwxr-xr-x   1 testuser  staff   45 Jul 26 14:26 ShiftIt.app@ -> /usr/local/Caskroom/shiftit/1.6.3/ShiftIt.app
lrwxr-xr-x   1 testuser  staff   49 Jul 26 14:26 SourceTree.app@ -> /usr/local/Caskroom/sourcetree/2.3/SourceTree.app
lrwxr-xr-x   1 testuser  staff   37 Jul 26 14:26 VLC.app@ -> /usr/local/Caskroom/vlc/2.2.2/VLC.app
lrwxr-xr-x   1 testuser  staff   56 Jul 26 14:26 XMind.app@ -> /usr/local/Caskroom/xmind/3.6.0.R-201511090408/XMind.app
lrwxr-xr-x   1 testuser  staff   54 Jul 26 14:26 iTerm.app@ -> /usr/local/Caskroom/iterm2-beta/2.9.20160206/iTerm.app
lrwxr-xr-x   1 testuser  staff   46 Jul 26 14:26 p4v.app@ -> /usr/local/Caskroom/p4v/2014.3-1007540/p4v.app
lrwxr-xr-x   1 testuser  staff   59 Jul 26 14:26 unetbootin.app@ -> /usr/local/Caskroom/unetbootin/613,212083654/unetbootin.app

 

保險起見,我重開機之後,再次確認這些 app 都還可以使用…

簡單試了幾個,應該都是 OK 的喔~

 

(本頁面已被瀏覽過 352 次)

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料