使用 snapcraft 为 Linux snap 包构建 flutter 应用程序时出错 - CMake 步骤失败
Error when building flutter app for Linux snap package using snapcraft - CMake step failing
此问题已在此处提出并(错误地)作为与旧 CMAKE 问题的 link 的重复项关闭。可能关闭的人没有正确阅读问题。这与普通 CMake 配置无关,除非您想在 snapcraft 源代码中配置 CMake 使用。
Error when building flutter app for Linux snap package using snapcraft
事实是运行 snapcraft 失败了。 运行 它与 --debug 一起为您提供 snapcraft / multipass 文件系统的根控制台,whoami 表示根,但您只能看到周围的快照(例如,不是您的家)。无论如何,错误说
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 错误。因为前阵子问过原题,显然这还是不行。有人解决过这个问题吗?
更新、清除 multipass 并尝试使用 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里
删除构建目录并重新构建。
如果您在构建时遇到任何错误,只需 运行 snapcraft build --debug
然后删除parts
文件夹下your_part_name
的整个文件夹
解决方案是在您的 flutter 项目根文件夹(包含 build、lib、snap 等文件夹)中执行以下命令:
snapcraft clean <project-name>
这会删除“/root/parts/>project-name>”文件夹中的构建缓存。
如果这还不够,您可以使用
清理整个 snapcraft 零件文件夹
snapcraft clean
但这包括所有依赖项。这意味着下次编译项目时必须重新下载所有依赖项。
Then delete the whole folder of your_part_name under parts folder
这不起作用,因为“parts”文件夹位于“/root”目录中,我们无法手动访问或删除其中的内容。
但如果我们可以更改零件文件夹,例如进入我们的 /home 目录。但我还没有找到任何可能性!
对我来说,删除本地目录中的构建目录也很重要:
rm -rf build && snapcraft clean <project> && snapcraft
此问题已在此处提出并(错误地)作为与旧 CMAKE 问题的 link 的重复项关闭。可能关闭的人没有正确阅读问题。这与普通 CMake 配置无关,除非您想在 snapcraft 源代码中配置 CMake 使用。
Error when building flutter app for Linux snap package using snapcraft
事实是运行 snapcraft 失败了。 运行 它与 --debug 一起为您提供 snapcraft / multipass 文件系统的根控制台,whoami 表示根,但您只能看到周围的快照(例如,不是您的家)。无论如何,错误说
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 错误。因为前阵子问过原题,显然这还是不行。有人解决过这个问题吗?
更新、清除 multipass 并尝试使用 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里
删除构建目录并重新构建。
如果您在构建时遇到任何错误,只需 运行 snapcraft build --debug
然后删除parts
文件夹下your_part_name
的整个文件夹
解决方案是在您的 flutter 项目根文件夹(包含 build、lib、snap 等文件夹)中执行以下命令:
snapcraft clean <project-name>
这会删除“/root/parts/>project-name>”文件夹中的构建缓存。
如果这还不够,您可以使用
清理整个 snapcraft 零件文件夹snapcraft clean
但这包括所有依赖项。这意味着下次编译项目时必须重新下载所有依赖项。
Then delete the whole folder of your_part_name under parts folder
这不起作用,因为“parts”文件夹位于“/root”目录中,我们无法手动访问或删除其中的内容。
但如果我们可以更改零件文件夹,例如进入我们的 /home 目录。但我还没有找到任何可能性!
对我来说,删除本地目录中的构建目录也很重要:
rm -rf build && snapcraft clean <project> && snapcraft