Skip to content

Commit

Permalink
Remove and recreate shims in asdf install step (#83)
Browse files Browse the repository at this point in the history
@hochdave recently ran into an issue where his pre-commit shim was still
pointing to his old non-existant brew-installed version of asdf:
```
dave:wordsmith-proxy dave.hoch$ git commit -m 'add token usage'
/Users/dave.hoch/.asdf/shims/pre-commit: line 4: /opt/homebrew/Cellar/asdf/0.13.1/libexec/bin/asdf: No such file or directory
/Users/dave.hoch/.asdf/shims/pre-commit: line 4: exec: /opt/homebrew/Cellar/asdf/0.13.1/libexec/bin/asdf: cannot execute: No such file or directory
One or more pre-commit hooks failed.
```

`asdf reshim` didn't fix the issue, because it doesn't recreate existing
shims.

This PR removes the whole existing shim directory and recreates it with
`asdf reshim`.
  • Loading branch information
pb-dod authored Jan 23, 2024
1 parent 07e0737 commit ed1bc6f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.44
0.1.45
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.44"
VERSION="0.1.45"
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
23 changes: 23 additions & 0 deletions lib/core/asdf/step.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,27 @@ function ih::setup::core.asdf::deps() {
echo "core.shell core.git"
}

function recreate_shims() {
ih::log::info "Removing existing asdf shims..."
if [ -d "$HOME/.asdf/shims" ]; then
rm -f "$HOME/.asdf/shims"/*
else
ih::log::debug "Shims directory not found."
return 1
fi

ih::log::info "Generating new asdf shims..."
asdf reshim

local EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
ih::log::error "Failed to recreate asdf shims."
return $EXIT_CODE
fi

ih::log::info "Successfully recreated asdf shims."
}

function ih::setup::core.asdf::install() {

if ! command -v asdf; then
Expand Down Expand Up @@ -96,6 +117,8 @@ function ih::setup::core.asdf::install() {
fi
done <<<"$DESIRED_PLUGINS"

recreate_shims

ih::log::info "Copying augment file for shell"
cp -f "$ASDF_SH_TEMPLATE_PATH" "$ASDF_SH_PATH"

Expand Down

0 comments on commit ed1bc6f

Please sign in to comment.