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

Rust debug message make nvim think something went wrong #21

Closed
mraspaud opened this issue Jan 10, 2025 · 7 comments
Closed

Rust debug message make nvim think something went wrong #21

mraspaud opened this issue Jan 10, 2025 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@mraspaud
Copy link

I tried using a new build of himalaya with neovim and the rust log debug coming on stderr confuse neovim in that it believes something went wrong.

Eg when sending an email:

Save draft [OK]                                                                                                                                                                                                                                                                                                                                                                                                                               
Sending email…                                                                                                                                                                                                                                                                                                                                                                                                                                
^[[2m2025-01-10T15:13:56.747012Z^[[0m ^[[33m WARN^[[0m ^[[2mimap_client::client::tokio^[[0m^[[2m:^[[0m IMAP BINARY extension not supported, using fallback                                                                                                                                                                                                                                                                                    
Error detected while processing function <lambda>79[1]..<SNR>43_on_exit[6]..function <lambda>79[1]..<SNR>43_on_exit:                                                                                                                                                                                                                                                                                                                          
line    6:                                                                                                                                                                                                                                                                                                                                                                                                                                    
E605: Exception not caught: CLI error, see :messages for more information        

A solution is to make an intermediate shell script the quiets down debug messages:
himalaya_fix.sh

#!/bin/sh
RUST_LOG="warn" himalaya

and in nvim/init.lua:

	{
		"pimalaya/himalaya-vim",
		config = function()
			vim.g.himalaya_executable = "~/.local/bin/himalaya_fix.sh"
			vim.g.himalaya_folder_picker = "telescope"
		end,
	},

setting the environment variable inside the init.lua file did not work, neither did setting the variable at nvim call.

@soywod
Copy link
Member

soywod commented Jan 10, 2025

One idea coming to my mind is to use stdout for any user output (data and error), and stderr for logs. This way we can easily play with the exit code (which is actually discarded by the Vim plugin — everything captured on stderr is an error):

  • If exit code 0, then stdout contains output
  • If exit code not 0, then stdout contains an error
  • Any data on stderr is a log, and can easily be put in a dedicated buffer.

@soywod soywod added the bug Something isn't working label Jan 10, 2025
@soywod soywod added this to Pimalaya Jan 10, 2025
@soywod soywod moved this to Todo in Pimalaya Jan 11, 2025
@soywod soywod self-assigned this Jan 11, 2025
@soywod
Copy link
Member

soywod commented Jan 11, 2025

I fixed the issue on master, so now it should work as expected. For the deeper refactor about stdout, stderr and exit code see pimalaya/himalaya#539.

@soywod soywod closed this as completed Jan 11, 2025
@github-project-automation github-project-automation bot moved this from Todo to Done in Pimalaya Jan 11, 2025
@mraspaud
Copy link
Author

I still have the same issue after updating to the latest master, eg:

Deleting email…                                                                                                                                                                                                                                                                                                                                                                                                                               
^[[2m2025-01-13T08:52:27.427630Z^[[0m ^[[33m WARN^[[0m ^[[2mimap_codec::response^[[0m^[[2m:^[[0m Rectified missing `text` to "..."                                                                                                                                                                                                                                                                                                            
^[[2m2025-01-13T08:52:27.427697Z^[[0m ^[[33m WARN^[[0m ^[[2mimap_client::tasks::resolver^[[0m^[[2m:^[[0m received unsolicited ^[[3munsolicited^[[0m^[[2m=^[[0mStatus(Untagged(StatusBody { kind: Ok, code: Some(CopyUid { uid_validity: 12, source: UidSet([Single(1200965)]+), destination: UidSet([Single(254193)]+) }), text: Text("...") }))                                                                                              
^[[2m2025-01-13T08:52:27.427807Z^[[0m ^[[33m WARN^[[0m ^[[2mimap_client::tasks::resolver^[[0m^[[2m:^[[0m received unsolicited ^[[3munsolicited^[[0m^[[2m=^[[0mData(Expunge(48))                                                                                                                                                                                                                                                               
^[[2m2025-01-13T08:52:27.427833Z^[[0m ^[[33m WARN^[[0m ^[[2mimap_client::tasks::resolver^[[0m^[[2m:^[[0m received unsolicited ^[[3munsolicited^[[0m^[[2m=^[[0mData(Exists(48))                                                                                                                                                                                                                                                                
Error detected while processing function <lambda>68[1]..<SNR>46_on_exit[6]..function <lambda>68[1]..<SNR>46_on_exit:                                                                                                                                                                                                                                                                                                                          
line    6:                                                                                                                                                                                                                                                                                                                                                                                                                                    
E605: Exception not caught: CLI error, see :messages for more information

@soywod
Copy link
Member

soywod commented Jan 13, 2025

Strange, because it does work for me with CLI on master (15a9a4a) and Vim plugin on master (bb8d0eb). When listing envelopes using the CLI I see warnings, and when listing envelopes via the Vim plugin I don't get any error. Here the Vim config used for testing:

syntax on                                                                              
filetype plugin on                                                                     
                                                                                       
packadd! himalaya                                                                      
                                                                                       
" native, fzf or telescope                                                             
let g:himalaya_executable = '/path/to/himalaya/target/debug/himalaya'
let g:himalaya_config_path = '/path/to/config.toml'                                    
let g:himalaya_folder_picker = 'telescope'                                             
let g:himalaya_folder_picker_telescope_preview = v:false                               
let g:himalaya_complete_contact_cmd = 'echo test@localhost'                            

@mraspaud
Copy link
Author

mraspaud commented Jan 16, 2025

I finally got time to get back to this. I updated himalaya to master, build it with cargo to enable the keyring feature I need, and made sure it’s the one picked by nvim.
Himalaya-vim was already updated to master, so nothing to do there. My config for the plugin in like this (it’s lua as I’m using neovim with the lazy package manager):

  {
    "pimalaya/himalaya-vim",
    config = function()
      vim.g.himalaya_executable = "~/.cargo/bin/himalaya"
      vim.g.himalaya_folder_picker = "telescope"
      vim.g.himalaya_folder_picker_telescope_preview = false
    end,
  },

Listing the envelopes works fine, but as soon as I perform an action, eg deleting an email, the debug comes through and nvim flags it as en error:

Deleting email…                                                                                                                                                                                                       
^[[2m2025-01-16T12:01:19.579761Z^[[0m ^[[33m WARN^[[0m ^[[2mimap_codec::response^[[0m^[[2m:^[[0m Rectified missing `text` to "..."                                                                                    
^[[2m2025-01-16T12:01:19.579834Z^[[0m ^[[33m WARN^[[0m ^[[2mimap_client::tasks::resolver^[[0m^[[2m:^[[0m received unsolicited ^[[3munsolicited^[[0m^[[2m=^[[0mStatus(Untagged(StatusBody { kind: Ok, code: Some(CopyUi
d { uid_validity: 12, source: UidSet([Single(1201215)]+), destination: UidSet([Single(254409)]+) }), text: Text("...") }))                                                                                            
^[[2m2025-01-16T12:01:19.579878Z^[[0m ^[[33m WARN^[[0m ^[[2mimap_client::tasks::resolver^[[0m^[[2m:^[[0m received unsolicited ^[[3munsolicited^[[0m^[[2m=^[[0mData(Expunge(9))                                        
^[[2m2025-01-16T12:01:19.579892Z^[[0m ^[[33m WARN^[[0m ^[[2mimap_client::tasks::resolver^[[0m^[[2m:^[[0m received unsolicited ^[[3munsolicited^[[0m^[[2m=^[[0mData(Exists(12))                                        
Error detected while processing function <lambda>38[1]..<SNR>46_on_exit[6]..function <lambda>38[1]..<SNR>46_on_exit:                                                                                                  
line    6:                                                                                                                                                                                                            
E605: Exception not caught: CLI error, see :messages for more information

Note the the action is actually performed as the next time I open himalaya vim, the email in gone.

@soywod
Copy link
Member

soywod commented Jan 18, 2025

I still cannot reproduce. My intuition is that your Lua config bypasses the Vim's one. If you manually add RUST_LOG=off in front of your config, does it work?

vim.g.himalaya_executable = "RUST_LOG=off ~/.cargo/bin/himalaya"

@mraspaud
Copy link
Author

Thanks a lot for your patience! I had tried this before without success, but I tried again right now, and it’s working great! sorry for the noise…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

2 participants