Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 48081 - chroot command not found without absolute path
Summary: chroot command not found without absolute path
Status: RESOLVED FIXED
Alias: None
Product: [OLD] Docs-user
Classification: Unclassified
Component: Gentoo Alternative Installation Guide (show other bugs)
Hardware: x86 Linux
: High minor (vote)
Assignee: Sven Vermeulen (RETIRED)
URL: http://www.gentoo.org/doc/en/altinsta...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-16 15:05 UTC by Tom de Vries
Modified: 2004-04-25 09:55 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2004-04-16 15:05:45 UTC
I'm doing an install from an alternative distro: RH9. Gotten to the chroot part, I try:
$ env -i chroot /mnt/gentoo /bin/bash
env: chroot: No such file or directory
but it fails, which probably makes sense, since env -i is supposed to
flush the environment including the path variable

using the absolute path, I was able to do the chroot succesfully.
$ env -i /usr/sbin/chroot /mnt/gentoo /bin/bash
just after that, in the chrooted environment I have a similar problem with
$ env-update
in http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=6
and using the absolute pathname fixes the problem here as well
$ /usr/lib/portage/bin/env-update



Reproducible: Always
Steps to Reproduce:
1. install rh9
2. free partition and create ext3 fs, and mount it under /mnt/gentoo
3. download stage3-athlon-xp-20040218.tar.bz2 on /mnt/gentoo untar it using tar -xvjpf stage?-*.tar.bz2
4. edit /mnt/gentoo/etc/make.conf
5. cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
6. env -i chroot  /mnt/gentoo /bin/bash

Actual Results:  
$ env -i chroot /mnt/gentoo /bin/bash
env: chroot: No such file or directory


Expected Results:  
results seems to be correct (see additional info)

looking in the file 
/usr/src/redhat/SOURCES/coreutils-4.5.3/src/env.c
I found the following code snippet:

...
   env - LOGNAME=foo /hacks/hack bar baz
        runs the "hack" program on arguments "bar" and "baz" in an
        environment in which the only variable is "LOGNAME".  Note that
        the "-" option clears out the PATH variable, so one should be
        careful to specify in which directory to find the program to
        call.
                                                                               
                 ...
so it looks like the env -i behaviour is intentional (note: -i is equivalent to
- for the env command)
Comment 1 SpanKY gentoo-dev 2004-04-16 21:47:54 UTC
`env -i` doesnt 'flush' the environment, it totally erases it, including PATH

for example, run `env -i env` ... you'll get no output ...
Comment 2 SpanKY gentoo-dev 2004-04-16 21:56:15 UTC
err, to add something useful to my comment, the fix is as you say

change from:
$ env -i chroot /mnt/gentoo /bin/bash
to:
$ env -i /usr/sbin/chroot /mnt/gentoo /bin/bash

that of course assumes chroot is in /usr/sbin which would be the case for most systems i'd imagine ...
Comment 3 Sven Vermeulen (RETIRED) gentoo-dev 2004-04-25 09:55:33 UTC
Fixed in CVS. Thanks!