-
Hi! New to Bevy. I use a remote development environment (Ubuntu based Docker container). I connect via VS Code in the browser (code-server). When I try and run a very basic Bevy app, I get this error: thread 'main' panicked at 'Failed to initialize any backend! Wayland status: "backend disabled" X11 status:
LibraryOpenError(OpenError { kind: Library, detail:
"opening library failed (libXcursor.so.1: cannot open
shared object file: No such file or directory); opening
library failed (libXcursor.so: cannot open shared object
file: No such file or directory)" })',
/home/coder/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.26.1/src/platform_impl/linux/mod.rs:619:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace Is this possible or does Bevy only work with local development environments? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 3 replies
-
You might be interested in #4700, which sets up remote development using Gitpod. I'm not immediately sure how adaptable it might be, but it's a place to look. |
Beta Was this translation helpful? Give feedback.
-
Turns out, it's easier than you think. Bevy can be compiled for WebAssembly. Follow this guide and it will run your game on a webserver. |
Beta Was this translation helpful? Give feedback.
-
if your game can't work in wasm (need more shadows, need more perf, need multithread, ...), there are still options open to you:
|
Beta Was this translation helpful? Give feedback.
-
You can also run Here how I did it:
"containerEnv": {
"HOST_USER": "${localEnv:USER}",
"HOST_WORKSPACE": "${localWorkspaceFolder}",
"HOST_DISPLAY": "${localEnv:DISPLAY}",
"HOST_XAUTHORITY": "${localEnv:XAUTHORITY}"
}
#!/bin/bash
# Build the project
cargo rustc
# Check if the build was successful, otherwise exit
if [ $? -ne 0 ]; then
exit 1
fi
# Get the host user and ip address
REMOTE_ADDRESS="${HOST_USER}@$(ip route | grep default | awk '{print $3}')"
# Check if SSH key pair exists, otherwise generate one
if [ ! -f ~/.ssh/id_rsa ]; then
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
fi
# Copy the public key to the local host if not already done
ssh-copy-id -i ~/.ssh/id_rsa.pub ${REMOTE_ADDRESS} >/dev/null 2>&1
# Run the program on the local host
ssh ${REMOTE_ADDRESS} \
"XAUTHORITY=${HOST_XAUTHORITY} DISPLAY=${HOST_DISPLAY} ${HOST_WORKSPACE}/target/debug/$(basename "${HOST_WORKSPACE}")"
If im missing something let me know, just started using rust and bevy today. |
Beta Was this translation helpful? Give feedback.
-
Leaving this here in hopes it helps someone in future : https://github.com/cs50victor/new_media/pull/18 |
Beta Was this translation helpful? Give feedback.
-
I've been using VSCode's devcontainer to develop bevy for a few days. There were a lot of fiddling around until I've managed to make it work: mounting GPU, X11 and sound sockets, installing NVIDIA containers toolkit on host machine, installing cuda toolkit and drivers inside container. Relevant informations about my setup: Ubuntu 22.04, NVIDIA GPU with proprietary drivers, system user mapped to docker group
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
// .devcontainer/devcontainer.json
{
"name": "Rust",
"build": {
"dockerfile": "Dockerfile"
},
"runArgs": [
// Map sound devices (doesn't work on Windows, see https://github.com/microsoft/WSL/issues/689)
"--device=/dev/snd:/dev/snd",
"--device=/dev/dri:/dev/dri",
"-e", "DISPLAY=${env:DISPLAY}", // Set the display for X11
"-v", "/tmp/.X11-unix:/tmp/.X11-unix", // Mount the X11 socket
"--gpus", "all", // Mount the GPU
"--privileged" // It may or not be necessary to run the container in privileged mode
]
}
# .devcontainer/Dockerfile
FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye
# Install cuda-toolkit
RUN distribution=$(. /etc/os-release;echo $ID$VERSION_ID | sed -e 's/\.//g') && \
wget https://developer.download.nvidia.com/compute/cuda/repos/$distribution/x86_64/cuda-keyring_1.0-1_all.deb && \
dpkg -i cuda-keyring_1.0-1_all.deb && \
export DEBIAN_FRONTEND=noninteractive && \
apt-get -y update && \
apt-get -y install cuda-toolkit && \
rm cuda*
# Install additional packages.
RUN export DEBIAN_FRONTEND=noninteractive && apt-get -y upgrade \
&& apt-get -y install --no-install-recommends \
g++ \
pkg-config \
libx11-dev \
libasound2-dev \
libudev-dev \
libxkbcommon-x11-0 \
libxcursor-dev \
libxrandr-dev \
libxi-dev \
mesa-vulkan-drivers \
lld \
clang
# Cargo tools for nightly must be installed with vscode user
USER vscode
RUN rustup toolchain install nightly && \
rustup component add rustfmt --toolchain nightly-x86_64-unknown-linux-gnu && \
rustup component add clippy --toolchain nightly-x86_64-unknown-linux-gnu Good luck! |
Beta Was this translation helpful? Give feedback.
Turns out, it's easier than you think. Bevy can be compiled for WebAssembly. Follow this guide and it will run your game on a webserver.