How to compile generated rust dependencies for flatpak?

Hello, I want to compile the rust dependencies in my project offline since afaik flathub will not allow cargo to access the internet during the build process. I used the flatpak cargo generator against my Cargo.lockfile and got the following sources:

My flatpak manifest file is as follows:

id: com.gitlab.adnan338.Timediff
runtime: org.gnome.Platform
runtime-version: "3.38"
sdk: org.gnome.Sdk
  - org.freedesktop.Sdk.Extension.rust-stable
command: timediff
  - --socket=fallback-x11
  - --share=ipc
  append-path: /usr/lib/sdk/rust-stable/bin
    - --share=network
  - name: timediff
    - deptree.json
    # - type: git
    #   url: ""
    #   branch: offline_flatpak
    - type: dir
      path: "."
    - type: file
      path: "resources/com.gitlab.adnan338.Timediff.png"
    - type: file
      path: "resources/com.gitlab.adnan338.Timediff.desktop"
    buildsystem: simple
      - cargo --offline fetch --manifest-path Cargo.toml --verbose
      - cargo --offline build --release --verbose,
      - install -Dm755 target/release/timediff --target-directory=/app/bin
      - install -Dm644 com.gitlab.adnan338.Timediff.desktop --target-directory=/app/share/applications
      - install -Dm644 com.gitlab.adnan338.Timediff.png --target-directory=/app/share/icons/hicolor/scalable/apps

As you can see the deptree.json (generated dependency list) needs to be compiled offline and made available to the build environment’s path but I am not sure how to achieve this. Obviously trying to build this fails:

 # [snip]
Building module timediff in /home/adnan338/proj/timediff/.flatpak-builder/build/timediff-1
Running: cargo --offline fetch --manifest-path Cargo.toml --verbose
error: no matching package named `gio` found
location searched: registry ``
required by package `timediff v0.1.0 (/run/build/timediff)`
As a reminder, you're using offline mode (--offline) which can sometimes cause surprising resolution failures, if this error is too confusing you may wish to retry without the offline flag.
Error: module timediff: Child process exited with code 101
make: *** [Makefile:9: flatpak-install] Error 1

For Flatpak-related questions, you can also use the Flathub Discourse.

You need to properly set CARGO_HOME for the offline fetched crates to work. Changing your build-options to something like this should work

  append-path: /usr/lib/sdk/rust-stable/bin
    CARGO_HOME: /run/build/timediff/cargo

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.