nsjail icon indicating copy to clipboard operation
nsjail copied to clipboard

nsjail cannot find executables even with the entire root directory mounted?

Open SBaori opened this issue 6 months ago • 1 comments

Trying to compile a small program in c inside nsjail using the following command.

sudo nsjail -B / --cwd /mydir/ -- /usr/bin/gcc main.c

This command, even though defeats the entire purpose of nsjail, has been the result of constant inability of nsjail to find required dependencies for gcc. As an ultimatum, I mounted the entire root directory to check whether the issue lies in nsjail or in my mount configuration.

The above command fails with the following error

collect2: fatal error: cannot find 'ld'
compilation terminated.

Here's the output of $PATH as perceived in nsjail,

sudo nsjail -B / -- /usr/bin/bash -c 'echo $PATH' /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Update: gcc works when I explicitly point all of its internal search paths to /usr/bin like so,

sudo nsjail -B / --cwd /mydir/ -- /usr/bin/bash -c "/usr/bin/gcc -B/usr/bin main.c"

SBaori avatar Jul 13 '25 07:07 SBaori

I could not reproduce the issue. What OS are you using?

happyCoder92 avatar Oct 16 '25 09:10 happyCoder92