Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Env.exePath returns "/memfd:roc_file_descriptor (deleted)" when running as script

未關閉
#265 2 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
72/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
冷清
技術堆疊
rust
領域
cli

研究方向

使用提供的 roc test.roc 範例重現問題,然後閱讀 crates/roc_host/src/lib.rs 第 432 行附近的程式碼,以及連結的 Rust current_exe() 實作。比較可用的 argv[0] 和 Env.cwd 情境,並確認 Env.exePath 回報的是腳本的絕對路徑,而不是 memfd 路徑。

由索引模型根據 Issue 內容生成。

描述

blocked

Minimal Reproducible Example:

app [main] {
    pf: platform "https://github.com/roc-lang/basic-cli/releases/download/0.16.0/O00IPk-Krg_diNS2dVWlI0ZQP794Vctxzv0ha96mK0E.tar.br",
}

import pf.Env
import pf.Path

main = 
    exePath = Env.exePath!
    exePathStr = Path.display exePath
    dbg exePathStr
    Task.ok {}

Run as roc test.roc

Expected Behavior:

Output of /home/user/path/to/script/test.roc

Actual Behavior:

Output of /memfd:roc_file_descriptor (deleted)

Environment:

OS: Archlinux
Roc Version: roc nightly pre-release, built from commit 06996d8

Context

Discussed in https://roc.zulipchat.com/#narrow/channel/231634-beginners/topic/basic-cli.20debugging.20Env.2EexePath

Implementation (https://github.com/roc-lang/basic-cli/blob/918c1dcd2a863ea336e9fa0e70fa548f7107b6f0/crates/roc_host/src/lib.rs#L432) just defers to Rust's std::env::current_exe() (https://github.com/rust-lang/rust/blob/a8e75c53d0036b5d012cbc0ee5de17f8991fe60c/library/std/src/sys/pal/unix/os.rs#L406) which reads /proc/self/exe which seems to be invalid when running through roc <file>.

Somewhat related is https://github.com/roc-lang/roc/pull/7172 which fixed argv[0] to be set correctly.

Proposed solution is to use argv[0] and ideally combine with Env.cwd for a full absolute path (similar to https://github.com/rust-lang/rust/blob/a8e75c53d0036b5d012cbc0ee5de17f8991fe60c/library/std/src/sys/pal/unix/os.rs#L253) if /proc/self/exe can't be utilized.

Credit to @jwoudenberg and @lukewilliamboswell who did most of the work of putting this information together.

主要語言
Rust
星號
123
分支
46
平均合併
7 小時 43 分鐘
30 天內合併 PR
16

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

roc-lang/basic-cli 的其他 Issue

查看 roc-lang/basic-cli 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。