How Do You Fix the Problem in vi “E138: Can’t write viminfo file /home/cooluser/.viminfo!”?

Problem scenario
You save a file in vi.  When you go to exit you get the error "E138: Can't write viminfo file /home/cooluser/.viminfo!"

The error appears to be benign.  You can just press ENTER to continue.  But you would rather not do this.

What should you do?

Solution
Find the group that this user should be associated with (e.g., "users").  Run these two commands but replace "jdoe" with the user having the problem and replace "users" with the group that the user should belong to:

cd /home
sudo chown -R jdoe:users jdoe

Now the problem should not happen any longer.

Leave a comment

Your email address will not be published.