tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
958 stars 83 forks source link

Ormolu prints `stty: 'standard input': Inappropriate ioctl for device` to stdout #679

Closed gregorias closed 3 years ago

gregorias commented 3 years ago

Describe the bug When ormolu is called within Neovim's system call, Ormolu prints stty: 'standard input': Inappropriate ioctl for device as the first line in stdout.

The most important issue is not that ormolu doesn't play well with Neovim, but that it outputs an error message to stdout. This breaks plugins like vim-ormolu in Neovim. Those plugins run Ormolu and replace the current buffer with whatever Ormolu provides in stdout (assuming Ormolu doesn't return any errors).

To Reproduce

  1. Create /tmp/Main.hs with main :: IO ()
  2. Open the file with nvim /tmp/Main.hs
  3. Run `:let output = system("ormolu /tmp/Main.hs")
  4. Run echo output

The last command will display

stty: 'standard input': Inappropriate ioctl for device
main :: IO ()

Expected behavior

Ormolu should print only main :: IO () to stdout.

Environment

Additional Context

My hypothesis is that error is produced by the Text printing function as the problem doesn't appear when I run Ormolu in the inplace mode.

gregorias commented 3 years ago

It appears that this is a general problem with my Neovim not Ormolu.

Doing :! echo asdf also result in this error message.

gregorias commented 3 years ago

https://github.com/neovim/neovim/issues/6336 was relevant for this problem. I used Fish and a command in my config.fish was expecting an interactive shell. I found the culprit command and added an if that checks if status is-interactive before calling the culprit command.

Slava-Ini commented 6 months ago

Faced the same issue as @gregorias and the same actions helped For me it was fish config for powerline that contains some stty calls The code before from my fish.config:

set fish_function_path $fish_function_path "/usr/share/powerline/bindings/fish"
source /usr/share/powerline/bindings/fish/powerline-setup.fish
powerline-setup

The code after:

if status --is-interactive
  set fish_function_path $fish_function_path "/usr/share/powerline/bindings/fish"
  source /usr/share/powerline/bindings/fish/powerline-setup.fish
  powerline-setup
end