【问题标题】:Can't use Cargo to build hello world example from Rust tutorial不能使用 Cargo 从 Rust 教程中构建 hello world 示例
【发布时间】:2015-03-16 16:18:57
【问题描述】:

我在 http://doc.rust-lang.org/book/hello-cargo.html 的 Rust 页面上关注了 Rust 书籍/教程,并在执行 Cargo 部分时收到以下错误。命令是cargo build --verbose。由于构建过程失败,我使用了详细标志。看起来 Cargo 正在尝试构建一个名为“verbose”的文件。我确实使用了详细标志;这几乎就像发送给 rustc 的参数缺少 -- 前缀?

Process didn't exit successfully: `rustc -v verbose` (status=101)
--- stderr
error: couldn't read verbose: IoError { kind: FileNotFound, desc: "couldn\'t ope
n path as file", detail: Some("file not found (OS Error 2: The system cannot fin
d the file specified.\r\n); path=verbose; mode=open; access=read") }

Cargo.toml 文件包含以下文本:

[package] 

name = "hello_world" version = "0.0.1" 
authors = [ "Your name <you@example.com>" ] 

[[bin]] 

name = "hello_world"

我正在运行的计算机是 Windows 7 64 位,使用 2015 年 1 月 18 日两天前的 64 位夜间安装。

【问题讨论】:

  • 另外,您应该始终向我们提供导致此输出的确切命令。
  • 确保你运行的是cargo build --verbose而不是cargo build -- verbose

标签: rust rust-cargo


【解决方案1】:

我刚刚关注了您链接的tutorial,我没有看到任何关于使用详细标志的参考。我假设您查看了 Cargo 的帮助或以其他方式了解它。

但是,当我执行前两个步骤(“Hello, world!”和“Hello, Cargo!”)时,我能够运行cargo build --verbose

我认为您需要提供有关您的特定设置的更多信息。

【讨论】:

  • 见上文,我确实使用了 cargo build --verbose。我还尝试了货物构建-v。似乎当 rustc 被唤起时。 Cargo 使用参数“-v verbose”,这导致 rustc 尝试构建不存在的文件详细。如果我将文件“src/main.rs”重命名为“verbose”,构建完成,我得到一个名为“verbose.exe”的可执行文件。我很困惑为什么我没有得到一个名为“hello_world”的文件?
猜你喜欢
  • 2021-09-26
  • 2012-04-20
  • 1970-01-01
  • 1970-01-01
  • 2013-09-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-04-29
相关资源
最近更新 更多