Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug prevents from using dependency #11638

Closed
mouse07410 opened this issue Jan 27, 2023 · 5 comments · Fixed by #11665
Closed

Bug prevents from using dependency #11638

mouse07410 opened this issue Jan 27, 2023 · 5 comments · Fixed by #11665
Labels
C-bug Category: bug

Comments

@mouse07410
Copy link

Problem

$ cargo run --release
.  .  .
    Updating git repository `https://github.com/Manishearth/rust-clippy.git`
error: failed to download `aho-corasick v0.5.3`

Caused by:
  unable to get packages from source

Caused by:
  failed to unpack package `aho-corasick v0.5.3`

Caused by:
  failed to open `/Users/ur20980/.cargo/registry/src/github.com-1ecc6299db9ec823/aho-corasick-0.5.3/.cargo-ok`

Caused by:
  File exists (os error 17)

Steps

  1. Run cargo build on https://github.com/killercup/trpl-ebook.git

Possible Solution(s)

No idea. But it should either accept and use the already-installed package as-is, or re-download and re-build it a-fresh if needed. Just aborting here does not make any sense.

Notes

No response

Version

$ cargo version --verbose
cargo 1.67.0 (8ecd4f20a 2023-01-10)
release: 1.67.0
commit-hash: 8ecd4f20a9efb626975ac18a016d480dc7183d9b
commit-date: 2023-01-10
host: x86_64-apple-darwin
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 7.86.0 (sys:0.4.59+curl-7.86.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 13.2.0 [64-bit]
@mouse07410 mouse07410 added the C-bug Category: bug label Jan 27, 2023
@ehuss
Copy link
Contributor

ehuss commented Jan 28, 2023

Does this error happen repeatedly, or was it a one-time thing?
Can you check the filesize, permissions, and ownership of that file, such as posting the output of ls -al /Users/eric/.cargo/registry/src/github.com-1ecc6299db9ec823/aho-corasick-0.7.19/.cargo-ok?
I'm wondering how it would be possible for Cargo to get into this state.

@mouse07410
Copy link
Author

mouse07410 commented Jan 29, 2023

Does this error happen repeatedly, or was it a one-time thing?

Consistent, every time when building this package.

Can you check the filesize, permissions, and ownership of that file . . .

$ ll /Users/ur20980/.cargo/registry/src/github.com-1ecc6299db9ec823/aho-corasick-0.5.3/.cargo-ok
-rw-r--r--  1 ur20980  staff  2 Jul  6  2022  /Users/ur20980/.cargo/registry/src/github.com-1ecc6299db9ec823/aho-corasick-0.5.3/.cargo-ok
$

Owned by me, and with all the correct permissions.

I'm wondering how it would be possible for Cargo to get into this state.

I'm wondering what that even means, and what is Cargo supposed to do when it finds an existing .cargo-ok file in a $HOME/.cargo/registry/src/ tree.


BTW, what happens if you clone https://github.com/killercup/trpl-ebook.git and try to build or run it (just follow its Readme, it's short and simple enough)?

@ehuss
Copy link
Contributor

ehuss commented Jan 31, 2023

I don't have any issues with that project.

The .cargo-ok file is an indicator that Cargo has finished extracting the source for a package (to protect if it is interrupted in the middle of extraction). If the file exists, then it won't try to extract it again. For some reason, it doesn't seem to be able to detect that the file already exists. Can you perhaps run this little Rust program to see what the behavior is?

fn main() {
    let path = std::path::Path::new("/Users/ur20980/.cargo/registry/src/github.com-1ecc6299db9ec823/aho-corasick-0.5.3/.cargo-ok");
    match path.metadata() {
        Ok(meta) => println!("{}", meta.len()),
        Err(e) => println!("{e:?}"),
    }
}

You can just save that to a file foo.rs and run rustc foo.rs, and then ./foo to run it.

@mouse07410
Copy link
Author

I don't have any issues with that project.

Hmm... Weird... Does it run for you? Or only builds?

For me to get that project to the point where it builds, I had to nuke all the .cargo-ok files in ~/.cargo/registry/src/github.com-xxxxxxxxx/.

For your test-program - is this what you expected?

$ rustc foo.rs
$ ./foo
2
$ 

P.S. As I'm a Rust novice - perhaps you could advise what to replace .unwrap() with to get an informative message:

$ cargo run --release
warning: use of deprecated macro `RustcDecodable`: rustc-serialize is deprecated and no longer supported
  --> src/main.rs:34:17
   |
34 | #[derive(Debug, RustcDecodable)]
   |                 ^^^^^^^^^^^^^^
   |
   = note: `#[warn(deprecated)]` on by default
.  .  .
warning: use of deprecated macro `try`: use the `?` operator instead
  --> src/helpers/normalize.rs:45:14
   |
45 |     output = try!(normalize_links(&output));
   |              ^^^

warning: use of deprecated macro `try`: use the `?` operator instead
  --> src/helpers/normalize.rs:46:14
   |
46 |     output = try!(normalize_math(&output));
   |              ^^^
.  .  .
warning: `compile-trpl` (bin "compile-trpl") generated 58 warnings (run `cargo fix --bin "compile-trpl"` to apply 18 suggestions)
    Finished release [optimized] target(s) in 0.19s
     Running `target/release/compile-trpl`
Reading book..................................................................... done.
[✓] MD
[WARNING] Deprecated: --self-contained. use --embed-resources --standalone
pandoc: +smart: withBinaryFile: does not exist (No such file or directory)
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 32, kind: BrokenPipe, message: "Broken pipe" }', src/main.rs:50:68
stack backtrace:
   0: rust_begin_unwind
             at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:64:14
   2: core::result::unwrap_failed
             at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/result.rs:1791:5
   3: compile_trpl::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
$ 

Basically, the error is caught here convert_book::render_book(&prefix, &Path::new(&source), &meta).unwrap();:

  41fn main() {
  42let args: Args = Docopt::new(USAGE)
  43.and_then(|d| d.decode())
  44.unwrap_or_else(|e| e.exit());
  4546let prefix = args.flag_prefix.unwrap_or("trpl".to_owned());
  47let source = args.flag_source.unwrap_or("trpl".to_owned());
  48let meta = args.flag_meta.unwrap_or("trpl_meta.yml".to_owned());
  4950   │     convert_book::render_book(&prefix, &Path::new(&source), &meta).unwrap();
  5152let index = convert_book::index::render_index("dist/").unwrap();
  53   │     helpers::file::write_string_to_file(&index, "dist/index.html").unwrap();
  54println!("[✓] {}", "Index");

I'd love to get something more useful/informative than "file does not exist". At least, what file doesn't exist - would you know, by any chance, where/how to extract that info? Thanks!

@ehuss
Copy link
Contributor

ehuss commented Jan 31, 2023

I see a particular issue with the error handling for the .cargo-ok file, so I posted #11665 to address that.

As for getting better error messages, you'll need to add error handling. Unfortunately we can't provide support here. I suggest trying one of the user forums such as https://users.rust-lang.org/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants