2

The Terminal suddenly stopped accepting commands and is behaving like a text editor. I can type text, but pressing Enter does nothing—it just moves to the next line and doesn't execute anything.

enter image description here

The last commands that I put in before this happened was just some nvm commands, i.e. nvm alias default 20.11.0, nvm ls, etc.

Restart did not fix it.

I haven't seen this behaviour before, did I perhaps accidentally hit a shortcut that switched it into a different mode? If so, how do I reset it?

Ignatius
  • 143

3 Answers3

7

As steeldriver said, this is the symptom of a long-running process. Since it is nvm, this is completely reasonable. nvm caused my shell to take significantly longer to start as it tries to load a bunch of files from disk.

Try pressing CTRL+C (multiple times if it doesn't work, then CTRL+\) at that prompt to cancel the long-running command (usually nvm). You should end up at your normal prompt, possibly without color. When Linux runs a terminal command, the terminal subsystem buffers the input and echoes it before sending it to any application, unless the specific command bothered to disable echo.

As Raffa said, the problem is inside ~/.bashrc. See https://github.com/nvm-sh/nvm/issues/782 , https://stackoverflow.com/questions/23556330/run-nvm-use-automatically-every-time-theres-a-nvmrc-file-on-the-directory , and https://github.com/nvm-sh/nvm/issues/1261 . I personally use something like the following edit to my .bashrc:

# Comment out the lines the nvm installer added by default
#[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
#[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
#. <(npm completion)

Only load nvm when necessary

alias nvm='unalias nvm && . "$NVM_DIR/nvm.sh" && nvm' alias node='unalias node && . "$NVM_DIR/nvm.sh" && node'

This may cause some subtle bugs, but it greatly reduces the impact of nvm on my terminal startup time. This is especially useful for working with non-Node commands.

Daniel T
  • 5,339
0

Ran into the same issue where the terminal did not run any commands even though it could read text. Hitting return just moved to the next line.

I faced this issue after a system upgrade sudo zypper dup.

After a LOT of trial and error, found the culprit in ~/.zshrc.

I was using Powerlevel10k:

ZSH_THEME="powerlevel10k/powerlevel10k"

Switching back to the default fixed it:

ZSH_THEME="robbyrussell"

Moved to starship since—no issues.

ducky
  • 378
  • 3
  • 6
-1

Try booting in single user mode using shortcut ( for me it is ctrl+alt+F4).

Then see if you are able to run commands. If yes, then go to /usr/bin/ and check if gnome-terminal is present. Also check modified date.

First check if internet is reachable and then Try running

sudo apt-get remove gnome-terminal

sudo apt-get install gnome-terminal

to see if it fixes the issue.

If this doesn't work, you can go to ubuntu software and install any other terminal like terminator, guake etc.

IamSushil
  • 124