Zola: Panicked at 'called `Option::unwrap()` on a `None` value'

Created on 22 Feb 2019  ยท  5Comments  ยท  Source: getzola/zola

Bug Report

Environment

OS version: Linux 4.18.0-15-generic #16-Ubuntu SMP Thu Feb 7 10:56:39 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Zola version: 0.5.1

Expected Behavior

Shouldn't have crashed.

Current Behavior

Change detected @ 2019-02-22 11:22:11
-> Content changed /home/florianb/crafting/mks-web/content/_index.md
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:355:21
note: Run with `RUST_BACKTRACE=1` for a backtrace.

Stacktrace:

Change detected @ 2019-02-22 12:08:49
-> Content changed /home/florianb/crafting/mks-web/content/_index.md
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:355:21
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:211
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:227
   4: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:491
   5: std::panicking::continue_panic_fmt
             at src/libstd/panicking.rs:398
   6: rust_begin_unwind
             at src/libstd/panicking.rs:325
   7: core::panicking::panic_fmt
             at src/libcore/panicking.rs:95
   8: core::panicking::panic
             at src/libcore/panicking.rs:59
   9: library::library::Library::populate_sections
  10: rebuild::after_content_change
  11: zola::cmd::serve::serve
  12: zola::main
  13: std::rt::lang_start::{{closure}}
  14: std::panicking::try::do_call
             at src/libstd/rt.rs:59
             at src/libstd/panicking.rs:310
  15: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:102
  16: std::rt::lang_start_internal
             at src/libstd/panicking.rs:289
             at src/libstd/panic.rs:398
             at src/libstd/rt.rs:58
  17: main
  18: __libc_start_main
  19: _start

Step to reproduce

Started playing around with zola having the following file-tree:

../.
โ”œโ”€โ”€ config.toml
โ”œโ”€โ”€ content
โ”‚ย ย  โ”œโ”€โ”€ _cars
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ _index.md
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ _mercedes.md
โ”‚ย ย  โ””โ”€โ”€ _index.md
โ”œโ”€โ”€ public
โ”‚ย ย  โ””โ”€โ”€ _cars
โ”‚ย ย      โ”œโ”€โ”€ index.html
โ”‚ย ย      โ””โ”€โ”€ mercedes
โ”‚ย ย          โ””โ”€โ”€ index.html
โ”œโ”€โ”€ sass
โ”œโ”€โ”€ static
โ”œโ”€โ”€ templates
โ”‚ย ย  โ””โ”€โ”€ index.html
โ””โ”€โ”€ themes

The error ocured after deleting content/_index.md. Before that delete i renamed content/cars/ to content/_cars.

Content of content/_index.md

+++
+++
bug done

All 5 comments

It might have been fixed in the next branch, I'll try to reproduce that later

Thank you very much! I'd try to help but i guess i'm too new to Rust to actually be a help.

I've seen this might be related to #559 - feel free to close my issue in favor of the former issue. :coffee: :cake:

Your reproduction worked perfectly, thanks!

:+1:

I think I've reproduced this bug with Zola 0.11.0, on the master and next branches in archlinux. I can also file this as a new issue if that's ideal but this seems like a related bug.

To reproduce:

I do the following:

  • zola init test-site
  • cd test-site
  • in a new terminal zola serve
  • mkdir -p content/posts
  • echo '+++'> content/posts/_index.md && echo '+++' >> content/posts/_index.md
  • rm content/posts/_index.md

The zola serve command crashes for me.

The stack trace from the pacman install doesn't have symbols so I compiled master and here's the stack trace:

~/projects/test-site$ RUST_BACKTRACE=1 ../zola/target/debug/zola serve                                                                  
Building site...                                                                                                                                       
-> Creating 0 pages (0 orphan), 1 sections, and processing 0 images                                                                                    
Done in 112ms.                                                                                                                                         

Listening for changes in /home/simlay/projects/test-site{config.toml, content, sass, static, templates}                                                
Press Ctrl+C to stop                                                                                                                                   

Web server is available at http://127.0.0.1:1111                                                                                                       

