Env.exePath returns "/memfd:roc_file_descriptor (deleted)" when running as script
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
使用提供的 roc test.roc 範例重現問題,然後閱讀 crates/roc_host/src/lib.rs 第 432 行附近的程式碼,以及連結的 Rust current_exe() 實作。比較可用的 argv[0] 和 Env.cwd 情境,並確認 Env.exePath 回報的是腳本的絕對路徑,而不是 memfd 路徑。
由索引模型根據 Issue 內容生成。
描述
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 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
roc-lang/basic-cli 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 66/100
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 25/100
roc-lang/basic-cli#482 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 45/100
維護者通常 1 天內回覆
-
enhancement
難度 5/5 一週以上 新手友好度 45/100
roc-lang/basic-cli#455 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 32/100
維護者通常 1 天內回覆
查看 roc-lang/basic-cli 的全部 Issue
相似的 Issue
-
desktop documentation
難度 1/5 1 小時以內 新手友好度 90/100
vfarcic/dot-agent-deck#2008 ·
維護者通常 1 天內回覆
-
needs triage
難度 1/5 1 小時以內 新手友好度 85/100
pbakaus/impeccable#1210 ·
維護者通常 1 天內回覆
-
enhancement ux-opportunities
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
area: ci priority: P4 ready-for-agent
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 1 天內回覆
-
`PartialEq` for `AssignedBigUint` treats different values as equal可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉status:untriaged
難度 2/5 1-3 小時 新手友好度 78/100
midnightntwrk/midnight-zk#600 ·
維護者通常 2 天內回覆