holmgr / cargo-sweep

A cargo subcommand for cleaning up unused build files generated by Cargo
MIT License
693 stars 31 forks source link

`-s` is expecting `-t` and panicks on my system #41

Closed djdv closed 3 years ago

djdv commented 3 years ago

cargo-sweep f7e4cfa77a453425e1a8775ef2577d57a635f4cc rustc 1.47.0-nightly (bf4342114 2020-08-25) cargo 1.47.0-nightly (51b66125b 2020-08-19) Windows 10 (19042.450)

Inside the cargo-sweep source directory (or any Rust project) I'm invoking cargo sweep -s and it panicks expecting -t to be provided, but those arguments are incompatible. -t alone seems to work fine, but I can't test -f since the timestamp file can't be created with -s.

This is my first time trying sweep so I'm not sure if this worked in any previous version. I'm also only a Rust user, I can't actually read or write it yet to figure out why it's going down the branch that tries to match against --time. I included the trace but it doesn't look super helpful. Seems to only apply to the stdlib unless I missed something.

If I can help debug this somehow, let me know and I can try whatever to get more info.

cargo sweep -s
thread 'main' panicked at '--time argument missing', src\main.rs:208:18
stack backtrace:
   0:     0x7ff699c0f6e9 - std::backtrace_rs::backtrace::dbghelp::trace
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\..\..\backtrace\src\backtrace\dbghelp.rs:98
   1:     0x7ff699c0f6e9 - std::backtrace_rs::backtrace::trace_unsynchronized
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
   2:     0x7ff699c0f6e9 - std::sys_common::backtrace::_print_fmt
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\sys_common\backtrace.rs:79
   3:     0x7ff699c0f6e9 - std::sys_common::backtrace::_print::{{impl}}::fmt
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\sys_common\backtrace.rs:58
   4:     0x7ff699c2c2ab - core::fmt::write
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\core\src\fmt\mod.rs:1082
   5:     0x7ff699c0a9b4 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\io\mod.rs:1514
   6:     0x7ff699c125fb - std::sys_common::backtrace::_print
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\sys_common\backtrace.rs:61
   7:     0x7ff699c125fb - std::sys_common::backtrace::print
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\sys_common\backtrace.rs:48
   8:     0x7ff699c125fb - std::panicking::default_hook::{{closure}}
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\panicking.rs:200
   9:     0x7ff699c12239 - std::panicking::default_hook
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\panicking.rs:219
  10:     0x7ff699c12ddf - std::panicking::rust_panic_with_hook
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\panicking.rs:569
  11:     0x7ff699c12945 - std::panicking::begin_panic_handler::{{closure}}
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\panicking.rs:476
  12:     0x7ff699c0ff9f - std::sys_common::backtrace::__rust_end_short_backtrace<closure-0,!>
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\sys_common\backtrace.rs:153
  13:     0x7ff699c128f9 - std::panicking::begin_panic_handler
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\panicking.rs:475
  14:     0x7ff699c2aa60 - core::panicking::panic_fmt
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\core\src\panicking.rs:85
  15:     0x7ff699c2a7f2 - core::option::expect_failed
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\core\src\option.rs:1213
  16:     0x7ff699b4545e - <alloc::string::String as core::fmt::Display>::fmt::hcd19413c2a09a7f1
  17:     0x7ff699b2d296 - <T as core::any::Any>::type_id::h05d4d92862220c80
  18:     0x7ff699b2d64c - std::rt::lang_start::{{closure}}::h55d0604f7eb97191
  19:     0x7ff699c12fe6 - core::ops::function::impls::{{impl}}::call_once
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\library\core\src\ops\function.rs:280
  20:     0x7ff699c12fe6 - std::panicking::try::do_call
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\panicking.rs:373
  21:     0x7ff699c12fe6 - std::panicking::try
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\panicking.rs:337
  22:     0x7ff699c12fe6 - std::panic::catch_unwind
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\panic.rs:379
  23:     0x7ff699c12fe6 - std::rt::lang_start_internal
                               at /rustc/bf4342114e357f2934d59e12e31e94532ddb2adf\/library\std\src\rt.rs:51
  24:     0x7ff699b46727 - main
  25:     0x7ff699c33344 - invoke_main
                               at D:\agent\_work\9\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  26:     0x7ff699c33344 - __scrt_common_main_seh
                               at D:\agent\_work\9\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  27:     0x7fff32b36fd4 - BaseThreadInitThunk
  28:     0x7fff3411cec1 - RtlUserThreadStart

For extra context, I'm trying to integrate this into an update script that updates Rust itself, then goes into each Rust project directory, pulls changes, then tries to rebuild it, using sweep to clean up and make timestamps before and after the build.

up.ps1:

& rustup update

Get-ChildItem -Directory | % {
    Write-Host Target: $_
    Push-Location $_
    & git pull
    & cargo sweep -f
    & cargo install --path="."
    & cargo sweep -s
    Pop-Location
}
Eh2406 commented 3 years ago

I am sorry it is not working for you. Looks like it was broken by #38/#39. I think moving lines main.rs@214-221 to before main.rs@202 can fix it. (we need better testing) If you would like to make PR that would be grate!

djdv commented 3 years ago

@Eh2406 Thanks for the quick response! Making the suggested change has the hook working on my machine. I submitted a PR #42 that makes the basic fix, but I'm not experienced enough with this to write any tests for it. 👀