【问题标题】:Error when building flutter app for Linux snap package using snapcraft - CMake step failing使用 snapcraft 为 Linux snap 包构建 Flutter 应用程序时出错 - CMake 步骤失败
【发布时间】:2021-01-29 09:23:24
【问题描述】:

已在此处提出此问题,并且(错误地)作为副本关闭,并带有指向旧 CMAKE 问题的链接。可能关闭的人没有正确阅读问题。这与普通的 CMake 配置无关,除非您想在 snapcraft 源代码中配置 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。

【问题讨论】:

  • 面临同样的问题你找到解决方案了吗,接受的答案似乎对我不起作用
  • 不,对不起,我最终放弃了。

标签: flutter snapcraft


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

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

    snapcraft clean <project-name>
    

    这会删除“/root/parts/>project-name>”文件夹中的构建缓存。

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

    snapcraft clean
    

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

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

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

    但如果我们可以更改零件文件夹,例如进入我们的 /home 目录。但我还没有找到任何可能!

    【讨论】:

    • 长期面对这个问题有什么解决办法吗??
    【解决方案3】:

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

    srcgithub-issue

    【讨论】:

    • 这是不同的。删除构建目录并再次尝试是我尝试的第一件事。 GitHub 上的问题在 cmake 中的两个目录都从 home 开始,在我的情况下,第一个在 /root 中((Multipass VM 的根目录))。但是 - 很好的答案,因为我将开始一个 GitHub 问题。
    • 是的,这不应该是公认的答案。这是一个不同的问题
    • @amirzolal 你找到解决这个问题的方法了吗?你能链接你提到的github问题吗?
    • 对不起 Damien,虽然我打算创建一个 github issue,但我忘记了它(主要是因为我现在只需要将 windows 可执行文件部署到其他计算机)。而且我不再寻找解决方案了。
    猜你喜欢
    • 2021-05-09
    • 2020-12-05
    • 2020-03-30
    • 2020-03-16
    • 1970-01-01
    • 2022-09-29
    • 1970-01-01
    • 2018-08-28
    • 1970-01-01
    相关资源
    最近更新 更多