1

I am running MacOS Big Sur 11.7.9. Recently my nano editor stopped displaying text correctly using bash or zsh, and it scrambles text and doesn't properly display text.

How can I debug and fix this error?

Please see attached imgur video for the problem in action.

Things I've tried

  • Run stty sane -> no change
  • Opened a Terminal tab with a different profile -> no change
  • Created a new user account on my Mac -> problem occurs there as well

Running the command

ls  -l /usr/share/terminfo/78/xterm*

returns:

-rw-r--r--  1 root  wheel  3258 Jan  1  2020 /usr/share/terminfo/78/xterm
-rw-r--r--  1 root  wheel  1053 Jan  1  2020 /usr/share/terminfo/78/xterm+256color
-rw-r--r--  1 root  wheel  1051 Jan  1  2020 /usr/share/terminfo/78/xterm+88color
-rw-r--r--  1 root  wheel   422 Jan  1  2020 /usr/share/terminfo/78/xterm+app
-rw-r--r--  1 root  wheel   418 Jan  1  2020 /usr/share/terminfo/78/xterm+edit
-rw-r--r--  1 root  wheel   420 Jan  1  2020 /usr/share/terminfo/78/xterm+noapp
-rw-r--r--  1 root  wheel   404 Jan  1  2020 /usr/share/terminfo/78/xterm+pc+edit
-rw-r--r--  1 root  wheel  1153 Jan  1  2020 /usr/share/terminfo/78/xterm+pcc0
-rw-r--r--  1 root  wheel   824 Jan  1  2020 /usr/share/terminfo/78/xterm+pcc1
-rw-r--r--  1 root  wheel  1205 Jan  1  2020 /usr/share/terminfo/78/xterm+pcc2
-rw-r--r--  1 root  wheel   902 Jan  1  2020 /usr/share/terminfo/78/xterm+pcc3
-rw-r--r--  1 root  wheel  1091 Jan  1  2020 /usr/share/terminfo/78/xterm+pce2
-rw-r--r--  1 root  wheel  1011 Jan  1  2020 /usr/share/terminfo/78/xterm+pcf0
-rw-r--r--  1 root  wheel  1049 Jan  1  2020 /usr/share/terminfo/78/xterm+pcf2
-rw-r--r--  1 root  wheel  2069 Jan  1  2020 /usr/share/terminfo/78/xterm+pcfkeys
-rw-r--r--  1 root  wheel  1094 Jan  1  2020 /usr/share/terminfo/78/xterm+r6f2
-rw-r--r--  1 root  wheel  3268 Jan  1  2020 /usr/share/terminfo/78/xterm+sl
-rw-r--r--  1 root  wheel  3296 Jan  1  2020 /usr/share/terminfo/78/xterm+sl-twm
-rw-r--r--  1 root  wheel   464 Jan  1  2020 /usr/share/terminfo/78/xterm+vt+edit
-rw-r--r--  1 root  wheel  3269 Jan  1  2020 /usr/share/terminfo/78/xterm-1002
-rw-r--r--  1 root  wheel  3269 Jan  1  2020 /usr/share/terminfo/78/xterm-1003
-rw-r--r--  1 root  wheel  3402 Jan  1  2020 /usr/share/terminfo/78/xterm-16color
-rw-r--r--  1 root  wheel  1525 Jan  1  2020 /usr/share/terminfo/78/xterm-24
-rw-r--r--  1 root  wheel  3322 Jan  1  2020 /usr/share/terminfo/78/xterm-256color
-rw-r--r--  1 root  wheel  3320 Jan  1  2020 /usr/share/terminfo/78/xterm-88color
-rw-r--r--  1 root  wheel  1903 Jan  1  2020 /usr/share/terminfo/78/xterm-8bit
-rw-r--r--  1 root  wheel  1799 Jan  1  2020 /usr/share/terminfo/78/xterm-basic
-rw-r--r--  1 root  wheel  1535 Jan  1  2020 /usr/share/terminfo/78/xterm-bold
-rw-r--r--  1 root  wheel  1551 Jan  1  2020 /usr/share/terminfo/78/xterm-color
-rw-r--r--  1 root  wheel  1845 Jan  1  2020 /usr/share/terminfo/78/xterm-hp
-rw-r--r--  1 root  wheel  3252 Jan  1  2020 /usr/share/terminfo/78/xterm-new
-rw-r--r--  1 root  wheel  3268 Jan  1  2020 /usr/share/terminfo/78/xterm-nic
-rw-r--r--  1 root  wheel  3232 Jan  1  2020 /usr/share/terminfo/78/xterm-noapp
-rw-r--r--  1 root  wheel  1501 Jan  1  2020 /usr/share/terminfo/78/xterm-old
-rw-r--r--  1 root  wheel  3324 Jan  1  2020 /usr/share/terminfo/78/xterm-pcolor
-rw-r--r--  1 root  wheel  1301 Jan  1  2020 /usr/share/terminfo/78/xterm-r5
-rw-r--r--  1 root  wheel  1501 Jan  1  2020 /usr/share/terminfo/78/xterm-r6
-rw-r--r--  1 root  wheel  2021 Jan  1  2020 /usr/share/terminfo/78/xterm-sco
-rw-r--r--  1 root  wheel  2105 Jan  1  2020 /usr/share/terminfo/78/xterm-sun
-rw-r--r--  1 root  wheel  1983 Jan  1  2020 /usr/share/terminfo/78/xterm-vt220
-rw-r--r--  1 root  wheel   484 Jan  1  2020 /usr/share/terminfo/78/xterm-vt52
-rw-r--r--  1 root  wheel  2001 Jan  1  2020 /usr/share/terminfo/78/xterm-xf86-v32
-rw-r--r--  1 root  wheel  1991 Jan  1  2020 /usr/share/terminfo/78/xterm-xf86-v33
-rw-r--r--  1 root  wheel  2001 Jan  1  2020 /usr/share/terminfo/78/xterm-xf86-v333
-rw-r--r--  1 root  wheel  2207 Jan  1  2020 /usr/share/terminfo/78/xterm-xf86-v40
-rw-r--r--  1 root  wheel  2221 Jan  1  2020 /usr/share/terminfo/78/xterm-xf86-v43
-rw-r--r--  1 root  wheel  2255 Jan  1  2020 /usr/share/terminfo/78/xterm-xf86-v44
-rw-r--r--  1 root  wheel  2235 Jan  1  2020 /usr/share/terminfo/78/xterm-xfree86
-rw-r--r--  1 root  wheel  1981 Jan  1  2020 /usr/share/terminfo/78/xterm-xi
-rw-r--r--  1 root  wheel  3260 Jan  1  2020 /usr/share/terminfo/78/xterm1
-rw-r--r--  1 root  wheel  1607 Jan  1  2020 /usr/share/terminfo/78/xtermc
-rw-r--r--  1 root  wheel  1440 Jan  1  2020 /usr/share/terminfo/78/xtermm
-rw-r--r--  1 root  wheel  1525 Jan  1  2020 /usr/share/terminfo/78/xterms
-rw-r--r--  1 root  wheel  2121 Jan  1  2020 /usr/share/terminfo/78/xterms-sun

