HaddingtonDynamics / Dexter

GNU General Public License v3.0
363 stars 84 forks source link

"Error reading lock file /filename/ Not enough data read" #102

Closed JamesNewton closed 3 years ago

JamesNewton commented 3 years ago

If you try to edit a file after SSHing into Dexter and running nano <filename> then what's happened is that the file was previously open for editing, with changes, and Dexters power was cut or the SSH session was disconnected or a new terminal window was accidentally opened. The nano editor (and vim) will leave a backup .swp file which contains a copy of the edited file. However, it doesn't do a good job of recovering that file for you automatically, instead providing this confusing error message.

This is especially evident if you forget that Ctrl+S is NOT how you save a file from nano. In Linux, Ctrl+S opens a new terminal window, leaving the old terminal session stopped in the background. So if you are in nano, editing a file, and press Ctrl+S, the nano editor will "disappear" and you will find yourself at a command prompt again wondering what happened.

If Linux is your friend, you know to type jobs to see all the suspended sessions, and then fg # where # is the number of the suspended job (probably 1 so fg 1) and you are back in nano editing without a problem. But if you don't realize what happened, and you open the file with nano again, you will get this message. If you then disconnect, that nano session in the background will be stopped, but with a .swp file created.

To resolve the issue, delete any swp files. rm .*swp and answer 'y' to each prompt.

See also: https://askubuntu.com/questions/939527/getting-error-while-opening-etc-profile-error-reading-lock-file-etc-profile