Change detected @ 2020-08-11 12:08:44                                                                                                                  
-> Content changed /home/simlay/projects/test-site/content/posts/_index.md                                                                             
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', components/library/src/library.rs:366:9                                       
stack backtrace:                                                                                                                                       
   0: backtrace::backtrace::libunwind::trace                                                                                                           
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86                                         
   1: backtrace::backtrace::trace_unsynchronized                                                                                                       
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66                                               
   2: std::sys_common::backtrace::_print_fmt                                                                                                           
             at src/libstd/sys_common/backtrace.rs:78                                                                                                  
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt                                                                
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1076
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1537
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:486
  11: rust_begin_unwind
             at src/libstd/panicking.rs:388
  12: core::panicking::panic_fmt
             at src/libcore/panicking.rs:101
  13: core::panicking::panic
             at src/libcore/panicking.rs:56
  14: core::option::Option<T>::unwrap
             at /home/simlay/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/macros/mod.rs:10
  15: library::library::Library::get_section_by_key
             at components/library/src/library.rs:366
  16: library::library::Library::get_section_path_by_key
             at components/library/src/library.rs:374
  17: library::content::ser::SerializingSection::from_section
             at components/library/src/content/ser.rs:242
  18: library::content::section::Section::to_serialized
             at components/library/src/content/section.rs:251
  19: library::content::section::Section::render_html
             at components/library/src/content/section.rs:223
  20: site::Site::render_section
             at components/site/src/lib.rs:849
  21: site::Site::render_sections::{{closure}}
             at components/site/src/lib.rs:877
  22: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &F>::call_mut
             at /home/simlay/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/ops/function.rs:252
  23: core::iter::adapters::map_try_fold::{{closure}}
             at /home/simlay/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/iter/adapters/mod.rs:837
  24: core::iter::traits::iterator::Iterator::try_fold
             at /home/simlay/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/iter/traits/iterator.rs:1889
  25: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
             at /home/simlay/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/iter/adapters/mod.rs:863
  26: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::try_fold
             at /home/simlay/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/iter/adapters/mod.rs:863
  27: <core::iter::adapters::TakeWhile<I,P> as core::iter::traits::iterator::Iterator>::try_fold
             at /home/simlay/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/iter/adapters/mod.rs:1875
  28: <core::iter::adapters::TakeWhile<I,P> as core::iter::traits::iterator::Iterator>::fold
             at /home/simlay/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/iter/adapters/mod.rs:1890
  29: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
             at /home/simlay/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/iter/adapters/mod.rs:870
  30: core::iter::traits::iterator::Iterator::for_each
             at /home/simlay/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore/iter/traits/iterator.rs:658
  31: <rayon::iter::noop::NoopConsumer as rayon::iter::plumbing::Folder<T>>::consume_iter
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/noop.rs:34
  32: <rayon::iter::while_some::WhileSomeFolder<C> as rayon::iter::plumbing::Folder<core::option::Option<T>>>::consume_iter
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/while_some.rs:139
  33: <rayon::iter::map::MapFolder<C,F> as rayon::iter::plumbing::Folder<T>>::consume_iter
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/map.rs:248
  34: <rayon::iter::map::MapFolder<C,F> as rayon::iter::plumbing::Folder<T>>::consume_iter
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/map.rs:248
  35: rayon::iter::plumbing::Producer::fold_with
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/plumbing/mod.rs:110
  36: rayon::iter::plumbing::bridge_producer_consumer::helper
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/plumbing/mod.rs:438
  37: rayon::iter::plumbing::bridge_producer_consumer
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/plumbing/mod.rs:397
  38: <rayon::iter::plumbing::bridge::Callback<C> as rayon::iter::plumbing::ProducerCallback<I>>::callback
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/plumbing/mod.rs:373
  39: <rayon::vec::IntoIter<T> as rayon::iter::IndexedParallelIterator>::with_producer
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/vec.rs:68
  40: rayon::iter::plumbing::bridge
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/plumbing/mod.rs:357
  41: <rayon::vec::IntoIter<T> as rayon::iter::ParallelIterator>::drive_unindexed
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/vec.rs:33
  42: <rayon::iter::map::Map<I,F> as rayon::iter::ParallelIterator>::drive_unindexed
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/map.rs:49
  43: <rayon::iter::map::Map<I,F> as rayon::iter::ParallelIterator>::drive_unindexed
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/map.rs:49
  44: <rayon::iter::while_some::WhileSome<I> as rayon::iter::ParallelIterator>::drive_unindexed
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/while_some.rs:44
  45: rayon::iter::from_par_iter::<impl rayon::iter::FromParallelIterator<()> for ()>::from_par_iter
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/from_par_iter.rs:226
  46: rayon::iter::ParallelIterator::collect
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/mod.rs:1887
  47: rayon::result::<impl rayon::iter::FromParallelIterator<core::result::Result<T,E>> for core::result::Result<C,E>>::from_par_iter
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/result.rs:121
  48: rayon::iter::ParallelIterator::collect
             at /home/simlay/.cargo/registry/src/github.com-1ecc6299db9ec823/rayon-1.3.1/src/iter/mod.rs:1887
  49: site::Site::render_sections
             at components/site/src/lib.rs:872
  50: site::Site::build
             at components/site/src/lib.rs:497
  51: rebuild::delete_element
             at components/rebuild/src/lib.rs:123
  52: rebuild::after_content_change
             at components/rebuild/src/lib.rs:365
  53: zola::cmd::serve::serve
             at src/cmd/serve.rs:519
  54: zola::main
             at src/main.rs:83
  55: std::rt::lang_start::{{closure}}
             at /home/simlay/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:67
  56: std::rt::lang_start_internal::{{closure}}
             at src/libstd/rt.rs:52
  57: std::panicking::try::do_call
             at src/libstd/panicking.rs:297
  58: std::panicking::try
             at src/libstd/panicking.rs:274
  59: std::panic::catch_unwind
             at src/libstd/panic.rs:394
  60: std::rt::lang_start_internal
             at src/libstd/rt.rs:51
  61: std::rt::lang_start
             at /home/simlay/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd/rt.rs:67
  62: main
  63: __libc_start_main
  64: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

That's one of the many serve bugs. There's a branch https://github.com/getzola/zola/pull/1114 to completely change the way it's done which should fix all those issues and more.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pandark picture pandark  ยท  3Comments

NuLL3rr0r picture NuLL3rr0r  ยท  6Comments

porglezomp picture porglezomp  ยท  7Comments

phil-opp picture phil-opp  ยท  3Comments

snsvrno picture snsvrno  ยท  4Comments