﻿---
title: "命令环境像卡住：先关 shell_snapshot 再新开会话"
summary: "稳定、默认开。它给反复执行做环境快照。刚 nvm use、刚装进 PATH 的工具找不到时，先关掉这个，不要去开 experimental_use_profile。"
category: config
level: intermediate
surfaces: [cli]
tags: ["shell_snapshot", "features", "PATH"]
canonical: /tips/shell-snapshot/
---

# 命令环境像卡住：先关 shell_snapshot 再新开会话

稳定、默认开。它给反复执行做环境快照。刚 nvm use、刚装进 PATH 的工具找不到时，先关掉这个，不要去开 experimental_use_profile。

默认 `features.shell_snapshot = true`。Codex 会拍一份当前 shell 环境，后面的命令复用，少做一次启动。这是稳定开关，不是实验特性。

刚在这个终端里 `nvm use`、改过 PATH、或刚装了 CLI，会话里却仍是旧 Node / 找不到新命令时，先关快照：

```bash
codex features disable shell_snapshot
```

或写进用户 config 后**新开**会话：

```toml
[features]
shell_snapshot = false
```

一次性：`codex --disable shell_snapshot` 或 `codex -c features.shell_snapshot=false`。只覆盖这一程。

这**不是** `shell_environment_policy.experimental_use_profile`。后者会在生成子进程时去跑用户 shell profile，默认关，实验性质。也不是 `allow_login_shell`：那个管 shell 工具能不能要 login shell。

要长期钉死 PATH，用 `[shell_environment_policy] set`，不要为了「让 nvm 生效」去 source 整份 rc。改完对照 `codex features list`。

## 来源

- [OpenAI · Config basics](https://learn.chatgpt.com/docs/config-file/config-basic)
- [OpenAI · Configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference)