My $PATH is:

/usr/local/opt/curl/bin:/usr/local/opt/[email protected]/bin:/usr/local/opt/[email protected]/bin:/Users/danran/.local/bin:/Users/danran/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/opt/X11/bin:/Library/Apple/usr/bin:/Applications/Wireshark.app/Contents/MacOS:/Applications/dfsee/mac/:/usr/local/etc/pki
DanRan
  • 700
  • You're running GNU nano which you must have installed with some third-party package manager. Does the built-in nano work (/usr/bin/nano)? – Linc D. Jul 28 '23 at 20:24
  • @LincD. I am using Gnu nano. The MacOS /usr/bin/nano was having the exact same problem, so I installed nano from homebrew and put homebrew nano first in my path to see if it was the MacOS version of nano causing the problem. It wasn't, because the exact same problem happens in both zsh and bash with both MacOS nano and Gnu Nano. – DanRan Jul 29 '23 at 15:57
  • 1
    Start by uninstalling OMZ. So many issues get solved by removing it. – Allan Jul 29 '23 at 16:07
  • If you start nano with nano -I, does it still have the problem? Do you use screen or tmux ? – Marc Wilson Jul 29 '23 at 18:02
  • 1
    I uninstalled OMZ, and then tried starting nano with nano -I, which has no affect and the problem still exists. – DanRan Aug 04 '23 at 01:20
  • 2
    What is the value of $TERM? – Marc Wilson Aug 04 '23 at 03:24
  • @Marc Wilson it's "xterm-256color" – DanRan Aug 04 '23 at 07:48
  • Are you using Apple’s Terminal or some other terminal emulator? Can you try this with native Terminal? – Allan Aug 05 '23 at 23:26
  • Can you run stty sane in Terminal and try again? – nohillside Aug 06 '23 at 08:24
  • @nohillside It returns nothing in both bash and zsh. – DanRan Aug 06 '23 at 19:57
  • It shouldn't return anything, that's normal. But does nano work better now? – nohillside Aug 06 '23 at 20:04
  • If it didn't help: can you open a new Terminal tab with a different profile (via the menu, just pick a profile you don't usually use), and run nano there? If this fails as well, can you create a new user account on the Mac and try there? – nohillside Aug 07 '23 at 07:50
  • @nohillside After running stty sane, and then again testing nano, there is no difference and nano is still broken. I also picked a new profile in terminal and tried, with no difference. Then I created a new user account on the mac, and tried in that terminal, all to no avail. Same problem happened even on a brand new user account. So the problem is somewhere in root I would imagine. – DanRan Aug 07 '23 at 09:35
  • Does it only happen in nano or also in vi (use Esc followed by ":q" to exit) or emacs (use Ctrl-X Ctrl-C to exit)? – nohillside Aug 07 '23 at 09:46
  • @nohillside it only happens in nano, vi works fine. – DanRan Aug 07 '23 at 09:50
  • I'm slowly running out of ideas... TERM=vt100 nano does what? – nohillside Aug 07 '23 at 10:51
  • 3
    You never responded... are you using tmux or screen? Are you running this in Terminal.app or in iTerm or something else? – Marc Wilson Aug 07 '23 at 22:10
  • @MarcWilson How do I know if I am using tmux or screen? I don't think I'm using either. Im just using the regular default terminal (Terminal.app) that comes with Apple MacOS, and also trying with iTerm2. Both MacOS terminal and iTerms2 are yeilding the same problem with same results. – DanRan Aug 13 '23 at 15:32
  • 2
    If you don't know, you don't use it :-) Can you, in Terminal, run bash --noprofile --norc, and then in the newly started shell just nano? – nohillside Aug 13 '23 at 19:06
  • I ran the bash --noprofile --norc and then ran nono on test.txt. Nothing changed. Still getting the glitch. @nohillside – DanRan Aug 14 '23 at 18:15
  • Does echo $LINES $COLUMNS match the size of the Terminal window? Does the problem also exist if you set Terminal size to 80x25? – nohillside Aug 14 '23 at 19:03
  • Also, did you modify /etc/profile, /etc/bashrc or /etc/bashrc_Apple_Terminal? And what is your $PATH? – nohillside Aug 14 '23 at 19:04
  • @nohillside Lines and colums do match the size of the terminal window. I have not modified any of the mentioned files in the /etc/ directory. Also, I added my $PATH to the bottom of the question. – DanRan Aug 16 '23 at 20:04
  • Any other ideas? I'm thinking about backing up to Time Machine, and doing a complete reinstall just to get my nano back. But I really don't want to take the nuclear option unless I have to. – DanRan Aug 17 '23 at 20:59
  • Do you have something else installed that is providing terminfo? Did you maybe create $HOME/.terminfo or something similar? You mentioned Homebrew. If you run infocmp xterm-256color, where does the system think it's getting it from and what are the contents? – Marc Wilson Aug 20 '23 at 01:14

