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

Nix language parser failing #2909

Closed
heliostatic opened this issue Jun 29, 2022 · 6 comments
Closed

Nix language parser failing #2909

heliostatic opened this issue Jun 29, 2022 · 6 comments
Labels
C-bug Category: This is a bug

Comments

@heliostatic
Copy link
Contributor

Summary

I'm trying open a nix file, but helix is crashing. I attempted to fix by running:
hx --grammar fetch && hx --grammar build with no luck

Reproduction Steps

I tried this:

  1. hx shell.nix

I expected this to happen:
helix to open the shell.nix file

Instead, this happened:

> RUST_BACKTRACE=full hx shell.nix                                               
thread 'main' panicked at 'Could not parse queries for language "nix". Are your grammars out of sync? Try running 'hx --grammar fetch' and 'hx --grammar build'. This query could not be parsed: QueryError { row: 24, column: 3, offset: 1441, message: "string_expression", kind: NodeType }', helix-core/src/syntax.rs:379:43
stack backtrace:
   0:        0x11022d5b7 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc80096156cd24709
   1:        0x10fabe97b - core::fmt::write::hb6b947db0e571766
   2:        0x1102277bc - std::io::Write::write_fmt::h59c4febf5f8fcb1e
   3:        0x1102328c0 - std::panicking::default_hook::{{closure}}::h0e76f92bbb367061
   4:        0x1102325f4 - std::panicking::default_hook::hbbbb8c05ad6cce9a
   5:        0x110232e98 - std::panicking::rust_panic_with_hook::ha581a2c99399f83b
   6:        0x110232db4 - std::panicking::begin_panic_handler::{{closure}}::h97df6e4273b6a879
   7:        0x110230b97 - std::sys_common::backtrace::__rust_end_short_backtrace::ha4a3b48ae6bfb343
   8:        0x110232ad0 - _rust_begin_unwind
   9:        0x1102d0903 - core::panicking::panic_fmt::h4a5343602e6cbb54
  10:        0x10fb8978b - helix_core::syntax::LanguageConfiguration::initialize_highlight::hd2a306329e984e19
  11:        0x10fb7e5c4 - once_cell::imp::OnceCell<T>::initialize::{{closure}}::h0fd69cd05fc31710
  12:        0x110134fa3 - once_cell::imp::initialize_or_wait::h45dfc1883ac8e07f
  13:        0x1102d54ef - once_cell::imp::OnceCell<T>::initialize::h561f259ce977bf75
  14:        0x110027a61 - helix_view::document::Document::set_language::h52f4e94d51eb4a71
  15:        0x110026eed - helix_view::document::Document::open::h8ae493059f4f3e09
  16:        0x110007bf0 - helix_view::editor::Editor::open::hf4dca83b3979d790
  17:        0x10fde9313 - helix_term::application::Application::new::h7d51d82109968867
  18:        0x1100ac4cd - <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h9f50490d3b066f3e
  19:        0x11009ec6d - std::thread::local::LocalKey<T>::with::ha054178b750a394d
  20:        0x11007ed24 - tokio::park::thread::CachedParkThread::block_on::h1802dede9b1644c2
  21:        0x1100da252 - tokio::runtime::thread_pool::ThreadPool::block_on::h8888d2bc2e474639
  22:        0x1100a80bf - tokio::runtime::Runtime::block_on::h5585ffffa5373208
  23:        0x1100820be - hx::main::h29ab56576325879e
  24:        0x110077a96 - std::sys_common::backtrace::__rust_begin_short_backtrace::h0ca90071af26510f
  25:        0x11009e751 - std::rt::lang_start::{{closure}}::h0c77e0ba6c78b120
  26:        0x110221495 - std::rt::lang_start_internal::hdb19fe6764e59ca8
  27:        0x1100821d9 - _main

Helix log

~/.cache/helix/helix.log 2022-06-28T09:27:49.396 helix_lsp::transport [ERROR] err <- "[ERROR project_model::workspace] cyclic deps: helix_view(CrateId(63)) -> helix_tui(CrateId(57)), alternative path: helix_tui(CrateId(57)) -> helix_view(CrateId(63))\n" 2022-06-28T09:28:18.292 helix_lsp::transport [ERROR] err <- "[ERROR project_model::workspace] cyclic deps: helix_view(CrateId(63)) -> helix_tui(CrateId(57)), alternative path: helix_tui(CrateId(57)) -> helix_view(CrateId(63))\n" 2022-06-28T21:13:35.455 helix_lsp::transport [ERROR] err <- "[ERROR project_model::workspace] cyclic deps: helix_view(CrateId(63)) -> helix_tui(CrateId(57)), alternative path: helix_tui(CrateId(57)) -> helix_view(CrateId(63))\n" 2022-06-28T21:13:46.173 helix_lsp::transport [ERROR] err <- "[ERROR project_model::workspace] cyclic deps: helix_view(CrateId(63)) -> helix_tui(CrateId(57)), alternative path: helix_tui(CrateId(57)) -> helix_view(CrateId(63))\n"

Platform

macOS

Terminal Emulator

alacritty

Helix Version

22.05-158-g07e7a13a

@heliostatic heliostatic added the C-bug Category: This is a bug label Jun 29, 2022
@the-mikedavis
Copy link
Member

the-mikedavis commented Jun 29, 2022

I can't reproduce this on master or any recent commit.

The error message points to the

(string_expression)
node added in the update from #2472. That would suggest you're trying to run a helix tree-sitter-nix parser version older than #2472 against current queries. What does hx --version say? And which -a hx?

@heliostatic
Copy link
Contributor Author

Just rebuilt from master:
which -a hx --> /usr/local/bin/hx
/usr/local/bin/hx --version --> helix 22.05 (030de46e)

@the-mikedavis
Copy link
Member

Somewhere on your system there's an out-of-date nix.so compiled parser. Where helix is picking it up depends on $HELIX_RUNTIME (note that the nix develop / nix-shell shell sets its own HELIX_RUNTIME). Try finding any nix.so files and removing them and then re-running
hx -g build

@heliostatic
Copy link
Contributor Author

heliostatic commented Jun 29, 2022

Hmm, I've deleted the runtime/grammars/* and re-fetched and built, with the same results. Can't find another instance of nix.so anywhere.

I went ahead and grabbed the sha1sum of my nix.so:
210bcb75dc028de59899f0e3b977014468a684ed runtime/grammars/nix.so

@the-mikedavis
Copy link
Member

#3713 had another angle on this: do you have a ~/.config/helix/languages.toml and if so, does it contain any [[grammar]] entries? Those would pin the tree-sitter grammars to revisions that won't follow the queries in master, so you might have up-to-date queries but an out-of-date-parser.

I'm getting different sha1sums for my .so files between build/cleans, I think the compilation is non-deterministic so I can't compare

@gabydd
Copy link
Member

gabydd commented Jul 14, 2023

just looking through some nix language support issues and I think this can be reasonably closed

@gabydd gabydd closed this as completed Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

3 participants