Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Error while building TRPL second edition: #51

Open
palnabarun opened this issue Jan 20, 2018 · 5 comments
Open

Error while building TRPL second edition: #51

palnabarun opened this issue Jan 20, 2018 · 5 comments

Comments

@palnabarun
Copy link
Contributor

I am trying to build the second edition of the book. I have copied over the source files from trpl/second-edition/src in the TRPL source code repository on Github.

nabarun@pal:~/codesl/trpl-ebook (git:master) $ ls trpl
appendix-00.md                              ch08-01-vectors.md                                  ch15-01-box.md
appendix-01-keywords.md                     ch08-02-strings.md                                  ch15-02-deref.md
appendix-02-operators.md                    ch08-03-hash-maps.md                                ch15-03-drop.md
appendix-03-derivable-traits.md             ch09-00-error-handling.md                           ch15-04-rc.md
appendix-04-macros.md                       ch09-01-unrecoverable-errors-with-panic.md          ch15-05-interior-mutability.md
appendix-05-translation.md                  ch09-02-recoverable-errors-with-result.md           ch15-06-reference-cycles.md
appendix-06-newest-features.md              ch09-03-to-panic-or-not-to-panic.md                 ch16-00-concurrency.md
ch01-00-introduction.md                     ch10-00-generics.md                                 ch16-01-threads.md
ch01-01-installation.md                     ch10-01-syntax.md                                   ch16-02-message-passing.md
ch01-02-hello-world.md                      ch10-02-traits.md                                   ch16-03-shared-state.md
ch02-00-guessing-game-tutorial.md           ch10-03-lifetime-syntax.md                          ch16-04-extensible-concurrency-sync-and-send.md
ch03-00-common-programming-concepts.md      ch11-00-testing.md                                  ch17-00-oop.md
ch03-01-variables-and-mutability.md         ch11-01-writing-tests.md                            ch17-01-what-is-oo.md
ch03-02-data-types.md                       ch11-02-running-tests.md                            ch17-02-trait-objects.md
ch03-03-how-functions-work.md               ch11-03-test-organization.md                        ch17-03-oo-design-patterns.md
ch03-04-comments.md                         ch12-00-an-io-project.md                            ch18-00-patterns.md
ch03-05-control-flow.md                     ch12-01-accepting-command-line-arguments.md         ch18-01-all-the-places-for-patterns.md
ch04-00-understanding-ownership.md          ch12-02-reading-a-file.md                           ch18-02-refutability.md
ch04-01-what-is-ownership.md                ch12-03-improving-error-handling-and-modularity.md  ch18-03-pattern-syntax.md
ch04-02-references-and-borrowing.md         ch12-04-testing-the-librarys-functionality.md       ch19-00-advanced-features.md
ch04-03-slices.md                           ch12-05-working-with-environment-variables.md       ch19-01-unsafe-rust.md
ch05-00-structs.md                          ch12-06-writing-to-stderr-instead-of-stdout.md      ch19-02-advanced-lifetimes.md
ch05-01-defining-structs.md                 ch13-00-functional-features.md                      ch19-03-advanced-traits.md
ch05-02-example-structs.md                  ch13-01-closures.md                                 ch19-04-advanced-types.md
ch05-03-method-syntax.md                    ch13-02-iterators.md                                ch19-05-advanced-functions-and-closures.md
ch06-00-enums.md                            ch13-03-improving-our-io-project.md                 ch20-00-final-project-a-web-server.md
ch06-01-defining-an-enum.md                 ch13-04-performance.md                              ch20-01-single-threaded.md
ch06-02-match.md                            ch14-00-more-about-cargo.md                         ch20-02-slow-requests.md
ch06-03-if-let.md                           ch14-01-release-profiles.md                         ch20-03-designing-the-interface.md
ch07-00-modules.md                          ch14-02-publishing-to-crates-io.md                  ch20-04-storing-threads.md
ch07-01-mod-and-the-filesystem.md           ch14-03-cargo-workspaces.md                         ch20-05-sending-requests-via-channels.md
ch07-02-controlling-visibility-with-pub.md  ch14-04-installing-binaries.md                      ch20-06-graceful-shutdown-and-cleanup.md
ch07-03-importing-names-with-use.md         ch14-05-extending-cargo.md                          img
ch08-00-common-collections.md               ch15-00-smart-pointers.md                           SUMMARY.md

However, when I try to build the book, I encounter the following error:

nabarun@pal:~/codesl/trpl-ebook (git:crate-update) $ cargo run --release                                                                                                 
    Finished release [optimized] target(s) in 0.0 secs
     Running `target/release/compile-trpl`
Reading book.thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 2, message: "No such file or directory" } }', libcore/resul
t.rs:916:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

I also tried with:

nabarun@pal:~/codesl/trpl-ebook (git:crate-update) $ ./target/release/compile-trpl --source=/home/nabarun/codesl/trpl-ebook/trpl
Reading book.thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 2, message: "No such file or directory" } }', libcore/resul
t.rs:916:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

and I get the same error.

Did anybody else try to do the same?

@killercup
Copy link
Owner

killercup commented Jan 20, 2018 via email

@palnabarun
Copy link
Contributor Author

@killercup Here is the stacktrace

nabarun@pal:~/codesl/trpl-ebook (git:master) $ env RUST_BACKTRACE=1 cargo run --release
    Finished release [optimized] target(s) in 0.0 secs
     Running `target/release/compile-trpl`
Reading book.thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 2, message: "No such file or directory" } }', libcore/result.rs:916:5
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:68
             at libstd/sys_common/backtrace.rs:57
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:381
   3: std::panicking::default_hook
             at libstd/panicking.rs:397
   4: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:577
   5: std::panicking::begin_panic
             at libstd/panicking.rs:538
   6: std::panicking::begin_panic_fmt
             at libstd/panicking.rs:522
   7: rust_begin_unwind
             at libstd/panicking.rs:498
   8: core::panicking::panic_fmt
             at libcore/panicking.rs:71
   9: core::result::unwrap_failed
  10: compile_trpl::main
  11: std::rt::lang_start::{{closure}}
  12: std::panicking::try::do_call
             at libstd/rt.rs:59
             at libstd/panicking.rs:480
  13: __rust_maybe_catch_panic
             at libpanic_unwind/lib.rs:102
  14: std::rt::lang_start_internal
             at libstd/panicking.rs:459
             at libstd/panic.rs:365
             at libstd/rt.rs:58
  15: main
  16: __libc_start_main
  17: _start

@killercup
Copy link
Owner

Okay, damn, that's really unhelpful stack trace! The only thing of note here is 10: compile_trpl::main – the rest is just the panicking machinery. Sadly, this is also code I've written 2.5 years ago and has thus not really anything like the current state of the art error reporting (that you get e.g. with error-chain or the failure crate).

Since it says "No such file or directory", I'd just go looking for File stuff and add some logging. E.g., this helper here:

pub fn get_file_content<P: AsRef<Path>>(path: P) -> Result<String, Box<Error>> {
let mut file = try!(File::open(path));
let mut buffer = String::new();
try!(file.read_to_string(&mut buffer));
Ok(buffer)
}

Could be changed to report some more info, something like this.

@abcdev
Copy link

abcdev commented Jun 2, 2018

Fixed by #52

@palnabarun
Copy link
Contributor Author

That is awesome.

Thank you. @abcdev

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants