我正在关注柴油指南:LINK
当我尝试这个时:
cargo install diesel_cli --no-default-features --features postgres
我收到此错误:
error: failed to compile `diesel_cli v1.4.1`, intermediate artifacts can be found at
还有一个注释:
= note: ld: library not found for -lpq
解决方案:
问题是货物无法找到pq库,所以我需要使用:
sudo apt install libpq-dev
这也给我发送了一个错误:
The operation couldn’t be completed. Unable to locate a Java Runtime that supports apt.
Please visit http://www.java.com for information on installing Java.
第一 我需要检查环境变量,检查你的文件:
% open -e .bash_profile
文件内容:
export JAVA_HOME=$(/usr/libexec/java_home)
但是错误仍然存在......所以这对我没有帮助。我想有时只需要这个,在我的例子中,我用brew来安装这些元素。
第二: 安装 postgreql
brew install postgresql
第三:安装libpq
brew install libpq
最后:安装柴油 CLI
cargo install diesel_cli --no-default-features --features postgres
安装完成后
brew install postgresql
brew install libpq
安装柴油机 CLI
arch -x86_64 cargo install diesel_cli --no-default-features --features postgres
我刚刚遇到这个问题,并没有发现周围的各种答案特别有帮助。对我来说,问题的症结在于,虽然很明显我需要安装
libpq
,但安装 PosgreSQL 也是强制性的,这并不明显。而且,brew install postgresql
不再起作用;您必须指定要安装的版本。此外,我还想要 Sqlite 支持,并且没有找到在没有 MySQL 支持的情况下同时安装 PG 和 Sqlite 支持的示例。
最终对我有用的是:
brew install libpq postgresql@15
brew link postgresql@15
cargo install diesel_cli --no-default-features --features postgres,sqlite