[Solved] Error reading lock file /etc/.profile.swp not enough data read. 


Before you get into this article, you may find here are the most frequent solved problems here it is.

This article covers a detailed step by step solution and there are significant reasons this content serves your purpose. Success 

I'm happy to share the piece of tip here that worked for me and saved my time a lot. 

Let's begin now,  

Introduction

Before begin, a bit to describe my development work here is the project developed in PHP Laravel Framework with LAMP (Linux Apache, MySQL and Php). The completed Php project is deployed in AWS Server instance in where Linux Ubuntu 18.4 OS installed.

Over a period of time, php project captures error logs increased size and occupied disk space in server instance. 

  • Software Involved
  • Linux - Ubuntu 18.4
  • Linux Command Terminal
  • PHP - Laravel Framework
  • MySQL

As you may have encountered these terms like error writing lock file no space left on device, swp: Not enough data read, .swp file. There could be lot of reasons why we encounter "Not enough space left". 

Similarly here are the most frequent search terms as you and me searched a lot to get here.

Error reading lock file /etc/.profile.swp  Not enough data read
Error reading lock file /etc/.default.swp Not enough data read
Error reading lock file /etc/.rc.local.swp Not enough data read

As said above .swp file may be the one causing the error. In your case .swp could be profile or default or local.

Problem Description

This is what happened in my case,

I logged into server instance where my php project is deployed which is Ubuntu 18.4, and opened command Terminal (Ctrl + Alt + T).  I navigated to project folder.

When exactly this error thrown?

There was a random common error in php project, if you are php background I'm sure you know it .env file and its purposes.

.env file stores all the configurations databases, SSL certificates credentials etc of the project.

 As said in above box, I actually did not configure correctly, setting to APP_DEBUG=true in .env file is fine for development.

APP_DEBUG = true

Whereas when you deploy your project in server it is highly not recommended to set as true. It should be set to false as below

APP_DEBUG = false

Why setting to false is important?

Its because when you set APP_Debug = true in .env file means when you encounter error in application the exception thrown in browser along with whole .env file expose everything as plain text.

Imagine anyone sees the error can also read your database user name and password.

Apart from above suggested let's get into the main problem description,

In the project folder .env file resides in root folder, now I try to open it (to change APP_DEBUG=false) in command line editor in terminal with this command $ sudo nano .env

$ sudo nano .env

After executing the command error show as "Error reading lock file ./..env.swp not enough data read". This is because any file you open with any editor .swp file gets created. And in here, log file size huge and space on device is insufficient to open the file in editor. 

If you have searched google many sites suggested different approach that did not help as much, that's the only reason I'm providing helping hand, explore more here

Get Set Solution helps everyone with details steps with google search.

Solve Error reading lock file



So how I get rid of not enough data read on device? Let's move to solution section.

Solution

The simple solution is provided in image below. 

These are the 4 steps to do 

  • 1. Navigate to your Project folder
  • 2. Find if you have hidden .swp files in folder
  • 3. Delete the .swp files
  • 4. Ensure you have deleted or not


STEP 1 : Navigate to your Project Folder 

I have placed my project folder in /home/ubuntu/projects/generator.

/home is home directory

/ubuntu is user account 

/projects is the folder name 

/generator is the actual php application 


STEP : 2  Find if you have hidden .swp files 

As circled 1 in image, execute this command find . -name "*.swp"

$ find . -name "*.swp"

the result will be as below as circled 2 list of .swp files available in my project

.swp files


STEP 3 : Delete the .swp files

As circled 3 in image, execute the command find . -name "*.swp" -delete 

$ find . -name "*.swp" -delete

After executing command, you find all the .swp files are deleted 

STEP 4:  Ensure you have deleted .swp files are not 

Just execute the same command find . -name "*.swp" this takes to next line that indicates you have deleted .swp files successfully

If you have missed all 4 steps, you can refer to below image described.

 

Solved Error reading lock file not enough space on disk



So what's next move?

Now you can proceed to open .env file using this command, that's all done.

$ sudo nano .env

Summary

So far, this article explains the problem detailed, development environment software, what caused error and solutions step by step that helps everyone.

The solution is applicable for Linux Ubuntu OS, helps to find .swp files to remove.