尝试安装柴油机时出现问题 (Mac Air m1)

jos*_*jan 3 rust rust-cargo rust-diesel

我正在关注柴油指南:LINK

当我尝试这个时:

cargo install diesel_cli --no-default-features --features postgres
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

error: failed to compile `diesel_cli v1.4.1`, intermediate artifacts can be found at
Run Code Online (Sandbox Code Playgroud)

和一个注释:

 = note: ld: library not found for -lpq
Run Code Online (Sandbox Code Playgroud)

jos*_*jan 6

解决方案:

\n

问题是货物无法找到 pq 库,所以我需要使用:

\n
 sudo apt install libpq-dev\n
Run Code Online (Sandbox Code Playgroud)\n

这也给我发送了一个错误:

\n
The operation couldn\xe2\x80\x99t be completed. Unable to locate a Java Runtime that supports apt.\nPlease visit http://www.java.com for information on installing Java.\n
Run Code Online (Sandbox Code Playgroud)\n

首先\n我需要检查环境变量,检查你的文件:

\n
% open -e .bash_profile\n
Run Code Online (Sandbox Code Playgroud)\n

文件内容:

\n
export JAVA_HOME=$(/usr/libexec/java_home)\n
Run Code Online (Sandbox Code Playgroud)\n

但错误仍然存​​在......所以这对我没有帮助。我想有时只需要这个,在我的例子中,我用brew来安装这些元素。

\n

第二:\n安装 postgreql

\n
brew install postgresql\n
Run Code Online (Sandbox Code Playgroud)\n

第三:安装libpq

\n
brew install libpq  \n
Run Code Online (Sandbox Code Playgroud)\n

最后:安装diesel CLI

\n
cargo install diesel_cli --no-default-features --features postgres\n
Run Code Online (Sandbox Code Playgroud)\n