Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#265 2 bình luận 1 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
rust
Lĩnh vực
cli

Hướng nghiên cứu

Tái hiện vấn đề bằng ví dụ roc test.roc được cung cấp, sau đó đọc crates/roc_host/src/lib.rs quanh dòng 432 và phần triển khai current_exe() trong Rust được liên kết. So sánh ngữ cảnh argv[0] và Env.cwd hiện có, đồng thời xác minh rằng Env.exePath báo cáo đường dẫn tuyệt đối của script thay vì đường dẫn memfd.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Rust
Star
123
Fork
46
Merge trung bình
7 giờ 43 phút
Pull request đã merge (30 ngày)
16

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của roc-lang/basic-cli

Tất cả issue của roc-lang/basic-cli

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.