来自环境变量的 Rocket 端口覆盖在 Windows 中不起作用

Rocket port override from environment variable not working in Windows

我正在尝试 运行 rocket-rs 应用程序,同时使用 documentation 中所述的环境变量覆盖端口配置。

我已经设置了变量 ROCKET_PORT:

setx ROCKET_PORT 4444

我检查过它是用 echo 设置的。当我 运行 应用程序(使用 cargo run./application.exe)时,它仍然使用端口 8000:

  Configured for development.
    => address: localhost
    => port: 8000
    => log: normal
    => workers: 16
    => secret key: generated
    => limits: forms = 32KiB
    => tls: disabled
  Mounting '/':
    => GET /mine
    => POST /transactions/new application/json
    => GET /chain
    => GET /nodes/resolve
    => POST /nodes/register application/json
  Rocket has launched from http://localhost:8000

我知道可以在 Rocket.toml 中配置端口,但我的想法是能够通过设置环境变量 运行 在每个控制台会话的不同端口中。

为什么这不起作用?

像这样设置变量就成功了:

$Env:ROCKET_PORT=4444