Snapcraft build for flutter fails

Hey there,
I am creating a desktop application for linux in flutter.
I want to release it on snap (mostly because flutter provides a little how to and I don't looked for alternatives).
When snapcrafting, I get following exception:

/root/snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.3/
[  +60 ms] 💪 Building with sound null safety 💪
[   +8 ms] Building Linux application...
[  +11 ms] executing: [build/linux/x64/release/] cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DFLUTTER_TARGET_PLATFORM=linux-x64
/root/parts/nextcloud-password-client/build/linux
[ +827 ms] -- The CXX compiler identification is Clang 6.0.0
[  +13 ms] -- Check for working CXX compiler: /snap/flutter/current/usr/bin/clang++
[ +121 ms] -- Check for working CXX compiler: /snap/flutter/current/usr/bin/clang++ -- works
[   +1 ms] -- Detecting CXX compiler ABI info
[ +107 ms] -- Detecting CXX compiler ABI info - done
[  +11 ms] -- Detecting CXX compile features
[ +818 ms] -- Detecting CXX compile features - done
[   +5 ms] -- Found PkgConfig: /snap/flutter/current/usr/bin/pkg-config (found version "0.29.1") 
[        ] -- Checking for module 'gtk+-3.0'
[  +15 ms] --   Found gtk+-3.0, version 3.22.30
[  +67 ms] -- Checking for module 'glib-2.0'
[  +17 ms] --   Found glib-2.0, version 2.56.4
[  +35 ms] -- Checking for module 'gio-2.0'
[  +14 ms] --   Found gio-2.0, version 2.56.4
[  +47 ms] -- Checking for module 'libsecret-1>=0.18.4'
[   +4 ms] --   No package 'libsecret-1' found
[        ] -- Configuring incomplete, errors occurred!
[        ] See also "/root/parts/nextcloud-password-client/build/build/linux/x64/release/CMakeFiles/CMakeOutput.log".
[   +1 ms] CMake Error at /snap/flutter/101/usr/share/cmake-3.10/Modules/FindPkgConfig.cmake:419 (message):
[   +1 ms]   A required package was not found
[        ] Call Stack (most recent call first):
[        ]   /snap/flutter/101/usr/share/cmake-3.10/Modules/FindPkgConfig.cmake:597 (_pkg_check_modules_internal)
[        ]   flutter/ephemeral/.plugin_symlinks/flutter_secure_storage_linux/linux/CMakeLists.txt:13 (pkg_check_modules)
[   +5 ms] Building Linux application... (completed in 2,130ms)
[        ] "flutter linux" took 7,739ms.
[   +3 ms] Unable to generate build files
[   +1 ms] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      _runCmake (package:flutter_tools/src/linux/build_linux.dart:155:5)
           <asynchronous suspension>
           #2      buildLinux (package:flutter_tools/src/linux/build_linux.dart:75:5)
           <asynchronous suspension>
           #3      BuildLinuxCommand.runCommand (package:flutter_tools/src/commands/build_linux.dart:88:5)
           <asynchronous suspension>
           #4      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1130:27)
           <asynchronous suspension>
           #5      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #6      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
           <asynchronous suspension>
           #7      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:288:9)
           <asynchronous suspension>
           #8      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #9      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:236:5)
           <asynchronous suspension>
           #10     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
           <asynchronous suspension>
           #11     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #12     main (package:flutter_tools/executable.dart:92:3)
           <asynchronous suspension>
           
           
[  +67 ms] ensureAnalyticsSent: 57ms
[   +2 ms] Running shutdown hooks
[        ] Shutdown hooks complete
[        ] exiting with code 1
Failed to run 'flutter build linux --release -v -t lib/main.dart' for 'nextcloud-password-client': Exited with code 1.
Verify that the part is using the correct parameters and try again.

is it possible that the exception is thrown because libsecret-1-0 is the name of the ubuntu package and not the arch one? If so, how can I craft the snap on arch than?
I know that there is flutter_secured_storage-linux simlink is mentioned. But if that would be the problem I'd assume that the normal build would'nt work eiter.

Hi there, welcome to the community.

Try installing libsecret

sudo pacman -S libsecret
1 Like

Hey,
thanks for the answer.
But unfortunately it is already installed, as I needed it to test the app :-/

Wait, this means you explicitly marked libsecret-1 as dependency? I am not really sure but as far as I know, libsecret-1 is for debian based and libsecret is for Arch based.

So, is there any way to mark it as an "alternative" dependency?

3 Likes

After 2 more hours of search I found the "try" command.
If you use "try: -libsecret-1-0 else: -libsecret"
snap will use libsecret as fallbakc if libsecret-1-0 is not found.
Your "alternative" lead me to seach fo rsnap different distro which lead me finally to the advanced grammar section from offical documentation -.-

2 Likes

So, it's solved now I guess.

And btw, it's a new thing you learned. Good for you!

1 Like

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