Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

vi error

268 views
Skip to first unread message

jim_epler

unread,
Mar 28, 2007, 9:10:46 AM3/28/07
to
hello,
upon quitting vi, I am receiving

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

any suggestions would be appreciated.

thx.

Jim Epler
San Diego,CA
http://www.mytechmusings.com

Jean-Rene David

unread,
Mar 28, 2007, 9:56:30 AM3/28/07
to
* jim_epler [2007.03.28 13:10]:

> upon quitting vi, I am receiving

You are quitting vim, not vi.

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

:h E138
[...]
When you get error "E138: Can't write viminfo file"
check that no old temp files were left behind (e.g.
~/.viminf*) and that you can write in the directory of
the .viminfo file.

--
JR

jim_epler

unread,
Mar 28, 2007, 10:58:34 AM3/28/07
to
> When you get error "E138: Can't write viminfo file"
> check that no old temp files were left behind (e.g.
> ~/.viminf*) and that you can write in the directory of
> the .viminfo file.

JR, thanks for the reply. I guess I should have also noted that I'm
editing as the root user on the machine which makes it more strange to
me. I don't see any temp files in the root user's home directory
related to .vmi. I'm running Darwin Kernel Version 7.9.0 (OS 10.3.9
Server).

Jean-Rene David

unread,
Mar 28, 2007, 11:28:13 AM3/28/07
to
* jim_epler [2007.03.28 14:58]:

> I guess I should have also noted that I'm editing as the
> root user on the machine which makes it more strange to
> me. I don't see any temp files in the root user's home
> directory related to .vmi. I'm running Darwin Kernel
> Version 7.9.0 (OS 10.3.9 Server).

Did you become root by doing "su" or "su -"? What is the
HOME variable set to when you edit?

See:

:h viminfo-write

and the notes that follow. Esp:

- Vim will not overwrite a viminfo file that is not writable
by the current "real" user. This helps for when you did
"su" to become root, but your $HOME is still set to a
normal user's home directory. Otherwise Vim would create
a viminfo file owned by root that nobody else can read.

--
JR

jim_epler

unread,
Mar 28, 2007, 12:16:32 PM3/28/07
to
> Did you become root by doing "su" or "su -"? What is the
> HOME variable set to when you edit?
>

I typed "sudo -s" and authenticated using the admin's password to
arrive at the root prompt. I'm not sure exactly how to determine the
$HOME variable. I typed:

[www:~/] root# echo $HOME;

but was returned an empty line. I then typed "cd" and was returned

tcsh: cd: No home directory.

I'm going to go out on a limb here and guess this *might* be related
to the error I'm receiving?

Jean-Rene David

unread,
Mar 28, 2007, 12:27:45 PM3/28/07
to
* jim_epler [2007.03.28 16:16]:

> [www:~/] root# echo $HOME;
>
> but was returned an empty line. I then typed "cd" and was returned
>
> tcsh: cd: No home directory.

This is most likely your problem. Looks like root doesn't
have a home defined in /etc/passwd (though I know nothing
about OS X, to be frank.)

In vim, doing:
:set viminfo=n/tmp/viminfo

should at least make the error stop.

--
JR

jim_epler

unread,
Mar 28, 2007, 12:46:32 PM3/28/07
to
> This is most likely your problem. Looks like root doesn't
> have a home defined in /etc/passwd (though I know nothing
> about OS X, to be frank.)
>
yes, OS X Server's flavor of unix seems to be non-standard (i.e.
crap). unfortunately, i don't have the ability to change the OS on my
box or I would in a heartbeat.

> In vim, doing:
> :set viminfo=n/tmp/viminfo
>
> should at least make the error stop.
>

when entering above I receive E518: Unknow option: viminfo=n/tmp/
viminfo. I've been using pico but have been trying to do more with vi
(vim) to broaden my horizons. I've begun to appreciate its nuances
which clearly reveal why it is a superior text editor. I guess I can
go back to pico or just close my eyes and ignore the warning.

Glenn Jackman

unread,
Mar 28, 2007, 1:07:12 PM3/28/07
to
At 2007-03-28 12:46PM, "jim_epler" wrote:
> > In vim, doing:
> > :set viminfo=n/tmp/viminfo
> >
> > should at least make the error stop.
> >
>
> when entering above I receive E518: Unknow option: viminfo=n/tmp/
> viminfo. I've been using pico but have been trying to do more with vi
> (vim) to broaden my horizons. I've begun to appreciate its nuances
> which clearly reveal why it is a superior text editor. I guess I can
> go back to pico or just close my eyes and ignore the warning.

Or set $HOME before invoking vim:
env HOME=/tmp vim ...

--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry

jim_epler

unread,
Mar 28, 2007, 1:49:26 PM3/28/07
to
On Mar 28, 10:07 am, Glenn Jackman <gle...@ncf.ca> wrote:
>
> Or set $HOME before invoking vim:
> env HOME=/tmp vim ...

still getting the error. I even chmod'd 777 the .viminfo file found
in /tmp and to the .viminfo file in ~/var/root.

both these .viminfo files are universally writeable yet vim still
complains viminfo file $HOME/.viminfo!

What other directories might the .viminfo file reside?


Dan Mercer

unread,
Mar 28, 2007, 2:05:53 PM3/28/07
to

"jim_epler" <jim....@gmail.com> wrote in message news:1175087445....@p15g2000hsd.googlegroups.com...
: hello,

