Skip to content

Commit b2529a2

Browse files
authored
docs: Add a section on how to use environment variables (jdx#4435)
- update env. vars page to indicate under which conditions they work - small updates to backend/plugins/registry pages - clarify that `mise alias` command is only for version aliases (not backend aliases)
1 parent b586085 commit b2529a2

File tree

15 files changed

+228
-52
lines changed

15 files changed

+228
-52
lines changed

docs/cli/alias.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
- **Aliases**: `a`
55
- **Source code**: [`src/cli/alias/mod.rs`](https://github.com/jdx/mise/blob/main/src/cli/alias/mod.rs)
66

7-
Manage aliases
7+
Manage version aliases.
88

99
## Flags
1010

docs/cli/generate/git-pre-commit.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ when you commit changes to your repository.
1111

1212
Staged files are passed to the task as `STAGED`.
1313

14+
For more advanced pre-commit functionality, see mise's sister project: <https://hk.jdx.dev/>
15+
1416
## Flags
1517

1618
### `--hook <HOOK>`

docs/components/registry.vue

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
type="text"
55
placeholder="Filter by Short or Full"
66
v-model="filter"
7+
autofocus="autofocus"
78
/>
8-
<table>
9+
<table class="full-width">
910
<thead>
1011
<tr>
1112
<th>Short</th>
@@ -14,21 +15,27 @@
1415
</tr>
1516
</thead>
1617
<tbody>
17-
<tr v-for="(entry, index) in filteredData" :key="`backend-${index}`">
18+
<tr v-if="filteredData.length === 0">
19+
<td colspan="3" class="no-matches">No matches found</td>
20+
</tr>
21+
<tr
22+
v-else
23+
v-for="(entry, index) in filteredData"
24+
:key="`backend-${index}`"
25+
>
1826
<td v-html="highlightMatches(entry.short)"></td>
1927
<td>
2028
<span v-for="(backend, index) in entry.backends">
2129
<a
2230
:href="`${backend.url}`"
2331
v-html="highlightMatches(backend.name)"
2432
></a>
25-
<span v-if="index < entry.backends.length - 1">,<br /></span>
33+
<span v-if="index < entry.backends.length - 1"><br /></span>
2634
</span>
2735
</td>
2836
<td>
29-
<span v-for="(os, index) in entry.os">
30-
{{ os }}
31-
<span v-if="index < entry.os.length - 1">, </span>
37+
<span v-for="(os, index) in entry.os"
38+
>{{ os }}<span v-if="index < entry.os.length - 1">, </span>
3239
</span>
3340
</td>
3441
</tr>
@@ -42,7 +49,8 @@ import { data } from "/registry.data.ts";
4249
export default {
4350
data() {
4451
return {
45-
filter: "",
52+
filter:
53+
new URLSearchParams(globalThis?.location?.search).get("filter") || "",
4654
data: data,
4755
};
4856
},
@@ -60,6 +68,18 @@ export default {
6068
});
6169
},
6270
},
71+
watch: {
72+
filter(newFilter = "") {
73+
const url = new URL(window.location);
74+
url.hash = "tools";
75+
if (newFilter.trim() === "") {
76+
url.searchParams.delete("filter");
77+
} else {
78+
url.searchParams.set("filter", newFilter);
79+
}
80+
window.history.pushState({}, "", url);
81+
},
82+
},
6383
methods: {
6484
highlightMatches(text) {
6585
if (this.filter.trim() === "") return text;
@@ -71,7 +91,8 @@ export default {
7191
const re = new RegExp(this.filter, "ig");
7292
return text.replace(
7393
re,
74-
(matchedText) => `<strong>${matchedText}</strong>`,
94+
(matchedText) =>
95+
`<span style="background-color: rgba(173, 216, 230, 0.2)">${matchedText}</span>`,
7596
);
7697
},
7798
},
@@ -88,4 +109,38 @@ export default {
88109
font-size: 15px;
89110
color: var(--vp-c-text-2);
90111
}
112+
113+
.full-width {
114+
width: 100%;
115+
table-layout: fixed;
116+
min-height: 500px;
117+
}
118+
119+
.full-width th:nth-child(1),
120+
.full-width td:nth-child(1) {
121+
min-width: 40%;
122+
width: 50%;
123+
}
124+
125+
.full-width th:nth-child(2),
126+
.full-width td:nth-child(2) {
127+
min-width: 40%;
128+
width: 50%;
129+
}
130+
131+
.full-width th:nth-child(3),
132+
.full-width td:nth-child(3) {
133+
min-width: 20%;
134+
}
135+
136+
.full-width th,
137+
.full-width td {
138+
word-wrap: break-word; /* Allows text to wrap within cells */
139+
}
140+
141+
.no-matches {
142+
text-align: center;
143+
font-style: italic;
144+
color: var(--vp-c-text-2);
145+
}
91146
</style>

docs/dev-tools/aliases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Tools can be aliased so that something like `node` which normally maps to `core:node` can be changed
66
to something like `asdf:company/our-custom-node` instead.
77

8-
```toml
8+
```toml [~/.config/mise/config.toml]
99
[alias]
1010
node = 'asdf:company/our-custom-node' # shorthand for https://github.com/company/our-custom-node
1111
erlang = 'asdf:https://github.com/company/our-custom-erlang'

docs/dev-tools/backends/asdf.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# asdf Backend
22

3-
asdf is the original backend for mise. It relies on asdf plugins for each tool. asdf plugins are
4-
more risky to use because they're typically written by a single developer unrelated to the tool vendor
5-
they also do not function on Windows.
3+
`asdf` is the original backend for mise.
4+
5+
It relies on asdf plugins for each tool. asdf plugins are more risky to use because they're typically written by a single developer unrelated to the tool vendor. They also do not function on Windows.
6+
7+
asdf plugins are not used for tools inside the [registry](https://github.com/jdx/mise/blob/main/registry.toml) whenever possible. Sometimes it is not possible to use more secure backends like aqua/ubi because tools have complex install setups or need to export env vars.
8+
9+
All of these are hosted in the mise-plugins org to secure the supply chain so you do not need to rely on plugins maintained by anyone except me.
10+
611
Because of the extra complexity of asdf tools and security concerns we are actively moving tools in
712
the registry away from asdf where possible to backends like aqua and ubi which don't require plugins.
813
That said, not all tools can function with ubi/aqua if they have a unique installation process or
9-
need to set env vars other than PATH.
14+
need to set env vars other than `PATH`.
1015

1116
## Writing asdf plugins for mise
1217

docs/dev-tools/backends/index.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Backends
22

3-
In addition to asdf plugins, you can also directly install CLIs with some package managers.
3+
Backends are the way mise installs [tools](/dev-tools/) and [plugins](/plugins.html). Each backend is responsible for managing the installation and usage of a specific type of tool or package manager. This allows mise to support a wide variety of tools and languages by leveraging different backends.
44

5-
- [asdf](/dev-tools/backends/asdf)
5+
When you run the [`mise use`](/cli/use.html) command, mise will determine the appropriate backend to use based on the tool you are trying to manage. The backend will then handle the installation, configuration, and any other necessary steps to ensure the tool is ready to use.
6+
7+
Below is a list of the available backends in mise:
8+
9+
- [asdf](/dev-tools/backends/asdf) (provide tools through [plugins](/plugins.html))
610
- [aqua](/dev-tools/backends/aqua)
711
- [cargo](/dev-tools/backends/cargo)
812
- [dotnet](/dev-tools/backends/dotnet) <Badge type="warning" text="experimental" />
@@ -12,7 +16,7 @@ In addition to asdf plugins, you can also directly install CLIs with some packag
1216
- [pipx](/dev-tools/backends/pipx)
1317
- [spm](/dev-tools/backends/spm) <Badge type="warning" text="experimental" />
1418
- [ubi](/dev-tools/backends/ubi)
15-
- [vfox](/dev-tools/backends/vfox) <Badge type="warning" text="experimental" />
19+
- [vfox](/dev-tools/backends/vfox) (provide tools through [plugins](/plugins.html)) <Badge type="warning" text="experimental" />
1620

1721
::: tip
1822
If you'd like to contribute a new backend to mise, they're not difficult to write.

docs/dev-tools/index.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,9 @@
44
> or [pyenv](https://github.com/pyenv/pyenv) but for any language), it manages dev tools like node,
55
> python, cmake, terraform, and [hundreds more](/registry.html)._
66
7-
::: tip
8-
New developer? Try reading the [Beginner's Guide](https://dev.to/jdxcode/beginners-guide-to-rtx-ac4)
9-
for a gentler introduction.
10-
:::
11-
12-
mise is a tool that manages installations of programming language runtimes and other tools for local development. For example, it can be used to manage multiple versions of Node.js, Python, Ruby, Go, etc. on the same machine.
7+
`mise` is a tool that manages installations of programming language runtimes and other tools for local development. For example, it can be used to manage multiple versions of Node.js, Python, Ruby, Go, etc. on the same machine.
138

14-
Once [activated](/getting-started.html#activate-mise), mise will automatically switch between different versions of tools based on the directory you're in.
9+
Once [activated](/getting-started.html#activate-mise), mise can automatically switch between different versions of tools based on the directory you're in.
1510
This means that if you have a project that requires Node.js 18 and another that requires Node.js 22, mise will automatically switch between them as you move between the two projects. See tools available for mise with in the [registry](/registry).
1611

1712
To know which tool version to use, mise will typically look for a `mise.toml` file in the current directory and its parents. To get an idea of how tools are specified, here is an example of a [mise.toml](/configuration.html) file:

docs/dev-tools/shims.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This is the method used when you add the `echo 'eval "$(mise activate bash)"' >>
2121
For example, by default, your `PATH` variable might look like this:
2222

2323
```sh
24-
echo \$PATH
24+
echo $PATH
2525
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
2626
```
2727

docs/environments/index.md

Lines changed: 73 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
> manages _environment variables_ for
55
> different project directories.
66
7-
Use mise to specify environment variables used for different projects. Create a `mise.toml` file
8-
in the root of your project directory:
7+
Use mise to specify environment variables used for different projects.
8+
9+
To get started, create a `mise.toml` file in the root of your project directory:
910

1011
```toml [mise.toml]
1112
[env]
@@ -22,13 +23,76 @@ NODE_ENV = false # unset a previously set NODE_ENV
2223
You can also use the CLI to get/set env vars:
2324

2425
```sh
25-
$ mise set NODE_ENV=development
26-
$ mise set NODE_ENV
27-
development
28-
$ mise set
29-
key value source
30-
NODE_ENV development mise.toml
31-
$ mise unset NODE_ENV
26+
mise set NODE_ENV=development
27+
# mise set NODE_ENV
28+
# development
29+
30+
mise set
31+
# key value source
32+
# NODE_ENV development mise.toml
33+
34+
cat mise.toml
35+
# [env]
36+
# NODE_ENV = 'development'
37+
38+
mise unset NODE_ENV
39+
```
40+
41+
Additionally, the [mise env [--json] [--dotenv]](/cli/env.html) command can be used to export the environment variables in various formats (including `PATH` and environment variables set by tools or plugins).
42+
43+
## Using environment variables
44+
45+
Environment variables are available when using [`mise x|exec`](/cli/exec.html), or with [`mise r|run`](/cli/run.html) (i.e. with [tasks](/tasks/)):
46+
47+
```shell
48+
mise set MY_VAR=123
49+
mise exec -- echo $MY_VAR
50+
# 123
51+
```
52+
53+
You can of course combine them with [tools](/dev-tools/):
54+
55+
```sh
56+
mise use node@22
57+
mise set MY_VAR=123
58+
cat mise.toml
59+
# [tools]
60+
# node = '22'
61+
# [env]
62+
# MY_VAR = '123'
63+
mise exec -- node --eval 'console.log(process.env.MY_VAR)'
64+
# 123
65+
```
66+
67+
If [mise is activated](/getting-started.html#activate-mise), it will automatically set environment variables in the current shell session when you `cd` into a directory.
68+
69+
```shell
70+
cd /path/to/project
71+
mise set NODE_ENV=production
72+
cat mise.toml
73+
# [env]
74+
# NODE_ENV = 'production'
75+
76+
echo $NODE_ENV
77+
# production
78+
```
79+
80+
If you are using [`shims`](/dev-tools/shims.html), the environment variables will be available when using the shim:
81+
82+
```shell
83+
mise set NODE_ENV=production
84+
mise use node@22
85+
# using the absolute path for the example
86+
~/.local/share/mise/shims/node --eval 'console.log(process.env.NODE_ENV)'
87+
```
88+
89+
Finally, you can also use [`mise en`](/cli/en.html) to start a new shell session with the environment variables set.
90+
91+
```shell
92+
mise set FOO=bar
93+
mise en
94+
> echo $FOO
95+
# bar
3296
```
3397

3498
## Lazy eval

docs/plugins.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
11
# Plugins
22

3-
Plugins in mise extend functionality. Historically they were the only way to add new tools as the only backend was asdf. The way
4-
that backend works is every tool has its own plugin which needs to be manually installed. However now with core languages and
5-
backends like aqua/ubi, plugins are no longer necessary to run most tools in mise.
3+
Plugins in mise are a way to extend `mise` with new functionality like extra tools or environment variable management.
64

7-
Meanwhile, plugins have expanded beyond tools and can provide functionality like [setting env vars globally](/environments/#plugin-provided-env-directives) without relying on a tool being installed.
5+
Historically it was the only way to add new tools (as the only backend was [asdf](/dev-tools/backends/asdf.html)).
6+
7+
The way that backend works is every tool has its own plugin which needs to be manually installed. However, now with [core tools](/core-tools.html)
8+
and backends like [aqua](/dev-tools/backends/aqua.html)/[ubi](/dev-tools/backends/ubi.html), plugins are no longer necessary to run most tools in mise.
89

910
Tool plugins should be avoided for security reasons. New tools will not be accepted into mise built with asdf/vfox plugins unless they are very popular and
1011
aqua/ubi is not an option for some reason.
12+
13+
The only exception is if the tool needs to set env vars or has a complex installation process, as plugins can provide functionality like [setting env vars globally](/environments/#plugin-provided-env-directives) without relying on a tool being installed. They can also provide [aliases for versions](/dev-tools/aliases.html#aliased-versions).
14+
1115
If you want to integrate a new tool into mise, you should either try to get it into the [aqua registry](https://mise.jdx.dev/dev-tools/backends/aqua.html)
1216
or see if it can be installed with [ubi](https://mise.jdx.dev/dev-tools/backends/ubi.html). Then add it to the [registry](https://github.com/jdx/mise/blob/main/registry.toml).
1317
Aqua is definitely preferred to ubi as it has better UX and more features like slsa verification and the ability to use different logic for older versions.
1418

19+
You can manage all installed plugins in `mise` with [`mise plugins`](/cli/plugins.html).
20+
21+
```shell
22+
mise plugins ls --urls
23+
# Plugin Url Ref Sha
24+
# 1password https://github.com/mise-plugins/mise-1password-cli.git HEAD f5d5aab
25+
# vfox-mise-plugins-vfox-dart https://github.com/mise-plugins/vfox-dart HEAD 1424253
26+
# ...
27+
```
28+
1529
## asdf Plugins
1630

17-
mise uses asdf's plugin ecosystem under the hood. These plugins contain shell scripts like
31+
mise can use asdf's plugin ecosystem under the hood. These plugins contain shell scripts like
1832
`bin/install` (for installing) and `bin/list-all` (for listing all of the available versions).
1933

2034
See <https://github.com/jdx/mise/blob/main/registry.toml> for the list of built-in plugins shorthands. See asdf's
@@ -23,7 +37,7 @@ more about how they work.
2337

2438
## vfox Plugins
2539

26-
Similarly, mise can also use [vfox plugins](https://mise.jdx.dev/dev-tools/backends/vfox.html). These have the advantage of working on Windows so are preferred.
40+
Similarly, mise can also use [vfox plugins](/dev-tools/backends/vfox.html). These have the advantage of working on Windows so are preferred.
2741

2842
## Plugin Authors
2943

@@ -40,13 +54,13 @@ of tools. One example of this is virtualenv on python runtimes:
4054

4155
```toml
4256
[tools]
43-
python = {version='3.11', virtualenv='.venv'}
57+
python = { version='3.11', virtualenv='.venv' }
4458
```
4559

4660
This will be passed to all plugin scripts as `MISE_TOOL_OPTS__VIRTUALENV=.venv`. The user can specify
47-
any option and it will be passed to the plugin in that format.
61+
any option, and it will be passed to the plugin in that format.
4862

49-
Currently this only supports simple strings, but we can make it compatible with more complex types
63+
Currently, this only supports simple strings, but we can make it compatible with more complex types
5064
(arrays, tables) fairly easily if there is a need for it.
5165

5266
## Templates

0 commit comments

Comments
 (0)