Skip to content

Commit f9c0a56

Browse files
committedJan 3, 2025
Add See Where asdf Gets Current Tool Version as a Unix TIL
1 parent 527038c commit f9c0a56

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
 

‎README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010

1111
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
1212

13-
_1555 TILs and counting..._
13+
_1556 TILs and counting..._
1414

1515
See some of the other learning resources I work on:
1616
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators)
@@ -1571,6 +1571,7 @@ See some of the other learning resources I work on:
15711571
- [Search History](unix/search-history.md)
15721572
- [Search Man Page Descriptions](unix/search-man-page-descriptions.md)
15731573
- [Securely Remove Files](unix/securely-remove-files.md)
1574+
- [See Where asdf Gets Current Tool Version](unix/see-where-asdf-gets-current-tool-version.md)
15741575
- [Set The asdf Package Version For A Single Shell](unix/set-the-asdf-package-version-for-a-single-shell.md)
15751576
- [Show A File Preview When Searching With FZF](unix/show-a-file-preview-when-searching-with-fzf.md)
15761577
- [Show Disk Usage For The Current Directory](unix/show-disk-usage-for-the-current-directory.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# See Where asdf Gets Current Tool Version
2+
3+
The other day I [installed the latest version of
4+
Ruby](ruby/install-latest-version-of-ruby-with-asdf.md) with `asdf`. I then set
5+
that version (`3.4.1`) as the global default. However, when I then ran `ruby
6+
--version`, I was getting a `3.2.x` version. I checked my current project's
7+
directory and there was no `.tool-versions` file, so it wasn't being set by my
8+
current directory.
9+
10+
`asdf` looks up the current chain of directories until it encounters a
11+
`.tool-versions` file, so it must have been finding one somewhere up there, but
12+
before it was getting to the _global_ `.tool-versions` file. But where?
13+
14+
The `asdf current` command can tell us for a specific tool what the current
15+
version it is set to and what file is giving that directive.
16+
17+
```bash
18+
asdf current ruby
19+
ruby 3.2.2 /Users/jbranchaud/code/.tool-versions
20+
```
21+
22+
As it turns out, I had a `.tool-versions` file in `$HOME/code` that was setting
23+
that `3.2.x` Ruby version.
24+
25+
I didn't want that directory controlling the Ruby version, so I removed `ruby`
26+
from that file. `asdf` was then able to traverse up to `$HOME/.tool-versions`
27+
for the global setting.
28+
29+
See `asdf help` for more details.

0 commit comments

Comments
 (0)
Please sign in to comment.