Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notion install yarn fails to save the platform.toml file #219

Closed
mikrostew opened this issue Dec 14, 2018 · 1 comment
Closed

notion install yarn fails to save the platform.toml file #219

mikrostew opened this issue Dec 14, 2018 · 1 comment
Labels

Comments

@mikrostew
Copy link
Contributor

Repro

When I run notion install yarn <version> (on current master) it's panicking and clearing the platform.toml file:

$ notion install node 11

$ cat ~/.notion/tools/user/platform.toml
[node]
runtime = '11.4.0'
npm = '6.4.1'

$ notion install yarn 1.9.2
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ValueAfterTable', libcore/result.rs:1009:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

$ cat ~/.notion/tools/user/platform.toml

Investigation

Looks like it's failing on Toolchain::save

$ NOTION_DEV=1 RUST_BACKTRACE=1 notion install yarn 1.9.2
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: ValueAfterTable', libcore/result.rs:1009:5
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::result::unwrap_failed
   9: notion_core::toolchain::Toolchain::save
  10: notion_core::toolchain::Toolchain::set_active_yarn
  11: notion_core::session::Session::install_yarn
  12: <notion::command::install::Install as notion::command::Command>::run
  13: notion::command::Command::go
  14: notion::main
  15: std::rt::lang_start::{{closure}}
  16: std::panicking::try::do_call
  17: __rust_maybe_catch_panic
  18: std::rt::lang_start_internal
  19: main

The only line in save() that calls .unwrap() is this one (line 84 in notion-core/src/toolchain/mod.rs):

let src = toml::to_string_pretty(&platform.to_serial()).unwrap();

So that looks like an issue with platform.to_serial()

@mikrostew mikrostew added the bug label Dec 14, 2018
@mikrostew
Copy link
Contributor Author

Turns out that TOML is very picky. From https://docs.rs/toml/0.4.10/toml/ser/index.html:

Note that the TOML format has a restriction that if a table itself contains tables, all keys with non-table values must be emitted first. This is typically easy to ensure happens when you're defining a struct as you can reorder the fields manually,...

So that's all I had to do is re-order the fields so that yarn comes first, because it is a non-table value (a String)

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

No branches or pull requests

1 participant