Termux-packages: $PREFIX/usr/bin/env is not installed by default

Created on 13 Jan 2016  路  11Comments  路  Source: termux/termux-packages

It is located in usr/bin/applets/env and this causes some programs not to work. Is there any good reason for that?

bug report

Most helpful comment

usr/bin/applets/env is from busybox. You need to install coreutils.

apt install coreutils

All 11 comments

usr/bin/applets/env is from busybox. You need to install coreutils.

apt install coreutils

Oops, thanks.

Generally, the lightweight pre-installed busybox versions of tools (such as ls, top, ln, wget, etc) are in bin/applets/, which come after bin/ in the PATH environment variable.

This means that if more fully-featured versions of the tools are installed (from e.g. the coreutils, wget and procps packages) they come up earlier in the path and gets used instead.

We could special case env here and put the busybox version of it in directly in bin/, so that using $PREFIX/usr/bin/env works in script shebangs, and remove env from the coreutils package. This can be done if the coreutils version of env doesn't have any useful or commonly used functionality over the busybox version:

# Options supported by coreutils env:
-i, --ignore-environment  start with an empty environment
-0, --null           end each output line with NUL, not newline
-u, --unset=NAME     remove variable from the environment
--help     display this help and exit
--version  output version information and exit

# Options supported by busybox env:
-, -i   Start with an empty environment
-u  Remove variable from the environment

Another option would be to change termux-fix-shebang (which I guess is the main reason that the missing $PREFIX/bin/env is noticed) to special case rewriting /usr/bin/env to $PREFIX/bin/applets/env.

A third option would be to install coreutils by default, which would increase initial download size with 400 kB and install size with 1500 kB.

Opinions welcome!

I don't know much about busybox but how about putting it in both places by linking $PREFIX/usr/bin/env to busybox by default, letting it be overwritten if someone installs coreutils while always keeping the one in $PREFIX/usr/bin/applet/env in place in case the same person then removes coreutils?

What if env was just removed from the busybox package. That way executing env would cause comment-not-found to suggest coreutils. termux-fix-shebang could also print a warning to install coreutils if it isn't installed.

@ZeBaal Interesting suggestion! It could be done with dpkg scripts setting up bin/env to avoid having the package manager considering the packages as conflicting with eachother.

@Neo-Oli A possibility! bin/env is so commonly used by scripts, so a bit unfortunate not having it working out of the box.

@fornwall What if about the termux-fix-shebang warning? Even if busybox env wasn't removed it could just print a warning to install coreutils when it encounters an env while fixing shebangs.

I really like @ZeBaal's suggestion linking the busybox env to bin/env as well. But is it possible to have the link between bin/applets/env and bin/env reestablished, once coreutils has been removed?

I think installing coreutils by default is not the best option since it would force a bigger space usage on many people that do not need it. While the existence of termux-fix-shebang seems to be a good thing to me, fixing every script using bin/env does not seem to be the best solution especially since some of them might be automatically updated thus needing to be fixed every time they do so like castnow which was causing the problem in my case. I do not have a lot of experience with apt but I have seen in the past that it sometimes call an update-alternatives function or something like this that could be useful.

There's no need to have seperate exec dirs in the first place. We could just install everything to $PREFIX/bin and use pre-install or post-install hooks in the packages.
Or as ZeeBaal mentioned update-alternatives which would also require pre/post install scripts.
So this is really an matter of maintaining packages rather than finding workarounds.

(just a pointer for avoiding the conflict)

The conflict of many packages shared some binary file is also seen on Ubuntu's vim packages: you have vim-mini, vim-nox, vim-whatever; and they all can be set to provide /usr/bin/vim when you install it

PREFIX/bin/env is now provided by the pre-installed busybox package (and has been removed from the coreutils package, as I haven't found anyone using the extra flags that coreutils env adds).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Zuccace picture Zuccace  路  3Comments

newmania picture newmania  路  3Comments

neitsab picture neitsab  路  3Comments

reggi picture reggi  路  4Comments

ILadis picture ILadis  路  3Comments