使用snapcraft为Linux快照程序包构建flutter应用程序时出错-CMake步骤失败

问题描述

此问题已在此处提出,并且(错误地)作为重复项被关闭,并带有指向旧CMAKE问题的链接。结案人可能未正确阅读问题。除非您要在snapcraft源代码中配置CMake使用,否则这与普通CMake配置无关。

Error when building flutter app for Linux snap package using snapcraft

事实是运行snapcraft失败。使用--debug运行它可以为您提供snapcraft / multipass文件系统的根控制台,whoami说是root,但是您只能看到周围的快照(例如,不是您的家)。无论如何,错误提示

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 

(自然,您不能重新编辑CMAKECache.txt,因为它是由snapcraft创建的)

cmake构建似乎在snapcraft / multipass VM外部开始,然后移动到multipass VM,从而导致CMake错误。因为最初的问题是前一段时间提出的,所以显然这仍然行不通。有人解决了这个问题吗?

更新,清除多遍并尝试使用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.

自然地,这里是pubspec.yaml,但是文件显然没有传输到VM。

解决方法

删除构建目录并重新构建。

src github-issue

,

如果在构建此代码时遇到任何错误,只需运行snapcraft build --debug

然后删除your_part_name文件夹下parts的整个文件夹

,

解决方案是在flutter项目的根文件夹(包含build,lib,snap等文件夹)中执行以下命令:

snapcraft clean <project-name>

这将删除“ / root / parts />项目名称>”文件夹中的构建缓存。

如果这还不够,您可以使用以下命令清理整个snapcraft零件文件夹

snapcraft clean

但这包括所有依赖项。这意味着,下次您编译项目时,必须重新下载所有依赖项。

然后删除零件文件夹下your_part_name的整个文件夹

这不起作用,因为“ parts”文件夹位于“ / root”目录下,并且我们无法手动访问或删除其中的内容。

但是如果我们可以更改parts文件夹(例如,进入我们的/ home目录。但是我还没有发现任何可能性!

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...