diff --git a/README.md b/README.md index 6d11812..ba8a8ed 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). -_1617 TILs and counting..._ +_1618 TILs and counting..._ See some of the other learning resources I work on: - [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators) @@ -697,6 +697,7 @@ If you've learned something here, support my efforts writing daily TILs by - [List The Files Being Loaded By Mise](mise/list-the-files-being-loaded-by-mise.md) - [Preserve Color Output For Task Command](mise/preserve-color-output-for-task-command.md) - [Read Existing Dot Env File Into Env Vars](mise/read-existing-dot-env-file-into-env-vars.md) +- [Run A Command With Specific Tool Version](mise/run-a-command-with-specific-tool-version.md) ### MongoDB diff --git a/mise/run-a-command-with-specific-tool-version.md b/mise/run-a-command-with-specific-tool-version.md new file mode 100644 index 0000000..561adda --- /dev/null +++ b/mise/run-a-command-with-specific-tool-version.md @@ -0,0 +1,39 @@ +# Run A Command With Specific Tool Version + +Because I'm using `mise` to manage the versions of tools like Node, I can +execute commands in the context of specific versions. Behind the scenes `mise` +makes sure I have the necessary tool(s) installed at the desired version(s). + +So, [`mise exec` command](https://mise.jdx.dev/cli/exec.html) will default to +using the latest version of a tool if I haven't been more specific. At the time +of this writing, for Node, that is v23. + +```bash +$ mise exec node -- node --version +v23.9.0 +``` + +To be specific I could specify the major version with `node@23` like so: + +```bash +mise exec node@23 -- npx repomix +Need to install the following packages: +repomix@0.2.39 +Ok to proceed? (y) y + +... +``` + +Or if I wanted to use a different, older version of Node, I could specify that +as well. We can see it will first install that and then execute the command: + +```bash +$ mise exec node@22 -- npx repomix +gpg: Signature made Tue Feb 11 04:44:53 2025 CST +gpg: using RSA key C0D6248439F1D5604AAFFB4021D900FFDB233756 +gpg: Good signature from "Antoine du Hamel " [unknown] + +📦 Repomix v0.2.39 + +... +```