flatpak / flatpak-builder-tools

Various helper tools for flatpak-builder
191 stars 107 forks source link

Cargo.toml not found #344

Closed elpiel closed 1 year ago

elpiel commented 1 year ago

flatpak-builder version

1.0.10

Linux distribution and version

Ubuntu 20.04

Affected flatpak-builder tool

cargo/flatpak-cargo-generator.py

flatpak-builder tool cli args

No response

Source repository URL

No response

Flatpak-builder manifest URL

No response

Description

Based on the quickstart template I'm trying to build an app using a buildsystem: simple, the problem, however, is that every time it gets to the build-commands it returns an error that the Cargo.toml file is not found...

Running: cargo --offline fetch --manifest-path Cargo.toml --verbose
error: manifest path `Cargo.toml` does not exist

My manifest looks like this:

My manifest is in the root of the project:

app-id: com.........
runtime: org.gnome.Platform
runtime-version: "43"
sdk: "org.gnome.Sdk"
sdk-extensions:
  - org.freedesktop.Sdk.Extension.rust-stable
command: my-app-service
finish-args:
  - --share=network
  - --share=ipc
  - --socket=fallback-x11
  - --socket=wayland
  - --device=dri
  - --talk-name=org.kde.StatusNotifierWatcher
build-options:
  append-path: /usr/lib/sdk/rust-stable/bin
modules:
  - name: service
    buildsystem: simple
    build-options:
      env:
        # - RUSTFLAGS: '--remap-path-prefix =../'
        - CARGO_HOME: /run/build/service/cargo
    build-commands:
      # - echo $(pwd)
      # - ls -la .
      # - ls -la ../
      # - ls -la ../../
      # - ls -la ../../../
      - cargo --offline fetch --manifest-path Cargo.toml --verbose
      - cargo --offline build --release --features=bundled --verbose
    post-install:
      - install -Dm755 target/release/my-app-service -t /app/bin/my-app-service/
      - install -Dm644 flatpak/com..........desktop /app/share/applications/com..........desktop
      - install -Dm644 flatpak/com..........svg /app/share/icons/hicolor/scalable/apps/com..........svg
      - install -Dm644 flatpak/com..........appdata.xml /app/share/metainfo/com..........xml
    sources:
      - type: dir
        path: "."
        # path: "../" # tried with RUSTFLAGS too
      - generated-sources.json # The file from the generator
    modules:
      - flatpak/shared-modules/libappindicator/libappindicator-gtk3-12.10.json # submodule
muelli commented 1 year ago

what makes you think that the file exists?

elpiel commented 1 year ago

Otherwise you cannot build the application+ the quickstart app also has this line for the build-commands: cargo --offline fetch --manifest-path Cargo.toml --verbose

gasinvein commented 1 year ago

@elpiel The quickstart example has the Cargo.toml file inside the directory with the manifest, thus the source with path: "." works fine. Without having a hint of what your source tree structure looks like, we can only guess what's wrong.

elpiel commented 1 year ago

Hello again,

Thank you for spending time to answer my issue! Here are more details, I hope this is enough.

I'm starting to think that there is a problem with either the project (and the git submodules) or my flatpak installation,

Here's the structure of the project:

$ python3 flatpak/flatpak-builder-tools/cargo/flatpak-cargo-generator.py Cargo.lock $ flatpak-builder --repo=flatpak/stremio-flatpak-repo --force-clean flatpak/flatpak-build com.stremio.Service.json - this is the place where I get the error $ flatpak build-bundle flatpak/stremio-flatpak-repo flatpak/com.stremio.Service.flatpak com.stremio.Service master

[submodule "flatpak/shared-modules"] path = flatpak/shared-modules url = https://github.com/flathub/shared-modules

`flatpak-builder-tools` was on `33e4e62` now I've updated it to `900a165` - same result.
`share-module` was on `4046709` and now is on `348c4fd` - same result.

I still get a warning when `flatpack-builder` is ran, which is for the `generated-sources.json` file:

(flatpak-builder:20233): flatpak-builder-WARNING **: 09:30:53.495: Unknown source type inline

(flatpak-builder:20233): Json-WARNING **: 09:30:53.496: Failed to deserialize "sources" property of type "gpointer" for an object of type "BuilderModule"


![Screenshot from 2023-01-17 09-22-28](https://user-images.githubusercontent.com/8925621/212834805-a4c4733a-ee9c-4dd9-bd82-76047211132c.png)

#### Update on quickstart

I tried running the quickstart example in this repo and I get the same issue:

.../service/flatpak/flatpak-builder-tools/cargo/quickstart$ flatpak-builder --force-clean flatpak/flatpak-build com.flatpak.quickstart.json

(flatpak-builder:22144): flatpak-builder-WARNING **: 09:37:16.909: Unknown source type inline

(flatpak-builder:22144): Json-WARNING **: 09:37:16.909: Failed to deserialize "sources" property of type "gpointer" for an object of type "BuilderModule" Downloading sources Initializing build dir Committing stage init to cache Starting build of com.flatpak.quickstart

Building module quickstart in /home/elpiel/PROJECTS/AdEx/stremio/service/flatpak/flatpak-builder-tools/cargo/quickstart/.flatpak-builder/build/quickstart-1

Running: cargo --offline fetch --manifest-path Cargo.toml --verbose error: manifest path Cargo.toml does not exist Error: module quickstart: Child process exited with code 101


Mind you that I've updated the quickstart application manifest:
"runtime": "org.gnome.Platform",
"runtime-version": "43",
"sdk": "org.gnome.Sdk",
"sdk-extensions": ["org.freedesktop.Sdk.Extension.rust-stable"],
hfiguiere commented 1 year ago

you should use the flatpak-builder available as a flatpak org.flatpak.Builder. The one in your 3 year old Ubuntu is likely too old.

elpiel commented 1 year ago

Using org.flatpak.Builder got me further :tada: but I did get to yet another issue using the flatpak version of the builder. Our build script needs access to internet as it has to download some binaries but the build script fails. It seems building in the sandboxed environment of the flatpak builder can't access the internet.

error: failed to run custom build command for `stremio-service v0.1.0 (/run/build/service)`

Caused by:
  process didn't exit successfully: `/run/build/service/target/release/build/stremio-service-47e7e7633688b4e4/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=src/

  --- stderr
  Error: reqwest::Error { kind: Request, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("dl.strem.io")), port: None, path: "/four/master/server.js", query: None, fragment: None }, source: hyper::Error(Connect, ConnectError("dns error", Custom { kind: Uncategorized, error: "failed to lookup address information: Temporary failure in name resolution" })) }
warning: build failed, waiting for other jobs to finish...
Error: module service: Child process exited with code 101
hfiguiere commented 1 year ago

build must be offline. if a crate tries to unconditionaly download something, it has to be fixed.

hfiguiere commented 1 year ago

Closing as the initial problem is solved. Not a bug.

elpiel commented 1 year ago

Thank you!

gasinvein commented 1 year ago

@elpiel The build-options.env block in your manifest looks wrong. It should be an object, not an array.

elpiel commented 1 year ago

Good catch! We actually use a json file, however, for the sake of testing and comments I rewrote it in yaml.