Rust can't connect network while building

Trying to build a flatpak. But build gets failed in middle. Giving network error. Any help?

app-id: org.fcitx.Fcitx5.Addon.OpenBangla
runtime: org.fcitx.Fcitx5
runtime-version: 'stable'
sdk: org.kde.Sdk//5.15-22.08
sdk-extensions:
  - org.freedesktop.Sdk.Extension.rust-stable
build-extension: true
separate-locales: false
build-options:
  prefix: /app/addons/OpenBangla
  prepend-pkg-config-path: /app/addons/OpenBangla/lib/pkgconfig:/app/addons/OpenBangla/share/pkgconfig
  append-path: /usr/lib/sdk/rust-stable/bin
  env:
    CARGO_HTTP_MULTIPLEXING: false 
  sandbox:
    --share=ipc
    --share=network  
cleanup:
  - /bin
  - /include
  - /lib/pkgconfig
  - /share/pkgconfig
  - '*.la'

modules:
  - name: openbangla-keyboard
    buildsystem: cmake-ninja
    config-opts:
      - -DCMAKE_BUILD_TYPE=Release
      - -DCMAKE_INSTALL_PREFIX=/app/addons/OpenBangla
      - -DENABLE_FCITX=ON
    builddir: true
    sources:
      - type: git
        url: https://github.com/OpenBangla/OpenBangla-Keyboard.git
        tag: develop
    build-commands:
      - cmake .. -GNinja
      - ninja install
    build-requires:
      - org.freedesktop.Sdk.Extension.rust-stable//22.08

trying to run using

flatpak-builder --force-clean --install-deps-from=flathub --repo=repo --install build-dir org.fcitx.Fcitx5.Addon.OpenBangla.yaml

But i am getting some kind of network error when submodule trying to fetch dependency.

[12/28] running cargo
FAILED: src/engine/riti/x86_64-unknown-linux-gnu/release/libriti.a /run/build/openbangla-keyboard/_flatpak_build/src/engine/riti/x86_64-unknown-linux-gnu/release/libriti.a 
cd /run/build/openbangla-keyboard/src/engine/riti && /usr/bin/cmake -E env CARGO_TARGET_DIR=/run/build/openbangla-keyboard/_flatpak_build/src/engine/riti /usr/lib/sdk/rust-stable/bin/cargo build --target x86_64-unknown-linux-gnu --release
    Updating crates.io index
warning: spurious network error (3 tries remaining): [6] Couldn't resolve host name (Could not resolve host: index.crates.io)
warning: spurious network error (2 tries remaining): [6] Couldn't resolve host name (Could not resolve host: index.crates.io)
warning: spurious network error (1 tries remaining): [6] Couldn't resolve host name (Could not resolve host: index.crates.io)
error: failed to get `ahash` as a dependency of package `riti v0.1.0 (/run/build/openbangla-keyboard/src/engine/riti)`

Caused by:
  failed to query replaced source registry `crates-io`

Caused by:
  download of config.json failed

Caused by:
  failed to download from `https://index.crates.io/config.json`

Caused by:
  [6] Couldn't resolve host name (Could not resolve host: index.crates.io)
[15/28] Building CXX object src/frontend/CMakeFiles/openbangla-gui.dir/Layout.cpp.o
ninja: build stopped: subcommand failed.
Error: module openbangla-keyboard: Child process exited with code 1

As you can see I gave network permission. What to do?

The build phase is meant to be offline. For Rust the approach is to convert the Cargo.lock file into a list of sources that you then include in your manifest.

There is a tool available that takes care of the conversion:

1 Like