dustinblackman / oatmeal.nvim

Terminal UI to chat with large language models (LLM) using different model backends, and with a plugin for Neovim!
https://github.com/dustinblackman/oatmeal
MIT License
82 stars 3 forks source link

Panic on `:Oatmeal` -- `EOF while parsing a value at line 1 column 0` #1

Closed alexcardell closed 10 months ago

alexcardell commented 11 months ago

Configuration:

require('oatmeal').setup({
  backend = "ollama",
  model = "codellama:latest"
})

Steps to reproduce:

:Oatmeal

Neovim Terminal output (with RUST_BACKTRACE=full):

oatmeal --editor neovim --backend ollama --model codel
lama:latest
Backtrace (most recent call first):
  File "<unknown>", line 0, in oatmeal::main::{{closure}}
  File "<unknown>", line 0, in tokio::runtime::park::CachedParkT
hread::block_on
  File "<unknown>", line 0, in oatmeal::main
  File "<unknown>", line 0, in std::sys_common::backtrace::__rus
t_begin_short_backtrace
  File "<unknown>", line 0, in std::rt::lang_start::{{closure}}
  File "<unknown>", line 0, in std::rt::lang_start_internal
  File "<unknown>", line 0, in _main

The application panicked (crashed).
  called `Result::unwrap()` on an `Err` value: EOF while parsing
 a value at line 1 column 0
in src/main.rs, line 46
thread: main

System: Darwin arm64 Using the standalone binary

oatmeal --backed ollama --model codellama:latest works perfectly fine

I've been digging through the code, but not a Rustacean. Themes loading uses BufReader which would throw this but I'm not setting any theme. Does serde throw this as well?

dustinblackman commented 11 months ago

Thanks for the report! I've just pushed a new version of the CLI to provide clearer panic stack traces so this is easier to debug.

I did mange to repro though, and it's specifically something to do with calling in to Neovim. Could you help me out a do the following, please?

  1. Provide the version of Neovim you're using.
  2. Execute the following in a neovim terminal and provide me the result (double checking there's no sensitive data first): env | grep NVIM.

Thanks!

alexcardell commented 11 months ago

Cool project by the way!

CLI v0.2.4, standalone binary

nvim --version

NVIM v0.9.1
Build type: Release
LuaJIT 2.1.0-beta3

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/nix/store/r6wg9w7mzbd6vmmyhms0yb6y8sypfy8k-neovim-unwrapped-0.9.1/share/nvim
"

Run :checkhealth for more info

Nvim terminal output trace

Oh no! Oatmeal has failed with the following app version and err
or.

Version: 0.2.4
Commit: v0.2.4
Error: EOF while parsing a value at line 1 column 0

   0: anyhow::backtrace::capture::Backtrace::capture
   1: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
   2: <oatmeal::infrastructure::editors::neovim::Neovim as oatmeal::domain::models::editor::Editor>::get_context::{{closure}}
   3: oatmeal::application::ui::start::{{closure}}
   4: <tokio::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
   5: oatmeal::main::{{closure}}
   6: tokio::runtime::park::CachedParkThread::block_on
   7: oatmeal::main
   8: std::sys_common::backtrace::__rust_begin_short_backtrace
   9: std::rt::lang_start::{{closure}}
  10: std::rt::lang_start_internal
  11: _main
NVIM_SYSTEM_RPLUGIN_MANIFEST=/nix/store/kxlyc7xjdaakpyvdiys7yvxvbmrgklg3-neovim-0.9.1/rplugin.vim
NVIM=/var/folders/tq/1w9ztkw909j0xq9tsgpjgh7h0000gn/T/nvim.alexcard/2EPY2d/nvim.3431.0
NVIM_LOG_FILE=/Users/alexcard/.local/state/nvim/log
ls -al /var/folders/tq/1w9ztkw909j0xq9tsgpjgh7h0000gn/T/nvim.alexcard/2EPY2d/nvim.3431.0

srwxr-xr-x  1 alexcard  staff  0 11 Nov 14:18 /var/folders/tq/1w9ztkw909j0xq9tsgpjgh7h0000gn/T/nvim.alexcard/2EPY2d/nvim.3431.0

My neovim install is through nix with home-manager, which sometimes does cause permission issues, I was thinking maybe the NVIM socket permissions?

alexcardell commented 11 months ago

@dustinblackman looks like it was a 0.9.1 neovim issue, noticed I was slightly behind and updated, now it's working fine

codemeleon commented 11 months ago

I tried different versions of neovim and getting following error

$ oatmeal --editor neovim --backend ollama --model codellama:latest
Oh no! Oatmeal has failed with the following app version and error.
Version: 0.2.4

Commit: VERGEN_IDEMPOTENT_OUTPUT
Error: No such file or directory (os error 2)

To report a bug, please rerun your command with the following to print stack traces: 

RUST_BACKTRACE=1 oatmeal --editor neovim --backend ollama --model codellama:latest

It runs fine without editor option.

dustinblackman commented 11 months ago

@codemeleon That one feels odd. Would you mind running the recommended backtrace command please? I'll take a look!

codemeleon commented 11 months ago

@dustinblackman

$ RUST_BACKTRACE=1 oatmeal --editor neovim --backend ollama --model codellama:latest
Oh no! Oatmeal has failed with the following app version and error.

Version: 0.2.4
Commit: VERGEN_IDEMPOTENT_OUTPUT
Error: environment variable not found

   0: oatmeal::infrastructure::editors::neovim::run_lua_command::{{closure}}
   1: <oatmeal::infrastructure::editors::neovim::Neovim as oatmeal::domain::models::editor::Editor>::get_context::{{closure}}
   2: oatmeal::application::ui::start::{{closure}}
   3: <tokio::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
   4: oatmeal::main::{{closure}}
   5: oatmeal::main
   6: std::sys_common::backtrace::__rust_begin_short_backtrace
   7: std::rt::lang_start::{{closure}}
   8: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/ops/function.rs:284:13
      std::panicking::try::do_call
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:502:40
      std::panicking::try
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:466:19
      std::panic::catch_unwind
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panic.rs:142:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/rt.rs:148:48
      std::panicking::try::do_call
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:502:40
      std::panicking::try
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:466:19
      std::panic::catch_unwind
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panic.rs:142:14
      std::rt::lang_start_internal
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/rt.rs:148:20
   9: main
  10: <unknown>
  11: __libc_start_main
  12: <unknown>
dustinblackman commented 11 months ago

Ah you're not running within a neovim terminal, correct? I should add better error handling there.

codemeleon commented 11 months ago

At first, I tried inside neovim using given command :Oatmeal and got the errors I posted initially

image

dustinblackman commented 10 months ago

I’ve pushed a few patches since the last comments that I believe solve the issues here. I’ll close for now, and reopen if you’re still experiencing issues. Thanks all for reporting!

codemeleon commented 10 months ago

Apologies. The problem still persists.

dustinblackman commented 10 months ago

The latest version of oatmeal has logging to help debug. Could you run while setting environment variable RUST_LOG=oatmeal please? That should help find the issue :) You can find the log file by running 'oatmeal debug log-path'

The main repo also has docs to use debug builds to help drill down further. https://github.com/dustinblackman/oatmeal#report-an-issue

Note I've set the minimum version of Neovim to 0.9.2 since you've reported the issue. What version are you running?

I'm going to keep this issue closed. Please feel free to open a new one so we can start fresh!