简体   繁体   English

嵌入式 Linux 中的 busybox 显示“找不到小程序”

[英]busybox in embedded linux shows “applet not found”

I compiled busybox myself,and I put it in our embedded linux.我自己编译了busybox,放在我们的嵌入式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".问题 1:当我尝试使用某些命令(例如 gzip)时,它会打印“gzip: applet not found”。当我检查了 busybox 的 menuconfig 时,我确保我选择了“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".问题2:我以前用过vim,但是busybox只提供vi,所以我做了一个vim到vi的链接,但是当我输入vim并运行它时,它也显示“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? PS:我对busybox的“小程序”感到困惑,它是什么? Like "applet" in java?像Java中的“小程序”?

The answer to questions 1 and 2 is: you must set your PATH variable first or compile busybox with FEATURE_PREFER_APPLETS enabled.问题 1 和 2 的答案是:您必须先设置PATH变量,或者在启用FEATURE_PREFER_APPLETS编译 busybox。 You can set the PATH variable with:您可以使用以下命令设置PATH变量:

$ 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). busybox 小程序是一个小应用程序,通常可以在 UNIX 通用实用程序(在 POSIX 标准中定义)中找到。 This applets are compiled into a single executable: busybox .这个小程序被编译成一个单一的可执行文件: busybox

[FYI] Shebang's typo caused me the same applet not found error. [仅供参考] Shebang 的拼写错误导致我出现了同样的applet not found错误。

$ # 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:在 docker-compose 中,运行上面的脚本给了我一个打击错误:

standard_init_linux.go:211: exec user process caused "exec format error"

Even tho this is a Java-related question as @KEINOS pointed out this has more to do with the missing shebang notation.即使这是一个与 Java 相关的问题,因为@KEINOS 指出这更多地与缺少的 shebang 符号有关。 I've run into the issue when trying to build a Docker image based on Alpine Linux when installing R packages in it.在尝试构建基于 Alpine Linux 的 Docker 映像时,我在其中安装了 R 包时遇到了这个问题。

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:我的 jerry-rigged 解决方案是在映像中安装 R 后添加以下脚本运行,然后运行 ​​Buildx 的 muiltarch 构建:

#!/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.这会将 shebang 符号添加到所有 R 提供的脚本中。

And even so, some packages have their shell scripts missing the shebang notation also.即便如此,一些软件包的 shell 脚本也缺少 shebang 符号。 I've just opened a PR in one of them to add this notation.我刚刚在其中一个中打开了一个PR来添加这个符号。

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;如果您试图编译只是为了在基于 x86 的系统中运行,则此修复程序可能不会有什么不同,但如果您正在尝试编译为任何其他架构,如 arm/v6、arm/v7、arm/v8、ppc64le , 和 s390x; you will run into this issue.你会遇到这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM