Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crun and wasm example - could not load `libwasmedge.so.0 #1046

Closed
marcelo-modolo opened this issue Nov 1, 2022 · 6 comments
Closed

crun and wasm example - could not load `libwasmedge.so.0 #1046

marcelo-modolo opened this issue Nov 1, 2022 · 6 comments

Comments

@marcelo-modolo
Copy link

Hi!

I compiled and installed crun with wasm support

/opt/crun/bin/crun -V
crun version 1.6.0.0.0.77-2c6e
commit: 2c6efdd
rundir: /run/user/1000/crun
spec: 1.0.0
+SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +WASM:wasmedge +YAJL

I also adjusted the ~/.config/containers/containers.conf file to use the new crun

podman info
host:
arch: amd64
buildahVersion: 1.23.1
cgroupControllers:
... ociRuntime:
name: crun
package: Unknown
path: /opt/crun/bin/crun
version: |-
crun version 1.6.0.0.0.77-2c6e
commit: 2c6efdd
rundir: /run/user/1000/crun
spec: 1.0.0
+SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +WASM:wasmedge +YAJL

Then follow the example in https://github.com/containers/crun/blob/main/docs/wasm-wasi-example.md.

cat Dockerfile
FROM scratch
COPY wasi-hello-world.rustc.wasm /
CMD ["/wasi-hello-world.rustc.wasm"]

buildah build --annotation "module.wasm.image/variant=compat-smart" -t mywasm-image

podman run --rm -it mywasm-image
Error: could not load libwasmedge.so.0: libwasmedge.so.0: cannot open shared object file: No such file or directory: OCI runtime attempted to invoke a command that was not found

Does anyone have a tip that could help me?

Thanks

@flouthoc
Copy link
Collaborator

flouthoc commented Nov 1, 2022

Hi @marcelo-modolo Could you please confirm which wasmedge version is installed on your host ?

@marcelo-modolo
Copy link
Author

Hi @marcelo-modolo Could you please confirm which wasmedge version is installed on your host ?

wasmedge version 0.11.1

@marcelo-modolo
Copy link
Author

I believe that I managed to understand the problem and maybe it can be useful to someone else.

opt/crun/bin/crun -V
crun version 1.6.0.0.0.77-2c6e
commit: 2c6efdd
rundir: /run/user/1000/crun
spec: 1.0.0
+SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +WASM:wasmedge +YAJL

crun is configured to make use of +WASM:wasmedge. By default the installation of wasmedge is in the home folder

tree ~/.wasmedge
/home/modolo/.wasmedge
├── bin
│   ├── wasmedge
│   └── wasmedgec
├── env
├── include
│   └── wasmedge
│   ├── enum_configure.h
│   ├── enum_errcode.h
│   ├── enum.inc
│   ├── enum_types.h
│   ├── int128.h
│   ├── version.h
│   └── wasmedge.h
├── lib
│   ├── libwasmedge.so -> libwasmedge.so.0
│   ├── libwasmedge.so.0 -> libwasmedge.so.0.0.0
│   └── libwasmedge.so.0.0.0
└── plugin
└── libwasmedgePluginWasmEdgeProcess.so

With the following environment variables set:

LD_LIBRARY_PATH=/home/modolo/.wasmedge/lib
LIBRARY_PATH=/home/modolo/.wasmedge/lib

Testing with crun directly without creating the image there are no errors

tree container
container
├── config.json
└── rootfs
└── wasi-hello-world.rustc.wasm

cd container
/opt/crun/bin/crun run wasm-test
Hello, world!

But trying to create a container with the same binary I end up with a load error in the libraries

cat Dockerfile
FROM scratch
COPY wasi-hello-world.rustc.wasm /
CMD ["/wasi-hello-world.rustc.wasm"]

buildah build --annotation "module.wasm.image/variant=compat-smart" -t wasm-test-02

podman run --rm -it wasm-test-02

Error: could not load libwasmedge.so.0: libwasmedge.so.0: cannot open shared object file: No such file or directory: OCI runtime attempted to invoke a command that was not found

The problem was in the location of the libraries!

I copied the libraries to /usr/local/lib/wasmedge/

ls -l /usr/local/lib/wasmedge/
lrwxrwxrwx 20 root 1 nov 13:32  libwasmedge.so -> libwasmedge.so.0.0.0
lrwxrwxrwx 20 root 1 nov 13:32  libwasmedge.so.0 -> libwasmedge.so.0.0.0
.rwxr-xr-x 50M root 1 nov 13:31  libwasmedge.so.0.0.0

I created the file /etc/ld.so.conf.d/wasmedge.conf

cat /etc/ld.so.conf.d/wasmedge.conf
/usr/local/lib/wasmedge

And ran the command sudo ldconfig

No errors after that!

podman run --rm -it wasm-test-02
Hello, world!

I apologize for the mistake made but maybe the solution can be useful.

@rhatdan
Copy link
Member

rhatdan commented Nov 1, 2022

So is this not an issue? Or should crun have been smarter and set the LD_LIBRARY_PATH to point at the same directory?

@marcelo-modolo
Copy link
Author

So is this not an issue? Or should crun have been smarter and set the LD_LIBRARY_PATH to point at the same directory?

Honestly I don't know, maybe most people do the installation as root and with that the libraries end up where they can be accessed.

@rhatdan
Copy link
Member

rhatdan commented Nov 1, 2022

Ok I will close then.

@rhatdan rhatdan closed this as completed Nov 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants