daniestevez / gr4-packet-modem

Packet modem for GNU Radio 4.0
10 stars 1 forks source link

Rust is not included in the gr4-packet-modem Docker image #16

Closed ainst closed 1 month ago

ainst commented 1 month ago

My understanding is that the gr4-packet-modem Docker image is intended to allow compilation of GR4 without creating a full local installation. However, if you try to build GR4 using this image CMake almost immediately fails with a rustc not found error:

Steps to reproduce:

  1. Download the Docker image, i.e., docker pull ghcr.io/daniestevez/gr4-packet-modem:latest
  2. Checkout the gr4-packet-modem git repository, i.e., git clone https://github.com/daniestevez/gr4-packet-modem.git
  3. Start a Docker session as documented here: https://github.com/daniestevez/gr4-packet-modem/blob/main/docs/docker.md
  4. Get a root shell in the container by running docker exec -u0 -it gr4 bash from the host
  5. Inside the Docker container create a build folder under the /gr4-packet-modem subdirectory and change to it
  6. Attempt to run CMake, i.e., cmake ..

Expected result:

CMake completes successfully and creates appropriate Makefiles

Actual result:

root@gr4:/gr4-packet-modem/build# cmake ..
-- The CXX compiler identification is Clang 18.1.3
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at build/_deps/corrosion-src/cmake/FindRust.cmake:23 (message):
  `rustc` not found in PATH or `/home/ubuntu/.cargo/bin`.

  Hint: Check if `rustc` is in PATH or manually specify the location by
  setting `Rust_COMPILER` to the path to `rustc`.
Call Stack (most recent call first):
  build/_deps/corrosion-src/cmake/FindRust.cmake:248 (_findrust_failed)
  build/_deps/corrosion-src/cmake/Corrosion.cmake:63 (find_package)
  build/_deps/corrosion-src/CMakeLists.txt:73 (include)

-- Configuring incomplete, errors occurred!

Workaround:

Temporarily install rustc in the Docker session, i.e., curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh and source $HOME/.cargo/env

daniestevez commented 1 month ago

Actually the Rust toolchain was already installed into /opt/rust with rustup in the Docker image. The only thing that was missing was running source /opt/rust/env. I have added an ENV PATH=/opt/rust/bin:$PATH to the Dockerfile, so sourcing /opt/rust/env is not needed anymore. Test if this fixes the problem (I think it does, since I run your steps and now it works), and if so we can close this issue.

ainst commented 1 month ago

I updated the Docker image with sudo docker pull ghcr.io/daniestevez/gr4-packet-modem:latest and also my local repository with git pull. Although the Dockerfile was updated, the $PATH environment variable did not appear to be updated to include /opt/rust/bin when I ran the container.

Running source /opt/rust/env fixes the problem.

I note that the Dockerfile.build has not be updated in the main branch, so I wonder if the container on ghcr.io is updated?

daniestevez commented 1 month ago

Sorry. I have realized that I forgot to push the ghcr.io/daniestevez/gr4-packet-modem:latest image that I built yesterday, so I was testing with something that was only available on my machine. I've now pushed it. Can you give it a try?

The Dockerfile.built file is used to build the gr4-packet-modem-built image, which gets built and pushed by CI with every commit to main. The dockerfile for gr4-packet-modem is Dockerfile. This isn't handled by CI. It needs to be built and pushed manually, because this image is supposed to change only rarely.

daniestevez commented 1 month ago

The change I did to the Dockerfile was, by the way, https://github.com/daniestevez/gr4-packet-modem/commit/b8f121bbb4face4a00bc6e143d1484589e517202

ainst commented 1 month ago

Thank you, it all works perfectly as expected now. I can run cmake, compile, and run the created binaries. So please close this issue if you are happy.