micro icon indicating copy to clipboard operation
micro copied to clipboard

Freezing on save with sudo

Open schiorean opened this issue 3 years ago • 4 comments

Freezing on save over a file that requires sudo

Quite often when trying to save a file that my user doesn't have permission to save, it freezes when after hitting save (F2 or Ctrl+S). It doesn't even get to the point when password is being asked. I have to restart the terminal because micro stays frozen.

This started to happen a few versions back at least, not related with current 2.0.10. If it helps, I'm on WSL.

Specifications

Version: 2.0.10 Commit hash: b9763856 Compiled on August 07, 2021

schiorean avatar Aug 31 '21 07:08 schiorean

If you need sudo permissions to save, micro asks you for an input y/n you just have to type y on your keyboard and it's going to unfreeze.

lominoss-git avatar Sep 07 '21 07:09 lominoss-git

Just tried again, lucky it was a time when it actually worked. It didn't ask me for any y/n input, just asked for the root password. When it doesn't work, it simply freezes without asking for anything.

schiorean avatar Sep 07 '21 07:09 schiorean

Lately I have to run micro with sudo when I want to edit a priviledged file, because it freezes on the [Y/n] prompt. It stops accepting input and starts using my CPU, sometimes up to 20%. I have to force kill it and try again with sudo instead of using the prompt.

andersmmg avatar Feb 07 '22 08:02 andersmmg

It stops accepting input and starts using my CPU, sometimes up to 20%. I have to force kill it and try again with sudo instead of using the prompt.

The same for me.

~$ uname -r
3.10.0
~$ cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)

pamburus avatar May 30 '22 12:05 pamburus

This just happened to me on Fedora 36, but I haven't been able to reproduce it. After pressing Ctrl+S, the editor view freezed, and nothing seemed to do anything. Sending a SIGTERM did close the editor, but the command did not complete and I had to send a SIGKILL as well.

This was on micro version 2.0.8 (installed from the distro's repository).

Igetin avatar Nov 02 '22 19:11 Igetin

@schiorean Can you point me to that issue? This issue seemed to be the best match to the symptoms I experienced when I searched through all the issues.

Igetin avatar Nov 02 '22 19:11 Igetin

@Igetin I erased my previous comment because I wrongly assumed am in another issue tracker. You are right and your problem is exactly as mine.

schiorean avatar Nov 02 '22 20:11 schiorean

So I just did find a way to consistently reproduce this, and also on the latest micro version (2.0.11):

  1. Open a new shell session
  2. Create a test directory: mkdir /tmp/testdir
  3. Make root the owner: sudo chown root:root /tmp/testdir
  4. Start editing a non-existing file in the directory: micro /tmp/testdir/testfile
  5. Go here and copy the file contents to your clipboard with the button
  6. Paste the clipboard contents to micro
  7. Press Ctrl+S to save
  8. The editor becomes unresponsive

This is also reproducible if the file already exists (with the aforementioned content), and you try to save the file without making any modifications. It definitely seems to have something to do with how much content a file has. I could not reproduce this with smaller files. Although it is very possible that there are multiple possible situations where the freeze occurs.

I reproduced this on another machine (Fedora 35) as well.

Igetin avatar Nov 02 '22 20:11 Igetin

Thank you for the detailed instructions for reproducing. I have added a commit that fixes the issue. Please let me know if you still experience it after the most recent commit.

zyedidia avatar Nov 02 '22 23:11 zyedidia

i'm experiencing this exact issue on the latest version from the arch repos, my editor just becomes unresponsive on the "do you want to save this file using sudo" prompt when trying to save the neofetch script (/usr/bin/neofetch) it is a very large file (well over 5k lines) as was pointed out in an above comment possibly being related to the issue

EDIT: im on version 2.0.11 (the latest version on arch) but it seems like it was compiled quite a while ago so i'll try building the latest commit from source and see if it fixes it

FantasyPvP avatar May 17 '23 22:05 FantasyPvP

I am experiencing the exact same issue when attempting to sudo save a large file.

Ubuntu Subsystem Linux 20.04 For me it was the file: /usr/lib/python3/dist-packages/OpenSSL/crypto.py

micro -version: Version: 2.0.11 Commit hash: 225927b9 Compiled on August 01, 2022

JoachimDunkel avatar Jul 20 '23 07:07 JoachimDunkel

@JoachimDunkel This is already fixed, but version 2.0.11 does not contain the fix. However, it is the latest release version as of writing.

If you want the fix before a new official release is available, you may build the application from the latest source.

Igetin avatar Jul 20 '23 08:07 Igetin