Skip to content

Commit

Permalink
clean up old docker desktop broken symlink before rancher install (#86)
Browse files Browse the repository at this point in the history
@chadgh and @ark134 both hit this "Permission denied" issue while they
were reinstalling rancher:
```
==> Moving App 'Rancher Desktop.app' to '/Applications/Rancher Desktop.app'
:beer:  ih-rancher was successfully installed!
==> `brew cleanup` has not been run in the last 30 days, running now...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Error: Permission denied @ apply2files - /usr/local/lib/docker/cli-plugins
WARN: Could not install Rancher Desktop
```

Seems like the best way to handle this is by deleting the broken
symlink: https://stackoverflow.com/a/75141533

Here's what I see locally, which confirms docker leaves this broken
after uninstalling:
```
$ ls -hal /usr/local/lib/docker/cli-plugins
lrwxr-xr-x  1 root  wheel    55B Jan 25  2022 /usr/local/lib/docker/cli-plugins -> /Applications/Docker.app/Contents/Resources/cli-plugins
$ ls -hal /Applications/Docker.app/Contents/Resources/cli-plugins
ls: /Applications/Docker.app/Contents/Resources/cli-plugins: No such file or directory
```

This PR adds some additional clean-up logic to the clean up the broken
symlink before proceeding with the rancher install.
  • Loading branch information
pb-dod authored Feb 2, 2024
1 parent 5e01f08 commit 66eb05c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.47
0.1.48
2 changes: 1 addition & 1 deletion formula/ih-core.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class IhCore < Formula
VERSION="0.1.47"
VERSION="0.1.48"
desc "Brew formula for installing core tools used at Included Health engineering."
homepage "https://github.com/ConsultingMD/homebrew-ih-public"
license "CC BY-NC-ND 4.0"
Expand Down
15 changes: 14 additions & 1 deletion lib/core/rancher/step.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,25 @@ function ih::setup::core.rancher::deps() {
}

function ih::setup::core.rancher::install() {
local THIS_DIR="$IH_CORE_LIB_DIR/core/rancher"
# Clean up old docker symlink to prevent "Permission denied" error
# More details: https://stackoverflow.com/a/75141533
local SYMLINK_PATH="/usr/local/lib/docker/cli-plugins"
if [ -L "$SYMLINK_PATH" ]; then
local TARGET_PATH=$(readlink "$SYMLINK_PATH")
if [ ! -d "$TARGET_PATH" ]; then
sudo rm -f "$SYMLINK_PATH"
ih::log::info "Removed broken symlink from old docker install at $SYMLINK_PATH"

brew cleanup
ih::log::info "Homebrew cleanup completed."
fi
fi

cp -f "$RANCHER_AUGMENT_SRC" "$RANCHER_AUGMENT_DST"

echo "A configuration file for Rancher Desktop will be copied to your system"
echo "You may be required to enter your password"
local THIS_DIR="$IH_CORE_LIB_DIR/core/rancher"
sudo cp "${THIS_DIR}/io.rancherdesktop.profile.defaults.plist" "$PLIST_DST"

# Check if Rancher was installed manually
Expand Down

0 comments on commit 66eb05c

Please sign in to comment.