Skip to content

Fails to run in sandboxed environments such as Nix #56

@rafaelrc7

Description

@rafaelrc7

Hello, I recently updated this package on nixpkgs (NixOS/nixpkgs#449792), and had to fix some problems with gforth. In nix packages are built inside a sandboxed environment, and one of the problems is that /sys is not available. gforth on

gforth/cilk.fs

Line 28 in f50d1cf

s" /sys/devices/system/cpu/present" slurp-file over >r
tries to access /sys/devices/system/cpu/present causing the following error:

...
warning: some-waddr is compile-only
varues.fs:107:9: warning: WA: is obsoleteEXTRADOC.FD

in file included from *args*:13:1: 
cilk.fs:28:38: error: No such file or directory
        s" /sys/devices/system/cpu/present" >>>slurp-file<<< over >r
Backtrace:
stuff.fs:171:23:                         0 $7FFFF7438DB0 perform 
*** Gforth kernel failed ***
make: *** [Makefile:1681: doc/extradoc.fd] Error 1

I fixed this issue on nixpkgs by patching gforth to call nproc (https://github.com/NixOS/nixpkgs/blob/cf3f5c4def3c7b5f1fc012b3d839575dbe552d43/pkgs/by-name/gf/gforth/use-nproc-instead-of-fhs.patch), I based the code on what cilk.fs already does for MacOS/BSD here:

gforth/cilk.fs

Lines 24 to 26 in f50d1cf

s" sysctl -n hw.ncpu" r/o open-pipe throw slurp-fid over >r
s>number drop
r> free throw

While this works there, it seems to me that this is an issue where gforth assumes /sys is accessible, what may not be always true, such as in sandboxed environments such as, but not limited to, Nix. And as I believe this could be an issue on other situations I decided to open this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions