reujab / silver

A cross-shell customizable powerline-like prompt with icons
MIT License
453 stars 30 forks source link

thread 'main' panicked at 'index out of bounds' #9

Closed allanjamesvestal closed 5 years ago

allanjamesvestal commented 5 years ago

Hello,

I'm trying to install and use this prompt on a Mac with ZSH, but am running into issues when I try and run eval $(silver init).

I've installed rustup and then run rustup-init -y and then cargo install silver without issue.

At that point I set SILVER=(status:black:white dir:blue:black git:green:black cmdtime:magenta:black) and export SILVER_SHELL=zsh (both in my ~/.zshrc file).

Then, when I open a new terminal window and run eval $(silver init) I get the following:

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /rustc/cfdc84a009020c59e53e4039beae22eb59e41685/src/libcore/slice/mod.rs:2689:10
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

I set RUST_BACKTRACE=1 and tried again, with the following results:

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /rustc/cfdc84a009020c59e53e4039beae22eb59e41685/src/libcore/slice/mod.rs:2689:10
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: std::panicking::rust_panic_with_hook
   5: std::panicking::continue_panic_fmt
   6: rust_begin_unwind
   7: core::panicking::panic_fmt
   8: core::panicking::panic_bounds_check
   9: silver::modules::dir::segment
  10: silver::print::prompt
  11: silver::main
  12: std::rt::lang_start::{{closure}}
  13: std::panicking::try::do_call
  14: __rust_maybe_catch_panic
  15: std::rt::lang_start_internal
  16: main

Please let me know what you'd recommend. Thanks in advance for the help.

reujab commented 5 years ago

I am unable to reproduce and the stack trace doesn't provide enough information to pinpoint the issue. Can you try again using cargo install --debug --force and paste that stack trace?

reujab commented 5 years ago

Nevermind, I was able to reproduce, and this has been fixed in v1.0.7. Thanks for reporting this.

allanjamesvestal commented 5 years ago

That's great. Thank you for looking into this, and for the project — I'm looking forward to using it for awhile to come now that I've switched from oh-my-zsh to Antibody.

I'd meant to add the detail that I could get around the panic by setting SILVER_DIR_ALIASES with any non-null value and it'd work, but it looks like that's exactly what you found and fixed.

Thanks again for the quick reply & resolution.