fluttersnapcraft

Error when building flutter app for Linux snap package using snapcraft - CMake step failing


This question has been asked here and (erroneously) closed as a duplicate with a link to an old CMAKE question. Probably the closing person did not read the question properly. This has nothing to do with plain CMake configuration, unless you want to configure the CMake use in snapcraft source code.

Error when building flutter app for Linux snap package using snapcraft

The fact is that running snapcraft fails. Running it with --debug gives you a root console of the snapcraft / multipass filesystem, whoami says root, but you only see the snap things around (for instance, not your home). Anyways, the error says

CMake Error: The current CMakeCache.txt directory /root/parts/xxxxx/build/build/linux/release/CMakeCache.txt is different than the directory
/home/zolal/flutterapps/xxxxx/build/linux/release where CMakeCache.txt was created. This may result in binaries being created in the wrong
place. If you are not sure, reedit the CMakeCache.txt 

(naturally, you cannot reedit the CMAKECache.txt, because this is created by snapcraft)

It seems that the cmake build starts outside of the snapcraft / multipass VM, and than moves to the multipass VM resulting in CMake error. Because the original question was asked a while ago, obviously this still does not work. Did anyone solve this problem alredy?

Update, purged multipass and tried with lxd:

snapcraft --use-lxd
Launching a container.
Waiting for container to be ready
Waiting for network to be ready...
snap "snapd" has no updates available
The flutter plugin is currently in beta, its API may break. Use at your own risk.
snapd is not logged in, snap install commands will use sudo
snap "core18" has no updates available
Skipping pull flutter-extension (already ran)
Skipping pull geraspine-outcome-pc (already ran)
Skipping pull gnome-3-28-extension (already ran)
Skipping build flutter-extension (already ran)
Building geraspine-outcome-pc 
flutter pub get
   Woah! You appear to be trying to run flutter as root.
   We strongly recommend running the flutter tool without superuser privileges.
  /
šŸ“Ž
Error: No pubspec.yaml file found.
This command should be run from the root of your Flutter project.
Failed to run 'flutter pub get' for 'geraspine-outcome-pc': Exited with code 1.
Verify that the part is using the correct parameters and try again.
Run the same command again with --debug to shell into the environment if you wish to introspect this failure.

Naturally, the pubspec.yaml is there, but the files are obviously not transferred to the VM.


Solution

  • Delete build directory and build again.

    src github-issue