2 Answers2

3

For what it's worth, I am having the same problem.

Running

TERM=vt100 nano

fixes it.

nohillside
  • 100,768
acody
  • 56
  • Thanks for the feedback. So it seems that the terminal definitions are somehow wrong or corrupted. – nohillside Aug 09 '23 at 17:06
  • Yes, that also fixes it for me. But what was the problem, and what is the more permanent solution? How do i fix the terminal definitions @nohillside ? – DanRan Aug 13 '23 at 15:34
  • @DanRan /usr/share/terminfo/78/xterm-256color in your case – nohillside Aug 13 '23 at 16:09
  • I have no idea what /usr/share/terminfo/78/xterm-256color means or where it is to be used. Do you mean I should be entering the command TERM=/usr/share/terminfo/78/xterm-256color nano myfile.txt' or should I just enterTERM=/usr/share/terminfo/78/xterm-256color` ? – DanRan Aug 13 '23 at 17:23
  • @nohillside Running the plain command /usr/share/terminfo/78/xterm-256color yields zsh: permission denied: /usr/share/terminfo/78/xterm-256color with admin and root users. What should I do with this line? Could you make a proper answer possibly? Thanks so much for all of your help! – DanRan Aug 13 '23 at 17:24
  • @danran this is the file with the terminal definitions for xterm-256color. You could run ls -l /usr/share/terminfo/78/xterm* to see whether any of them stand out permission-wise, have a different date etc. – nohillside Aug 13 '23 at 19:04
  • @nohillside I added the output of ls -l /usr/share/terminfo/78/xterm* at the bottom of the ORIGINAL POST. Nothing seems suspicious. – DanRan Aug 14 '23 at 11:42
  • @nohillside Any other suggestions on how to fix this? I really need my nano editor to work. – DanRan Aug 16 '23 at 15:28
  • @danran see comments beneath the question, especially the last one. But I’m slowly running out of ideas. Would probably just define an alias for nano and go with VT100. – nohillside Aug 16 '23 at 16:00
0

I have solved it similar way as @acody suggest but with GUI (mac os 11.7.9 Big Sur): open terminal -> profiles -> advanced and find declare terminal as and choose vt100 enter image description here

Alex
  • 111