news 2026/9/9 21:16:58

如何在 Linux 上安装 AppFlowy 构建依赖并从源码首次构建应用

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
如何在 Linux 上安装 AppFlowy 构建依赖并从源码首次构建应用

如何在 Linux 上安装 AppFlowy 构建依赖并从源码首次构建应用

【免费下载链接】AppFlowyBring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.项目地址: https://gitcode.com/GitHub_Trending/ap/AppFlowy

AppFlowy 的 Linux 桌面版由 Flutter 前端与 Rust 后端两部分组成:Rust 侧的dart-fficrate 编译出动态库libdart_ffi.so供 Flutter 侧链接,再由flutter build linux打包整个应用。本文面向 Linux x86_64 环境,目标是完成一次从源码到可运行产物的首次构建:安装构建依赖(Rust、Flutter 指定版本、系统开发库),然后执行仓库自带的 cargo-make 构建链。构建成功后,会在appflowy_flutter/product/下生成 AppFlowy 的 Linux 产品目录。

准备条件

仓库提供了一键依赖安装脚本 install_linux.sh,但它对系统已有环境有如下要求:

  • Flutter SDK 必须已安装且在 PATH 中。脚本不会安装 Flutter,它只负责把 Flutter 切换到指定版本并做检查;
  • 包管理器为 apt-get 或 dnf。脚本对系统库的安装只覆盖这两种包管理器,其他发行版会提示手动安装;
  • git 可用(脚本内部用 git 切换 Flutter 版本);
  • 具备 sudo 权限,脚本中的系统库安装步骤会调用sudo apt-get/sudo dnf

另外,仓库通过 rust-toolchain.toml 固定了 Rust 工具链:

[toolchain] channel = "1.85" components = ["clippy", "rustfmt"]

即进入该目录构建时使用的 Rust 版本为 1.85(rustup 会根据此文件选用对应工具链)。

安装构建依赖

在仓库根目录执行:

bash scripts/install_dev_env/install_linux.sh

脚本必须从仓库根目录运行,因为它内部使用相对路径(.githooks目录、cd frontend)。各步骤的行为和副作用如下,执行前需要知道:

  1. Rust 安装(交互式)。脚本询问Do you want to install Rust? [y/N],未安装 Rust 时选择Y,等价于执行:

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh source $HOME/.cargo/env rustup toolchain install stable rustup default stable

    已有 Rust 环境可选择跳过。

  2. Flutter 版本切换。脚本检查flutter --version,若不是 3.27.4,会在 Flutter SDK 所在目录执行git checkout 3.27.4。注意这会改变你系统中 Flutter SDK 的检出状态,然后执行:

    flutter config --enable-linux-desktop flutter doctor

    flutter doctor用于检查并暴露环境中的其他问题,脚本注释中说明其用途是修复flutter doctor报告的项。

  3. 系统开发库安装(需要 sudo)。apt 与 dnf 的包名不同:

    # apt 系(Debian/Ubuntu) sudo apt-get install keybinder-3.0-dev sudo apt-get install libnotify-dev sudo apt-get install libmpv-dev mpv # dnf 系(Fedora/RHEL) sudo dnf install keybinder3-devel sudo dnf install libnotify-dev sudo dnf install libmpv-dev mpv

    脚本注释说明libmpv-dev mpv是为 Video Block 支持安装;其他发行版会提示please install ... manually

  4. git hooks 配置(提交规范相关,非构建必需)。脚本会设置git config core.hooksPath .githooks,并从上游下载go-gitlint_1.1.0_linux_x86_64.tar.gz解压gitlint.githooks/目录。这属于贡献者提交校验流程,脚本把它和构建依赖放在一起执行。

  5. cargo-make 与 duckscript。进入frontend/目录后安装:

    cargo install --force cargo-make cargo install --force --locked duckscript_cli
  6. 前置依赖检查。脚本最后执行:

    cargo make appflowy-flutter-deps-tools

    对应 env.toml 中的任务链:rustup target add x86_64-unknown-linux-gnu,以及安装 protobuf 的 Dart 编译器插件(当protoc-gen-dart不在 PATH 中时执行dart pub global activate protoc_plugin 21.1.2,见 protobuf.toml)。

执行首次构建

依赖就绪后,在frontend/目录执行开发版(debug)构建:

cd frontend cargo make --profile development-linux-x86_64 appflowy-linux-dev

--profile development-linux-x86_64不是可省略的:Makefile.toml 中该 profile 提供了构建任务检查所必需的环境变量(TARGET_OSRUST_COMPILE_TARGETCRATE_TYPEBUILD_FLAG等),任务env_check的条件就是这些变量已设置。x86_64 profile 的关键取值为RUST_COMPILE_TARGET = "x86_64-unknown-linux-gnu"BUILD_FLAG = "debug"LIB_EXT = "so"LINUX_ARCH = "x64"

appflowy-linux-dev任务链按顺序执行(定义见 flutter.toml 与 desktop.toml):

  1. 编译 Rust 核心库。在rust-lib/下执行:

    RUSTFLAGS="--cfg tokio_unstable" cargo build --package=dart-ffi \ --target x86_64-unknown-linux-gnu --features "dart"

    完成后,产物拷贝步骤会把rust-lib/target/x86_64-unknown-linux-gnu/debug/libdart_ffi.sorust-lib/dart-ffi/binding.h复制到appflowy_flutter/linux/flutter/dart_ffi/目录,并打印:

    🚀 🚀 🚀 AppFlowy-Core build success
  2. 代码生成,执行./scripts/code_generation/generate.sh

  3. Flutter 构建,在appflowy_flutter/下执行:

    flutter pub get flutter packages pub get flutter build linux --debug --verbose
  4. 产物归集,把appflowy_flutter/build/linux/x64/debug/bundle目录拷贝到产品目录。

验证构建结果

任务链全部完成后,检查以下位置(文档中任务脚本实际写入/输出的路径):

  • 核心库阶段打印的AppFlowy-Core build success信息;
  • appflowy_flutter/linux/flutter/dart_ffi/下存在libdart_ffi.sobinding.h
  • Flutter 构建产物目录appflowy_flutter/build/linux/x64/debug/bundle
  • 最终产品目录appflowy_flutter/product/0.11.4/linux/Debug/AppFlowy,其中0.11.4来自 Makefile.toml 中的APPFLOWY_VERSION = "0.11.4"(未显式传APP_VERSION时任务链以该值填充)。

如果某一步失败,cargo make会因on_error_task = "catch"触发restore-crate-type恢复任务,把rust-lib/dart-ffi/Cargo.toml的 crate type 改回staticlib,随后中止——因此报错后直接重试即可,无需手动还原该文件。

常见问题与限制

  • flutter命令找不到:脚本没有安装 Flutter 的职责,需要按 Flutter 官方安装说明先装好 SDK 并加入 PATH,再重跑脚本完成 3.27.4 版本切换与其余依赖安装。

  • apt/dnf 之外的包管理器:脚本会打印Your system is not supported, please install keybinder3 manually.(libnotify、libmpv 同理),需按发行版方式手动安装对应的开发库。

  • aarch64 Linux:本文路径是 x86_64。仓库也提供了development-linux-aarch64profile,与 x86_64 的差异是FLUTTER_DESKTOP_FEATURES = "dart,openssl_vendored"RUST_COMPILE_TARGET = "aarch64-unknown-linux-gnu",对应命令把 profile 换成development-linux-aarch64即可。

  • 想要 release 版产物:可选分支是使用appflowy-linux任务(release 核心库 + release 构建):

    cargo make --profile production-linux-x86_64 appflowy-linux

    产物会归集到appflowy_flutter/product/0.11.4/linux/Release/AppFlowy

仓库中与本文相关的文件:依赖脚本 install_linux.sh、任务定义 Makefile.toml 及 scripts/makefile 下的desktop.tomlflutter.tomlenv.tomlprotobuf.toml、工具链固定 rust-toolchain.toml。

【免费下载链接】AppFlowyBring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.项目地址: https://gitcode.com/GitHub_Trending/ap/AppFlowy

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/9/9 21:16:33

VB.NET实现桌面应用自动更新:版本校验、下载替换与回滚

简介:这套基于VB.NET实现的软件自动更新程序,面向桌面应用开发者,解决客户端版本分发与升级维护难题。资源完整包含自动更新客户端、Web服务端及配置文件,覆盖从版本检查、更新包下载到本地替换安装的核心流程。压缩包共40个文件&…

作者头像 李华
网站建设 2026/9/9 21:16:28

ardupilot.7z 在 Linux 下的解压、校验与加密分发

简介:ArduPilot 开源飞控源码的预打包压缩包,面向在 Ubuntu 下开展无人机、机器人与航模开发的研究者和开发者,专门解决从 GitHub 克隆源码缓慢、环境准备耗时的问题,适用于二次开发、学习研究与仿真调试等场景。压缩包整体约 200…

作者头像 李华
网站建设 2026/9/9 21:15:59

领导者定义计划:如何将组织意义“上链”并重构商业价值

1. 先看懂这个标题:意义、上链、源代码,到底在说什么"当意义上链"这句话,第一次听确实像句玄学。但拆开看,它其实击中了一个很现实的管理痛点:一个组织、一个项目,甚至一个人,做事的底…

作者头像 李华
网站建设 2026/9/9 21:15:37

screenshot-to-code 在 Windows 上运行后端遇到 UTF-8 错误怎么解决?

screenshot-to-code 在 Windows 上运行后端遇到 UTF-8 错误怎么解决? 【免费下载链接】screenshot-to-code Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue) 项目地址: https://gitcode.com/GitHub_Trending/sc/screenshot-to-code…

作者头像 李华