A blank NOSTUI_CONFIG is taken as an answer, not as an omission
- 主要语言
- Rust
- 星标
- 71
- 派生
- 5
- 平均合并
- 4 小时 2 分钟
- 30 天内合并 PR
- 31
描述
Found while reviewing [#576](https://github.com/akiomik/nostui/pull/576), which works around the symptom rather than this.
## What happens
```rust
pub static CONFIG_FOLDER: LazyLock> = LazyLock::new(|| {
env::var(format!("{}_CONFIG", *PROJECT_NAME))
.ok()
.map(PathBuf::from)
});
```
`env::var` answers `Ok("")` for a variable that is set and empty, so `NOSTUI_CONFIG=` yields `Some(PathBuf::from(""))` and `get_config_dir` returns it in preference to the platform directory. The loader then joins each name onto nothing and probes the working directory:
```console
$ cd /tmp && NOSTUI_CONFIG= nostui
No configuration file found in /private/tmp
```
`DATA_FOLDER` reads `NOSTUI_DATA` the same way, so a blank one puts the log in the working directory too.
This is not an exotic way to end up with a blank variable. `NOSTUI_CONFIG="$SOMETHING_UNSET"` produces one, as does a compose file or unit that declares the key without a value, and `export NOSTUI_CONFIG=` is a plausible way to try to *clear* an override — which is exactly the intent this reading inverts.
## What #576 does and does not do
It makes the message name the working directory rather than print an empty path, so a user is at least told where nostui looked. It does not change where that is. Someone who blanked the variable meaning "never mind" still gets the working directory rather than the platform one.
## Shape
`.ok().filter(|value| !value.is_empty())` in both statics, so a blank variable reads as an omission. That is a behaviour change rather than a message change — `--version` prints these directories too — which is why it is not in #576.
## Acceptance
- `NOSTUI_CONFIG=` and `NOSTUI_DATA=` behave as if unset, for the loader and for `--version`.
- A variable set to a real path is unaffected.
贡献指南
调研方向
Start by searching for CONFIG_FOLDER and DATA_FOLDER, plus the get_config_dir path used by the loader and --version output. The issue proposes treating empty environment variables with a filter while leaving real paths unchanged. Done means NOSTUI_CONFIG= and NOSTUI_DATA= behave like unset for loading and --version, while non-empty overrides still work.
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- rust
- 领域
- cli
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 活跃
- 描述清晰度
- 描述清楚
- 新手友好度
- 88/100