15

I am getting this error while opening /etc/profile file using nano.

Error reading lock file /etc/.profile.swp: Not enough data read

How can I fix this?

  • 3
    which version of nano are you using? Please type nano --version – Michele Jul 25 '17 at 9:33
  • This might be part of a known (and now resolved) bug in nano - do other text editors work with this file? You may need to upgrade your nano version to resolve depending on a the results of a nano --version. – The Pizza Overlord Jul 25 '17 at 9:37
  • my nano version is 2.5.3 – Vaibhav Phadke Jul 25 '17 at 14:43
  • Interesting. Can you run the following to see what/who else is accessing the swap file, and copy the output here please? - vi /etc/.profile.swp. – The Pizza Overlord Jul 26 '17 at 14:37
  • This swap file is only access by me to set the paths of java, hive, hadoop, pig etc. I'm able to open and edit the file using gedit, but not with nano. – Vaibhav Phadke Jul 28 '17 at 14:51
20

Try to remove the hidden file .[yourfilename].swp, which is stored in the same folder as the file that you are trying to open.
In your case try the shell command rm /etc/.profile.swp.

This issue also occurs with nano 2.7.4, and must be something to do with how nano handles a corrupted swapfile.

Hope this helped

4

The problem is linked to a bug in an older version of nano as seen here.

As per the report, the affected version was nano-2.4.2. You should run nano --version to ascertain your current version and update accordingly.

A more detailed report of the actual issue can be found here.

1

Was happening for me because I was out of disk space, I cleared up some space, deleted the swap file and it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.