7

I compiled busybox myself,and I put it in our embedded linux. But I have some questions.

Question 1:When I try to use some command such as gzip,it prints "gzip: applet not found".While I checked the menuconfig of busybox,I make sure that I've selected "gzip".

Question 2:I used to work with VIM,but busybox just provide VI.So I make a link VIM to VI,but when I typed vim and run it,it also show "vim: applet not found".

Anybody can help me with this problem that "applet not found"? Thank you very much.

PS:I'm confused with the "applet" of busybox,what it is? Like "applet" in java?

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
Ezio
  • 1,116
  • 4
  • 13
  • 25
  • Looks like your shell is not finding busybox in its path. Google "busybox shell path" to find the remedy. – UncleO Sep 27 '13 at 06:48
  • 2
    First of all, try to execute gzip like "busybox gzip". If it works, then problem is in applet links (symbolic, hard or micro scripts). If not, then gzip applet is likely not compiled into busybox (although it seems that links point to busybox executable because you get "applet not found" message). Applets are commands/utilities supported by busybox. – sknaumov Sep 27 '13 at 10:37
  • @UncleO oh no,the path is ok,any other command is ok. – Ezio Sep 30 '13 at 05:20
  • @sknaumov thanks,i tried gzip and success.but when i try "ln busybox vim" and using vim ,it still show "vim: applet not found",how can i solved this? – Ezio Sep 30 '13 at 05:24
  • 6
    The way *busybox* work is it looks at it `argv[0]` parameter which is the name of the *symlink*; **vim** in your case. It then does a look-up and it has no applet named **vim**. You can make a script that does `busybox vi` and symlink that script to **vim**. The syntax `busybox applet`, is another way to select the *program*; but why not just type `vi`. An *applet* in *busybox* parlance is the emulated program. *busybox* has base infrastructure (command line parsing, etc) with a main *driver file* that is an *applet* emulating the normal program. – artless noise Sep 30 '13 at 15:21
  • I found other command shows the same error,such as openvt,while I can find it in /usr/bin,and I truely compile it in busybox. – Ezio Nov 21 '13 at 03:50

3 Answers3

1

The answer to questions 1 and 2 is: you must set your PATH variable first or compile busybox with FEATURE_PREFER_APPLETS enabled. You can set the PATH variable with:

$ export PATH=/bin:/sbin:/usr/bin:/usr/sbin

A busybox applet is a small application that is usually found in the UNIX common utilities (defined in the POSIX standard). This applets are compiled into a single executable: busybox.

Luis Lavaire.
  • 599
  • 5
  • 17
1

[F.Y.I.] Shebang's typo caused me the same applet not found error.

$ # The '!' was forgotten in shebang
$ cat sample.sh
#/bin/sh

echo 'hello world'

$ ./sample.sh
sample.sh: applet not found

In docker-compose, running the above script gives me the blow error:

standard_init_linux.go:211: exec user process caused "exec format error"
KEINOS
  • 71
  • 8
-1

Even tho this is a Java-related question as @KEINOS pointed out this has more to do with the missing shebang notation. I've run into the issue when trying to build a Docker image based on Alpine Linux when installing R packages in it.

My jerry-rigged solution was to add the following script to run after installing R in the image and then running Buildx's muiltarch build:

#!/bin/sh
for script in $(ls -p /usr/lib/R/bin/ | grep -v / )
do
    sed -i '1 i\#!/bin/bash\n#' "/usr/lib/R/bin/$script"
done

This will add the shebang notation to all R-provided scripts.

And even so, some packages have their shell scripts missing the shebang notation also. I've just opened a PR in one of them to add this notation.

If you are trying to compile just to run in your x86 based system, probably won't make a difference this fix, but if you are trying to compile to any other architecture like arm/v6, arm/v7, arm/v8, ppc64le, and s390x; you will run into this issue.