trailofbits / dylint

Run Rust lints from dynamic libraries

Home Page:https://blog.trailofbits.com/2021/11/09/write-rust-lints-without-forking-clippy/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`cargo dylint new` fails to find temp file on Windows

mattvmsft opened this issue · comments

Overview

When running cargo dylint new or cargo dylint --new on Windows 11, it is failing to create a temporary directory during the execution of the command. The error message I am seeing is:

Error: Could not open `C:\Users\<username>\AppData\Local\Temp\.tmpKzVdW8\`                                                
Caused by:
    The system cannot find the path specified. (os error 3)

This is happening on my local machine and on a Windows 11 VM I spun up.

Operating System: Windows 11
Rust Versions Tried:
stable-x86_64-pc-windows-msvc
nightly-x86_64-pc-windows-msvc (11/22/2022)

@mattvmsft Thank you very much for the bug report.

I can reproduce this, but I haven't yet determined the cause.

I wil try to get to the bottom of this as soon as possible.

The issue seems to be that Template::iter() includes directories here when cargo-dylint is cargo installed, but not when it is say cargo run:

for path in Template::iter() {

I'm going to have to investigate further to see whether something changed in rust-embed. But in the meantime, if you install cargo-dylint with the following command, it should work for you:

cargo install cargo-dylint --git https://github.com/trailofbits/dylint --branch fix-495

I am very sorry for the difficulty.

cargo install performs an implicit cargo update, which explains why I could reproduce the problem that way, but not with cargo run.

This appears to be the cause: pyrossh/rust-embed#196

Thank you again for reporting this, @mattvmsft.

Thank you very much for the quick turnaround! When cargo installing the branch with the fix I am getting an E0599 compiler
error:

Compiling dylint_internal v2.0.14 (C:\Users\<username>\.cargo\git\checkouts\dylint-a1e613967c7439f2\e55bfc1\internal)
error[E0599]: no method named `is_dir` found for struct `rust_embed::Metadata` in the current scope
  --> internal\src\packaging.rs:20:35
   |
20 |         if embedded_file.metadata.is_dir() {
   |                                   ^^^^^^ method not found in `rust_embed::Metadata`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `dylint_internal` due to previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `dylint_internal` due to previous error
error: failed to compile `cargo-dylint v2.0.14 (https://github.com/trailofbits/dylint?branch=fix-495#e55bfc1b)`,

The same error also appears if I switch the branch to master.

I think it's because rust-embed 6.5.0 was yanked not long ago.

Could you please try cargo install --force cargo-dylint and then cargo dylint new ... again?

That worked for me, thanks again for your work here, it is appreciated!

Thanks again for reporting, and for retesting. 🙏