Book Searcher软件,不用介绍太多,知道的都知道,不知道的,基本上也不会使用这个软件。github上,这个软件的仓库都已经清空的,如果要下载源代码,只能从其他fork的仓库下载源码安装了。仓库地址大家可以github自行搜索。由于README中从源码安装的介绍非常简单,对于大部分用户来说,按照README完成编译还是有难度的。本文就从工具安装,源码编译及常见问题几个方面,介绍一下从源码安装的步骤。
安装前准备
Book Searcher采用pnpm,rust,tauri,因此在编译之前,需要先安装这些软件包:
安装pnpm
Book Searcher采用pnpm进行包管理,编译之前需要先安装pnpm,命令如下:
npm install -g pnpm
至于npm和pnpm的区别,大家可以自行搜索了解。
安装rustup
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
安装tauri
cargo install tauri-cli
从源码编译desktop版本
安装前端依赖
make frontend_preinstall
构建版本
cargo tauri build
准备索引文件
由于Book Searcher仓库已清空,可以从其他地方获取软件索引,如下地址可做参考:
https://onedrive.caomingjun.com/zh-CN/
创建索引
先执行rm -rf index命令,然后再创建索引;
book-searcher index -f *.csv
配置ipfs
常见编译问题解决
1、pnpm与版本不匹配:
错误描述:
zhangzhijun@zhangzhijun:/data/workspace/opensource/bs-core$ cargo tauri build
Running beforeBuildCommand cd ../frontend && pnpm run build
ERR_PNPM_OTHER_PM_EXPECTED This project is configured to use pnpm^8.5.0
Error beforeBuildCommand cd ../frontend && pnpm run build failed with exit code 1
解决方法:
通过 pnpm -v命令查询安装的pnpm版本,然后修改frontend目录下package.json中pnpm版本为系统中安装的版本号;
2、rustc版本过低:
错误描述:
zhangzhijun@zhangzhijun:/data/workspace/opensource/bs-core$ cargo install tauri-cli
Updating aliyun index
Installing tauri-cli v1.5.12
Updating aliyun index
error: failed to compile tauri-cli v1.5.12, intermediate artifacts can be found at /tmp/cargo-installDdUPUU
Caused by:
package clap_builder v4.5.2 cannot be built because it requires rustc 1.74 or newer, while the currently active rustc version is 1.70.0
Try re-running cargo install with --locked
解决方法:
1)通过rustup命令,更新和查询可用版本,例如:
zhangzhijun@zhangzhijun:/data/workspace/opensource/bs-core$ rustup update
info: syncing channel updates for 'stable-aarch64-unknown-linux-gnu'
info: syncing channel updates for '1.70-aarch64-unknown-linux-gnu'
info: checking for self-update
info: downloading self-update
stable-aarch64-unknown-linux-gnu unchanged - rustc 1.78.0 (9b00956e5 2024-04-29)
1.70-aarch64-unknown-linux-gnu unchanged - rustc 1.70.0 (90c541806 2023-05-31)
info: cleaning up downloads & tmp directories
2)通过rustup default命令指定版本
rustup default 【指定版本的名称】# 比如:stable-aarch64-unknown-linux-gnu unchanged
3、tauri-cli安装失败问题
执行命令cargo install tauri-cli安装tauri-cli时,出现如下错误:
zhangzhijun@debian:~/tools/bookSearcher$ cargo install tauri-cli
Updating crates.io index
Installing tauri-cli v2.5.0
Updating crates.io index
error: failed to compile `tauri-cli v2.5.0`, intermediate artifacts can be found at `/tmp/cargo-installdJSP7M`
Caused by:
failed to select a version for `env_logger`.
... required by package `tauri-cli v2.5.0`
versions that meet the requirements `^0.11` are: 0.11.8, 0.11.7, 0.11.6, 0.11.5, 0.11.4, 0.11.3, 0.11.2, 0.11.1, 0.11.0
the package `tauri-cli` depends on `env_logger`, with features: `anstream` but `env_logger` does not have these features.
It has an optional dependency with that name, but that dependency uses the "dep:" syntax in the features table, so it does not have an implicit feature with that name.
failed to select a version for `env_logger` which could resolve this conflict
解决方法:
1、修改rustup源为阿里云rustup镜像源
echo 'export RUSTUP_UPDATE_ROOT=https://mirrors.aliyun.com/rustup/rustup' >> ~/.bash_profile
echo 'export RUSTUP_DIST_SERVER=https://mirrors.aliyun.com/rustup' >> ~/.bash_profile
source ~/.bash_profile
修改后执行rustup update
2、配置crates.io源
[source.crates-io]
replace-with = 'aliyun'
[source.aliyun]
registry = "sparse+https://mirrors.aliyun.com/crates.io-index/"
3、重新执行命令安装