Skip to content

Commit 3f4335d

Browse files
committed
docs: recommend exec for non-interactive environments
1 parent 0bfd2e5 commit 3f4335d

4 files changed

Lines changed: 56 additions & 0 deletions

File tree

docs/guides/faq.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ that means you do not hook `vfox` into your shell, please hook it manually first
1111

1212
Please refer to [Quick Start#_2-hook-vfox-to-your-shell](./quick-start.md#_2-hook-vfox-to-your-shell) to manually hook `vfox` into your shell.
1313

14+
## How should I use vfox in Docker, CI/CD, or other non-interactive shells?
15+
16+
Prefer `vfox exec`.
17+
18+
`vfox activate` works by installing shell hooks, which are intended for interactive shells. In Docker build steps, CI jobs, and other non-interactive shells, these hooks are usually not triggered automatically.
19+
20+
Recommended examples:
21+
22+
```bash
23+
vfox exec nodejs@24.14.0 -- npm install -g pnpm
24+
vfox exec nodejs@24.14.0 -- bash -lc 'node -v && npm -v'
25+
```
26+
27+
Use `vfox use` when you want to persist version selection for Global, Project, or Session scope. Use `vfox exec` when you want a command to run immediately with the correct SDK environment.
28+
1429
## Why can't I select when use `use` and `search` commands in GitBash?
1530

1631
Related ISSUE: [Unable to select in GitBash](https://github.com/version-fox/vfox/issues/98)

docs/usage/core-commands.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,19 @@ The `exec` command allows you to temporarily execute commands in a specified SDK
224224
- **Script Execution**: Use specific SDK versions in CI/CD or build scripts
225225
- **Temporary Testing**: Test code with different SDK versions
226226

227+
::: tip Non-Interactive Environments
228+
229+
For Docker, CI/CD, and other non-interactive shells, prefer `vfox exec` instead of relying on `vfox activate`.
230+
231+
`activate` integrates vfox through shell hooks, while `exec` prepares the SDK environment explicitly for the subprocess you are running.
232+
233+
```shell
234+
vfox exec nodejs@24.14.0 -- npm install -g pnpm
235+
vfox exec nodejs@24.14.0 -- bash -lc 'node -v && npm -v'
236+
```
237+
238+
:::
239+
227240
**Examples**
228241

229242
```shell

docs/zh-hans/guides/faq.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@
1111

1212
请按照[快速入门#_2-挂载vfox到你的shell](./quick-start.md#_2-挂载vfox到你的shell)步骤进行手动挂载。
1313

14+
## 在 Docker、CI/CD 或其他非交互 Shell 中应该怎么使用 vfox?
15+
16+
推荐优先使用 `vfox exec`
17+
18+
`vfox activate` 的工作方式是安装 Shell Hook,这更适合交互式 Shell。在 Docker 构建步骤、CI Job 以及其他非交互 Shell 中,这些 Hook 通常不会自动触发。
19+
20+
推荐示例:
21+
22+
```bash
23+
vfox exec nodejs@24.14.0 -- npm install -g pnpm
24+
vfox exec nodejs@24.14.0 -- bash -lc 'node -v && npm -v'
25+
```
26+
27+
如果你希望把版本选择持久化到 Global、Project 或 Session 作用域,请使用 `vfox use`。如果你希望某条命令立刻在正确的 SDK 环境中执行,请使用 `vfox exec`
28+
1429

1530
## GitBash下`use``search`命令无法进行选择?
1631

docs/zh-hans/usage/core-commands.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,19 @@ vfox x <sdk-name>[@<version>] -- <command> [args...]
226226
- **脚本执行**: 在 CI/CD 或构建脚本中使用特定 SDK 版本
227227
- **临时测试**: 临时使用不同版本的 SDK 测试代码
228228

229+
::: tip 非交互环境
230+
231+
在 Docker、CI/CD 和其他非交互 Shell 中,推荐优先使用 `vfox exec`,而不是依赖 `vfox activate`
232+
233+
`activate` 通过 Shell Hook 集成 vfox,而 `exec` 会为当前子进程显式准备好 SDK 环境。
234+
235+
```shell
236+
vfox exec nodejs@24.14.0 -- npm install -g pnpm
237+
vfox exec nodejs@24.14.0 -- bash -lc 'node -v && npm -v'
238+
```
239+
240+
:::
241+
229242
**示例**
230243

231244
```shell

0 commit comments

Comments
 (0)