: upon quitting vi, I am receiving
:
: E138: Can't write viminfo file $HOME/.viminfo!

You have somehow defined viminfo as the literal string '$HOME/.viminfo',
not the value of $HOME/.viminfo. For instance, if the root home directory
was /root, the message would have been

E138: Can't write viminfo file /root/.viminfo!

Dan Mercer

:
: any suggestions would be appreciated.

:


jim_epler

unread,
Mar 28, 2007, 2:17:46 PM3/28/07
to
> You have somehow defined viminfo as the literal string '$HOME/.viminfo',
> not the value of $HOME/.viminfo. For instance, if the root home directory
> was /root, the message would have been
>
> E138: Can't write viminfo file /root/.viminfo!
>
> Dan Mercer

that makes sense. is there a preference or profile somewhere where I
can remove the quotes to set the value from a string back to the way
it should be represented?

-Jim

Bill Marcum

unread,
Mar 28, 2007, 2:39:51 PM3/28/07
to
On 28 Mar 2007 06:10:46 -0700, jim_epler
Could it be trying to write '$HOME/.viminfo' instead of using the
variable $HOME?


--
Minors in Kansas City, Missouri, are not allowed to purchase cap pistols;
they may buy shotguns freely, however.

jim_epler

unread,
Mar 28, 2007, 5:28:09 PM3/28/07
to
> On Mar 28, 10:07 am, Glenn Jackman <gle...@ncf.ca> wrote:
>
> > Or set $HOME before invoking vim:
> > env HOME=/tmp vim ...
>
this finally did the trick after typing env HOME=/tmp vi (not vim).
But how do I set this environmental variable so I won't need to type
it when invoking vim in future sessions? I tried setenv HOME=/tmp vi
but received a syntax error, and then tried to add it to my csh.cshrc
profile by hand, both to no avail.
-Jim


Bill Marcum

unread,
Mar 28, 2007, 6:59:52 PM3/28/07
to
On 28 Mar 2007 14:28:09 -0700, jim_epler
In a standard Unix system, the HOME variable is set according to the
next-to-last field in /etc/passwd. If Darwin is different, perhaps you
should consult an appropriate newsgroup or mailing list.
Here is one on the news.gmane.org news server:
news://news.gmane.org/gmane.os.opendarwin.general
Maybe an Apple newsgroup could help


--
"Well I don't see why I have to make one man miserable when I can make so many
men happy."
-- Ellyn Mustard, about marriage

Janis Papanagnou

unread,
Mar 28, 2007, 7:53:18 PM3/28/07
to
jim_epler wrote:
>>This is most likely your problem. Looks like root doesn't
>>have a home defined in /etc/passwd (though I know nothing
>>about OS X, to be frank.)
>>
>
> yes, OS X Server's flavor of unix seems to be non-standard (i.e.
> crap). unfortunately, i don't have the ability to change the OS on my
> box or I would in a heartbeat.

AFAIK, OS X is based on freeBSD; so a quite typical Unix.

You don't need to change the complete OS, just fix some settings,
as far as I see. Maybe your /etc/passwd has no home directory for
root (add it and create the directory if not existing). What does
this command show on your box...?

$ grep root /etc/passwd
root:x:0:0:root:/root:/bin/ksh
^^^^^

Maybe your profile is not set correctly; you seem to be using tcsh
as your default shell, so I cannot tell you about the specific tcsh
profile that you would have to add to your (root's) home directory,
but usually you find settings for the login shells in /etc/profile,
and perhaps also links to the shell specific profiles.

Elsethread you wrote:
> I tried setenv HOME=/tmp vi
> but received a syntax error, and then tried to add it to my
> csh.cshrc profile by hand, both to no avail.

Cannot tell about syntax for tcsh/csh but I had tried something like

$ setenv HOME /tmp
$ vi

or

$ setenv HOME=/tmp
$ vi

But better to use a non-dummy HOME directory.

Janis

jim_epler

unread,
Mar 30, 2007, 2:49:10 PM3/30/07
to
update:
I figured out why I was having the problem. I was tunneling in through
ssh to my box with an admin account and then switching to the root
prompt using "sudo -s". So, I guess vim wasn't actually trying to save
to the .viminfo file in the root user's home directory, but instead
into the admin's home directory (even though the prompt seemed to
indicate I was the root user [www:~/] root# ). And the admin account
is the one that doesn't have a home directory. When I actually
tunneled in to my box as root, I no longer received the error. Anyway,
thanks for the help. And to clarify what I said about OS X's Server's
flavor of UNIX which is the freeBSD, I think the underlying unix is
fine. But OS X Server mucked around and added their own directives and
non-freeBSD configuration files without adequate documentation. It
probably should have its own name; maybe LUNI-osX would fit the bill.

Hactar

unread,
Mar 31, 2007, 2:07:39 PM3/31/07
to
In article <1175117289.5...@b75g2000hsg.googlegroups.com>,

You could do it with an alias:

alias hvi env HOME=/tmp vi

but that's bash-speak; I don't know tcsh.

--
-eben QebWe...@vTerYizUonI.nOetP royalty.mine.nu:81
When we've nuked the world to a cinder, the cockroaches picking
over the remains will be crawling over the remaining artifacts
and wondering what "PC LOAD LETTER" means. -- PC / ASR

0 new messages