containerd / runwasi

Facilitates running Wasm / WASI workloads managed by containerd
Apache License 2.0
1.06k stars 88 forks source link

Makefile: Define `RUSTC` to avoid "rustc: not found" during `sudo make install` #578

Closed keisku closed 4 months ago

keisku commented 4 months ago

Through the Demo in the README, the following error happened.

# Make sure rustc is installed.
ls -la $(which rustc)
-rwxr-xr-x 14 ubuntu ubuntu 15428432 May  4 11:05 /home/ubuntu/.cargo/bin/rustc
rustc --version
rustc 1.75.0 (82e1608df 2023-12-21)

# Cannot run rustc as root.
sudo rustc --version
sudo: rustc: command not found

sudo make --trace install
/bin/sh: 1: rustc: not found
/bin/sh: 1: rustc: not found
/bin/sh: 1: rustc: not found
/bin/sh: 1: rustc: not found
Makefile:76: target 'build-wasmedge' does not exist
cargo build --target= --target-dir=./target/ -p containerd-shim-wasmedge
/bin/sh: 1: rustc: not found
/bin/sh: 1: rustc: not found
/bin/sh: 1: rustc: not found
make: cargo: No such file or directory
make: *** [Makefile:76: build-wasmedge] Error 127

I would like to define RUSTC variable in Makefile, then run this command.

sudo CARGO=~/.cargo/bin/cargo RUSTC=~/.cargo/bin/rustc make --trace install
Makefile:76: target 'build-wasmedge' does not exist
/home/ubuntu/.cargo/bin/cargo build --target=x86_64-unknown-linux-gnu --target-dir=./target/ -p containerd-shim-wasmedge
    Updating crates.io index
  Downloaded anstream v0.6.11
  Downloaded cgroups-rs v0.3.4
  Downloaded async-stream v0.3.5
...skip...
Makefile:138: update target 'install-wasmer' due to: build-wasmer
mkdir -p /usr/local/bin
install ./target//x86_64-unknown-linux-gnu/debug/containerd-shim-wasmer-v1 /usr/local/bin/
ln -sf ./containerd-shim-wasmer-v1 /usr/local/bin/containerd-shim-wasmerd-v1
ln -sf ./containerd-shim-wasmer-v1 /usr/local/bin/containerd-wasmerd

# Make sure binaries exist in /usr/loca/bin/
ls -la /usr/local/bin/containerd*wasm*
-rwxr-xr-x 1 root root 410800840 May  5 00:02 /usr/local/bin/containerd-shim-wasmedge-v1
lrwxrwxrwx 1 root root        29 May  5 00:02 /usr/local/bin/containerd-shim-wasmedged-v1 -> ./containerd-shim-wasmedge-v1
-rwxr-xr-x 1 root root 618126120 May  5 00:05 /usr/local/bin/containerd-shim-wasmer-v1
lrwxrwxrwx 1 root root        27 May  5 00:05 /usr/local/bin/containerd-shim-wasmerd-v1 -> ./containerd-shim-wasmer-v1
-rwxr-xr-x 1 root root 581308584 May  5 00:03 /usr/local/bin/containerd-shim-wasmtime-v1
lrwxrwxrwx 1 root root        29 May  5 00:03 /usr/local/bin/containerd-shim-wasmtimed-v1 -> ./containerd-shim-wasmtime-v1
lrwxrwxrwx 1 root root        29 May  5 00:02 /usr/local/bin/containerd-wasmedged -> ./containerd-shim-wasmedge-v1
lrwxrwxrwx 1 root root        27 May  5 00:05 /usr/local/bin/containerd-wasmerd -> ./containerd-shim-wasmer-v1
lrwxrwxrwx 1 root root        29 May  5 00:03 /usr/local/bin/containerd-wasmtimed -> ./containerd-shim-wasmtime-v1
jprendes commented 4 months ago

The change is fine, but in general building the binaries with sudo is not recommended. You should do make build-wasmedge and then sudo make install-wasmedge.

Maybe we should change the README.md to reflect that, and maybe also remove the Makefile dependency so that install doesnt call build automatically.