saber
saber copied to clipboard
Unable to compile for Linux offline - pdfium dependency
Before submitting an issue, please check the following
- [X] I have searched for similar issues (both open and closed) and cannot find a duplicate
- [X] I agree to follow the Code of Conduct
Describe the bug
I'm trying to put together a Nix derivation for building Saber, which I hope to submit to the nixpkgs repository if I get it working. I have all the dependencies in place and cmake finds everything fine, but the build process then seems to try to download a binary of pdfium from github.com/bblanchon/pdfium-binaries.
This doesn't work within Nix, as all building is done in a sandboxed environment with no internet access and all dependencies are expected to be available beforehand (or otherwise buildable). Compilation therefore fails since this binary can't be fetched:
Build Log
[ +26 ms] Building Linux application...
[ +2 ms] executing: [build/linux/x64/release/] cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DFLUTTER_TARGET_PLATFORM=linux-x64 /build/source/linux
[ +124 ms] -- The CXX compiler identification is Clang 17.0.6
[ +23 ms] -- Detecting CXX compiler ABI info
[ +128 ms] -- Detecting CXX compiler ABI info - done
[ +34 ms] -- Check for working CXX compiler: /nix/store/jbm7b0gdxrjbbyh8rvkfp7xdm0s4saaj-clang-wrapper-17.0.6/bin/clang++ - skipped
[ ] -- Detecting CXX compile features
[ ] -- Detecting CXX compile features - done
[ +3 ms] -- Found PkgConfig: /nix/store/d7gxj7i9zr04mgf819k34vm5dzxgxjzn-pkg-config-wrapper-0.29.2/bin/pkg-config (found version "0.29.2")
[ ] -- Checking for module 'gtk+-3.0'
[ +17 ms] -- Found gtk+-3.0, version 3.24.42
[ +144 ms] -- Checking for module 'glib-2.0'
[ +13 ms] -- Found glib-2.0, version 2.80.3
[ +31 ms] -- Checking for module 'gio-2.0'
[ +14 ms] -- Found gio-2.0, version 2.80.3
[ +57 ms] -- Checking for module 'gstreamer-1.0'
[ +15 ms] -- Found gstreamer-1.0, version 1.24.3
[ +46 ms] -- Checking for module 'gstreamer-app-1.0'
[ +15 ms] -- Found gstreamer-app-1.0, version 1.24.3
[ +57 ms] -- Checking for module 'gstreamer-audio-1.0'
[ +15 ms] -- Found gstreamer-audio-1.0, version 1.24.3
[ +56 ms] -- Checking for module 'libsecret-1>=0.18.4'
[ +14 ms] -- Found libsecret-1, version 0.21.4
[ +58 ms] -- Downloading/updating pdfium
[ +20 ms] -- Configuring done (0.0s)
[ ] -- Generating done (0.0s)
[ +6 ms] -- Build files have been written to: /build/source/build/linux/x64/release/pdfium-download
[ +16 ms] [1/9] Creating directories for 'pdfium-download'
[+85025 ms] [2/9] Performing download step (download, verify and extract) for 'pdfium-download'
[ ] FAILED: pdfium-download-prefix/src/pdfium-download-stamp/pdfium-download-download /build/source/build/linux/x64/release/pdfium-download/pdfium-download-prefix/src/pdfium-download-stamp/pdfium-download-download
[ ] cd /build/source/build/linux/x64/release && /nix/store/ll2b6cslly4v30im7qk34f9y21ziiz1i-cmake-3.29.6/bin/cmake -P /build/source/build/linux/x64/release/pdfium-download/pdfium-download-prefix/src/pdfium-download-stamp/download-pdfium-download.cmake && /nix/store/ll2b6cslly4v30im7qk34f9y21ziiz1i-cmake-3.29.6
/bin/cmake -P /build/source/build/linux/x64/release/pdfium-download/pdfium-download-prefix/src/pdfium-download-stamp/verify-pdfium-download.cmake && /nix/store/ll2b6cslly4v30im7qk34f9y21ziiz1i-cmake-3.29.6/bin/cmake -P /build/source/build/linux/x64/release/pdfium-download/pdfium-download-prefix/src/pdfium-download-st
amp/extract-pdfium-download.cmake && /nix/store/ll2b6cslly4v30im7qk34f9y21ziiz1i-cmake-3.29.6/bin/cmake -E touch /build/source/build/linux/x64/release/pdfium-download/pdfium-download-prefix/src/pdfium-download-stamp/pdfium-download-download
[ ] -- Downloading...
[ ] dst='/build/source/build/linux/x64/release/pdfium-download/pdfium-download-prefix/src/pdfium-linux-x64.tgz'
[ ] timeout='none'
[ ] inactivity timeout='none'
[ ] -- Using src='https://github.com/bblanchon/pdfium-binaries/releases/download/chromium/5200/pdfium-linux-x64.tgz'
[ ] -- Retrying...
[ ] -- Using src='https://github.com/bblanchon/pdfium-binaries/releases/download/chromium/5200/pdfium-linux-x64.tgz'
[ ] -- Retry after 5 seconds (attempt #2) ...
[ ] -- Using src='https://github.com/bblanchon/pdfium-binaries/releases/download/chromium/5200/pdfium-linux-x64.tgz'
[ ] -- Retry after 5 seconds (attempt #3) ...
[ ] -- Using src='https://github.com/bblanchon/pdfium-binaries/releases/download/chromium/5200/pdfium-linux-x64.tgz'
[ ] -- Retry after 15 seconds (attempt #4) ...
[ ] -- Using src='https://github.com/bblanchon/pdfium-binaries/releases/download/chromium/5200/pdfium-linux-x64.tgz'
[ ] -- Retry after 60 seconds (attempt #5) ...
[ ] -- Using src='https://github.com/bblanchon/pdfium-binaries/releases/download/chromium/5200/pdfium-linux-x64.tgz'
[ ] CMake Error at pdfium-download/pdfium-download-prefix/src/pdfium-download-stamp/download-pdfium-download.cmake:162 (message):
[ ] Each download failed!
[ ] error: downloading 'https://github.com/bblanchon/pdfium-binaries/releases/download/chromium/5200/pdfium-linux-x64.tgz' failed
[ ] status_code: 6
[ ] status_string: "Couldn't resolve host name"
[ ] log:
[ ] --- LOG BEGIN ---
[ ] Could not resolve host: github.com
[ ] Closing connection
[ ] --- LOG END ---
[ ] error: downloading 'https://github.com/bblanchon/pdfium-binaries/releases/download/chromium/5200/pdfium-linux-x64.tgz' failed
[ ] status_code: 6
[ ] status_string: "Couldn't resolve host name"
[ ] log:
[ ] --- LOG BEGIN ---
[ ] Could not resolve host: github.com
[ ] Closing connection
[ ] --- LOG END ---
[ ] error: downloading 'https://github.com/bblanchon/pdfium-binaries/releases/download/chromium/5200/pdfium-linux-x64.tgz' failed
[ ] status_code: 6
[ ] status_string: "Couldn't resolve host name"
[ ] log:
[ ] --- LOG BEGIN ---
[ ] Could not resolve host: github.com
[ ] Closing connection
[ ] --- LOG END ---
[ ] error: downloading 'https://github.com/bblanchon/pdfium-binaries/releases/download/chromium/5200/pdfium-linux-x64.tgz' failed
[ ] status_code: 6
[ ] status_string: "Couldn't resolve host name"
[ ] log:
[ ] --- LOG BEGIN ---
[ ] Could not resolve host: github.com
[ ] Closing connection
[ ] --- LOG END ---
[ ] error: downloading 'https://github.com/bblanchon/pdfium-binaries/releases/download/chromium/5200/pdfium-linux-x64.tgz' failed
[ ] status_code: 6
[ ] status_string: "Couldn't resolve host name"
[ ] log:
[ ] --- LOG BEGIN ---
[ ] Could not resolve host: github.com
[ ] Closing connection
[ ] --- LOG END ---
[ ] error: downloading 'https://github.com/bblanchon/pdfium-binaries/releases/download/chromium/5200/pdfium-linux-x64.tgz' failed
[ ] status_code: 6
[ ] status_string: "Couldn't resolve host name"
[ ] log:
[ ] --- LOG BEGIN ---
[ ] Could not resolve host: github.com
[ ] Closing connection
[ ] --- LOG END ---
[ ] ninja: build stopped: subcommand failed.
[ ] CMake Error at flutter/ephemeral/.plugin_symlinks/printing/windows/DownloadProject.cmake:179 (message):
[ ] Build step for pdfium failed: 1
[ ] Call Stack (most recent call first):
[ ] flutter/ephemeral/.plugin_symlinks/printing/linux/CMakeLists.txt:37 (download_project)
[ ] -- Configuring incomplete, errors occurred!
[ +5 ms] Building Linux application... (completed in 86.0s)
[ ] "flutter linux" took 86,233ms.
[ +1 ms] Unable to generate build files
[ ]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 _runCmake (package:flutter_tools/src/linux/build_linux.dart:174:5)
<asynchronous suspension>
#2 buildLinux (package:flutter_tools/src/linux/build_linux.dart:81:5)
<asynchronous suspension>
#3 BuildLinuxCommand.runCommand (package:flutter_tools/src/commands/build_linux.dart:89:5)
<asynchronous suspension>
#4 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1394:27)
<asynchronous suspension>
#5 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#6 CommandRunner.runCommand (package:args/command_runner.dart:212:13)
<asynchronous suspension>
#7 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:366:9)
<asynchronous suspension>
#8 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#9 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:308:5)
<asynchronous suspension>
#10 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:130:9)
<asynchronous suspension>
#11 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:153:19)
<asynchronous suspension>
#12 main (package:flutter_tools/executable.dart:93:3)
<asynchronous suspension>
To reproduce
With Nix
- On a Linux machine running Nix, copy the following derivation into a file:
{
lib,
fetchFromGitHub,
flutter322,
rustc,
cargo,
libsecret,
jsoncpp,
gst_all_1,
libunwind,
orc,
...
}:
let
pname = "saber";
version = "0.24.3";
# pubspecLock = lib.importJSON ./pubspec.lock.json;
in
flutter322.buildFlutterApplication {
inherit pname version;
src = fetchFromGitHub {
owner = "saber-notes";
repo = pname;
rev = "v${version}";
hash = "sha256-mWRUUY8kNbYbYbpgxhi3JLbVBWhJzSzguXj1S6HGwUs=";
};
gitHashes = {
"json2yaml" = "sha256-Vb0Bt11OHGX5+lDf8KqYZEGoXleGi5iHXVS2k7CEmDw=";
};
pubspecLock = lib.importJSON ./pubspec.lock.json;
buildInputs = [
rustc
cargo
libsecret.dev
jsoncpp.dev
gst_all_1.gstreamer.dev
gst_all_1.gst-plugins-base.dev
libunwind.dev
orc.dev
];
}
- Download pubspec.lock.json into the same folder as the derivation.
- Run
nix-build
ornix build
depending on if you're using flakes or not.
Without Nix
- Follow the normal build instructions for Linux, up to and including running
flutter pub get
. - Disconnect your PC from the internet.
- Run
flutter build linux
.
Expected behavior
For a build with Nix to work, Saber needs to fetch all dependencies (outside of flutter, libgstreamer, etc.) as part of running flutter pub get
, which Nix's buildFlutterApplication
handles by separately fetching each of the dependencies in pubspec.yaml and including them as their own source packages that the main build can use.
Saber version
0.24.3
Device
- Device: Linux Desktop
- OS: NixOS 24.11 (Vicuna)
Anything else?
I can't seem to find any mention of pdfium in this repo, with only passing references to it in a few issues. Is it a dependency of a dependency? I should note that this is my first time using Flutter, so apologies if I've missed something obvious.
If there's a way of passing an already installed version of pdfium to whatever is asking for it, that might be possible. I don't think Nix has a version of pdfium packaged yet though, so that would have to be a separate venture.