Linux Administrator

How To Fix – Vim Error E138: Can’t write viminfo file

If you are getting this error “Can’t write viminfo file” it means there is no space left on the system.

It happens due to out of disk space or may be no free inode is left on the server/system.

This could be the main reason that vim operation is unable to write in the .viminfo file. First you should check your server disk space.

Error :

Vim Error E138: Can't write viminfo file $HOME/.viminfo!

In this article I will show how you can fix this error.

Check Disk Space

First of all check disk space on the server using below command.

# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        7.8G   64K  7.8G   1% /dev
tmpfs           7.8G     0  7.8G   0% /dev/shm
/dev/nvme0n1p1  148G   98G   50G  67% /

If everything is looks fine. In my example my disk / partition disk space is 67% used it means all looks good no need to increase disk. Now let’s check inode usage using below command:

Follow my this tutorial to find  :  Top 10 Space Consuming Directories & Files On Linux & UNIX System

# df -i
Filesystem      Inodes  IUsed   IFree IUse% Mounted on
devtmpfs       2028382    473 2027909    1% /dev
tmpfs          2030623      1 2030622    1% /dev/shm
/dev/nvme0n1p1 9830400 199034 9631366    3% /

Check this line:

/dev/nvme0n1p1 9830400 199034 9631366    3% /

If it is showing 100% Isue means you have to make some space on your server. In my case it is using only 3%.

I found this issue on my vps server there was no free inode was left. I fixed this issue increasing inode on the server.

If above situation is fine than there could be lots of reason, may be viminfo file in $/HOME/.viminfo! is corrupted. You should fix this removing this file as shown below.

# rm /HOME/.viminfo*

You can also check the permission and ownership of /HOME/.viminfo* For some reason, this resulted in the owner of the directory to be “nobody“. Adding write permissions for “other” solved the problem.

# chmod o+w ~/.viminfo

Hope this will help you!

If want to learn basic vi command follow my this tutorial : Understanding Basic Vi Editor

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment