Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 93779 - "env -i ... chroot ..." command fails
Summary: "env -i ... chroot ..." command fails
Status: RESOLVED INVALID
Alias: None
Product: [OLD] Docs-user
Classification: Unclassified
Component: Gentoo Alternative Installation Guide (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Docs Team
URL: http://www.gentoo.org/doc/en/altinsta...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-24 02:40 UTC by Presuming Ed
Modified: 2005-05-24 13:06 UTC (History)
0 users

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 Presuming Ed 2005-05-24 02:40:48 UTC
The code listing at the end of the page tells me:

Code Listing 6.5: Flushing the environment during chroot

# env -i HOME=$HOME TERM=$TERM chroot /mnt/gentoo /bin/bash
# /usr/sbin/env-update
# source /etc/profile

but the "env -i" line fails in Mandriva Linux 2005:

[root@chrislap gentoo]# env -i HOME=/root TERM=$TERM chroot /mnt/gentoo /bin/bash
env: chroot: Invalid argument
[root@chrislap gentoo]# env -i HOME=/root TERM=emacs chroot /mnt/gentoo /bin/bash
env: chroot: Invalid argument

Using the full path to the 'chroot' command worked:

[root@chrislap gentoo]# env -i HOME=$HOME TERM=$TERM /usr/sbin/chroot
/mnt/gentoo /bin/bash
bash-2.05b# 

Perhaps the documentation should mention that.

Reproducible: Always
Steps to Reproduce:
See above.
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2005-05-24 03:08:01 UTC
Works perfectly here... You should file a bug with Mandriva, not a Gentoo problem.

from man env:

SYNOPSIS
       env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]
Comment 2 Johannes Weiner 2005-05-24 03:11:31 UTC
(In reply to comment #0)
> The code listing at the end of the page tells me:
> 
> Code Listing 6.5: Flushing the environment during chroot
> 
> # env -i HOME=$HOME TERM=$TERM chroot /mnt/gentoo /bin/bash
> # /usr/sbin/env-update
> # source /etc/profile
> 
> but the "env -i" line fails in Mandriva Linux 2005

You should post that on the Mandriva Support whatever site.
Perhaps this version of env only recognizes commands when they are absolutely
given. Check the manpage under Mandriva.
Comment 3 SpanKY gentoo-dev 2005-05-24 06:10:43 UTC
it sounds like your user's environment is incomplete in the Mandriva host

if it were setup properly, /usr/sbin would be in root's environment
Comment 4 Presuming Ed 2005-05-24 12:46:15 UTC
Well, I'm not sure...  Here's a log of some commands that show more details. 
chroot is in the PATH.  "env" works, but "env -i" doesn't:

# type chroot
chroot is hashed (/usr/sbin/chroot)

# chroot / /bin/bash
# exit

# env chroot / /bin/bash
# exit

# env -i chroot / /bin/bash
env: chroot: Invalid argument

# env | grep PATH
HELPPATH=/usr/openwin/lib/help
NLSPATH=/usr/share/locale/%l/%N
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin
Comment 5 SpanKY gentoo-dev 2005-05-24 13:06:02 UTC
sounds like the env is probably broken ?

it looks like env first clears the environ due to the -i and then searches for
the command in $PATH ... this clearly fails since the -i just nuked PATH

on Gentoo systems, the specified command is searched for before nuking PATH
which is why you can do `env -i chroot`

putting the fullpath in the docs is not a good idea because not everyone puts
chroot in /usr/sbin ... some people put it in /usr/bin (like Gentoo ;])