From f9c0a566eb79a679faef889f20b569de62cde977 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Fri, 3 Jan 2025 12:11:02 -0600 Subject: [PATCH] Add See Where asdf Gets Current Tool Version as a Unix TIL --- README.md | 3 +- ...ee-where-asdf-gets-current-tool-version.md | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 unix/see-where-asdf-gets-current-tool-version.md diff --git a/README.md b/README.md index ad8f39b..e4c0a24 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186). -_1555 TILs and counting..._ +_1556 TILs and counting..._ See some of the other learning resources I work on: - [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators) @@ -1571,6 +1571,7 @@ See some of the other learning resources I work on: - [Search History](unix/search-history.md) - [Search Man Page Descriptions](unix/search-man-page-descriptions.md) - [Securely Remove Files](unix/securely-remove-files.md) +- [See Where asdf Gets Current Tool Version](unix/see-where-asdf-gets-current-tool-version.md) - [Set The asdf Package Version For A Single Shell](unix/set-the-asdf-package-version-for-a-single-shell.md) - [Show A File Preview When Searching With FZF](unix/show-a-file-preview-when-searching-with-fzf.md) - [Show Disk Usage For The Current Directory](unix/show-disk-usage-for-the-current-directory.md) diff --git a/unix/see-where-asdf-gets-current-tool-version.md b/unix/see-where-asdf-gets-current-tool-version.md new file mode 100644 index 0000000..f068638 --- /dev/null +++ b/unix/see-where-asdf-gets-current-tool-version.md @@ -0,0 +1,29 @@ +# See Where asdf Gets Current Tool Version + +The other day I [installed the latest version of +Ruby](ruby/install-latest-version-of-ruby-with-asdf.md) with `asdf`. I then set +that version (`3.4.1`) as the global default. However, when I then ran `ruby +--version`, I was getting a `3.2.x` version. I checked my current project's +directory and there was no `.tool-versions` file, so it wasn't being set by my +current directory. + +`asdf` looks up the current chain of directories until it encounters a +`.tool-versions` file, so it must have been finding one somewhere up there, but +before it was getting to the _global_ `.tool-versions` file. But where? + +The `asdf current` command can tell us for a specific tool what the current +version it is set to and what file is giving that directive. + +```bash +asdf current ruby +ruby 3.2.2 /Users/jbranchaud/code/.tool-versions +``` + +As it turns out, I had a `.tool-versions` file in `$HOME/code` that was setting +that `3.2.x` Ruby version. + +I didn't want that directory controlling the Ruby version, so I removed `ruby` +from that file. `asdf` was then able to traverse up to `$HOME/.tool-versions` +for the global setting. + +See `asdf help` for more details.