1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00

Add Run A Command With Specific Tool Version as a Mise TIL

This commit is contained in:
jbranchaud
2025-03-14 16:34:39 -05:00
parent 93398ab950
commit d6ebe52523
2 changed files with 41 additions and 1 deletions

View File

@@ -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). 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: See some of the other learning resources I work on:
- [Ruby Operator Lookup](https://www.visualmode.dev/ruby-operators) - [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) - [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) - [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) - [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 ### MongoDB

View File

@@ -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 <duhamelantoine1995@gmail.com>" [unknown]
📦 Repomix v0.2.39
...
```