首页 > 解决方案 > 无法安装货物树:无法确定视觉工作室生成器

问题描述

我正在尝试在我的 Windows 机器上安装 cargo-tree。它使用 Windows 10、Visual Studio 构建工具 15。这是我的活动 rustup 工具链:

active toolchain
----------------

stable-x86_64-pc-windows-msvc (default)
rustc 1.26.0 (a77568041 2018-05-07)

运行cargo install cargo-tree时,构建失败。构建日志以以下结尾:

error: failed to run custom build command for `libssh2-sys v0.2.7`
process didn't exit successfully: `C:\Users\NICOLA~1\AppData\Local\Temp\cargo-installt7F5FM\release\build\libssh2-sys-726b9e90a2ed2b95\build-script-build` (exit code: 101)
--- stderr
fatal: not a git repository (or any of the parent directories): .git
thread 'main' panicked at '

couldn't determine visual studio generator
if VisualStudio is installed, however, consider running the appropriate vcvars script before building this crate
', C:\Users\nicolas-delsaux\.cargo\registry\src\github.com-1ecc6299db9ec823\cmake-0.1.31\src\lib.rs:552:25
note: Run with `RUST_BACKTRACE=1` for a backtrace.

warning: build failed, waiting for other jobs to finish...
error: failed to compile `cargo-tree v0.18.0`, intermediate artifacts can be found at `C:\Users\NICOLA~1\AppData\Local\Temp\cargo-installt7F5FM`

根据我在网上找到的一些文档,它似乎与要vcvars调用的某些脚本以及要安装的较旧的 Visual Studio 版本有关。我不完全明白该怎么做

标签: windowsrust

解决方案


根据@user25064,这需要通过开发人员命令提示符安装命令(更具体地说,您的架构的开发人员命令提示符 - 注意 x86/x64 架构)


推荐阅读