Discussion:
Can't write .profile from vi
l***@cisra.canon.com.au
2002-09-03 03:40:34 UTC
Permalink
My ~/.profile file is the only one I've found with this problem.
As far a I can see, I have write permission, I am me, but I'm not
allowed to write the file from vi! I have to write it into another
file in my home directory and then cp that on top of .profile!

$ vi ~/.profile

-rwxr-xr-x 1 luke Domain U 4327 Aug 30 10:40 /home/luke/.profile
Hit ENTER or type command to continue
uid=11021(luke) gid=10513(Domain Users) groups=10513(Domain Users)
"~/.profile"
"~/.profile" E212: Can't open file for writing
Hit ENTER or type command to continue

I'm using /usr/bin/vi from the Cygwin installation.

luke


--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
Cyber.Zombie
2002-09-03 04:07:45 UTC
Permalink
"cat /etc/passwd" and look at your numeric user and group ids. Now do a
"ls -aln .profile". I'm betting (given you're on a domain) that the id
is not gonna match up with what NT thinks it should be -- and you should
do a "mkpasswd -d ..." rather than -l (same using mkgroup).

Either that or do a "w!" (or chmod 777) on .profile...
Post by l***@cisra.canon.com.au
My ~/.profile file is the only one I've found with this problem.
As far a I can see, I have write permission, I am me, but I'm not
allowed to write the file from vi! I have to write it into another
file in my home directory and then cp that on top of .profile!
$ vi ~/.profile
-rwxr-xr-x 1 luke Domain U 4327 Aug 30 10:40 /home/luke/.profile
Hit ENTER or type command to continue
uid=11021(luke) gid=10513(Domain Users) groups=10513(Domain Users)
"~/.profile"
"~/.profile" E212: Can't open file for writing
Hit ENTER or type command to continue
I'm using /usr/bin/vi from the Cygwin installation.
luke
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
l***@cisra.canon.com.au
2002-09-06 01:46:29 UTC
Permalink
Post by Cyber.Zombie
"cat /etc/passwd" and look at your numeric user and group ids. Now do a
"ls -aln .profile". I'm betting (given you're on a domain) that the id
is not gonna match up with what NT thinks it should be -- and you should
do a "mkpasswd -d ..." rather than -l (same using mkgroup).
Either that or do a "w!" (or chmod 777) on .profile...
Thanks for the thought, but of course the :w! doesn't work (that was
the first thing I tried), and as I said, I can write other files in my
home directory (which is a local directory on the PC, not a network
share or anything, BTW). I can also do this:

:w xxx
:q
cp xxx .profile

I tried your other suggestion, too, and (not surprisingly, given the
above facts), that checked out okay too:

$ grep luke /etc/passwd
luke:unused_by_nt/2000/xp:11021:10513:Luke Kendall,U-CISRA\luke,S-1-5-21-5706737
-76180391-208020174-1021:/home/luke:/bin/bash
lukep:unused_by_nt/2000/xp:12898:10513:Luke Paton,U-CISRA\lukep,S-1-5-21-5706737
-76180391-208020174-2898:/home/lukep:/bin/bash
$ ls -aln ~/.profile
-rwxr-xr-x 1 11021 10513 4327 Aug 30 10:40 /home/luke/.profile
Post by Cyber.Zombie
Post by l***@cisra.canon.com.au
My ~/.profile file is the only one I've found with this problem.
As far a I can see, I have write permission, I am me, but I'm not
allowed to write the file from vi! I have to write it into another
file in my home directory and then cp that on top of .profile!
$ vi ~/.profile
-rwxr-xr-x 1 luke Domain U 4327 Aug 30 10:40 /home/luke/.profile
Hit ENTER or type command to continue
uid=11021(luke) gid=10513(Domain Users) groups=10513(Domain Users)
"~/.profile"
"~/.profile" E212: Can't open file for writing
Hit ENTER or type command to continue
I'm using /usr/bin/vi from the Cygwin installation.
luke
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
l***@cisra.canon.com.au
2002-09-06 02:19:12 UTC
Permalink
Subject: Re: Can't write .profile from vi
Post by l***@cisra.canon.com.au
Thanks for the thought, but of course the :w! doesn't work (that was
the first thing I tried), and as I said, I can write other files in my
home directory (which is a local directory on the PC, not a network
:w xxx
:q
cp xxx .profile
Actually, vi won't let me write any existing file whose name starts with
a ".". The error is always "E212: Can't open file for writing"

It only affects existing dot files. And yes, I have write permission
for them all. (I can edit them with vi by writing them to a file ~/xxx
and copying that over the top of the file.)

This is on WindowsXP on a FAT32 file system.

Even stranger, is the fact that I can create new dot files (e.g. .xxx),
and write them. I can then copy an old dotfile over .xxx and write
.xxx; and copy .xxx over .xinitrc. But I still can't write .xinitrc
from inside vi.

What *does* work is this:

cp .xinitrc .xxx
rm .xinitrc
mv .xxx .xinitrc

*Then* I can edit .xinitrc and write it.

The "rm" seemed to have a slightly different noise to other rms; it
sounded like there was a little more disc access, and it took a
fraction of a second longer.

Anyway, I'll wait a couple of days in case anyone would like me to try
some diagnostics. Failing that, I'll just write a script that applies
the above workaround and I'll be happy; though diagnosing the Cygwin
problem may then become impossible.

luke


--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
Larry Hall (RFK Partners, Inc)
2002-09-06 02:24:06 UTC
Permalink
Post by l***@cisra.canon.com.au
Subject: Re: Can't write .profile from vi
Post by l***@cisra.canon.com.au
Thanks for the thought, but of course the :w! doesn't work (that was
the first thing I tried), and as I said, I can write other files in my
home directory (which is a local directory on the PC, not a network
:w xxx
:q
cp xxx .profile
Actually, vi won't let me write any existing file whose name starts with
a ".". The error is always "E212: Can't open file for writing"
It only affects existing dot files. And yes, I have write permission
for them all. (I can edit them with vi by writing them to a file ~/xxx
and copying that over the top of the file.)
This is on WindowsXP on a FAT32 file system.
Even stranger, is the fact that I can create new dot files (e.g. .xxx),
and write them. I can then copy an old dotfile over .xxx and write
.xxx; and copy .xxx over .xinitrc. But I still can't write .xinitrc
from inside vi.
cp .xinitrc .xxx
rm .xinitrc
mv .xxx .xinitrc
*Then* I can edit .xinitrc and write it.
The "rm" seemed to have a slightly different noise to other rms; it
sounded like there was a little more disc access, and it took a
fraction of a second longer.
Anyway, I'll wait a couple of days in case anyone would like me to try
some diagnostics. Failing that, I'll just write a script that applies
the above workaround and I'll be happy; though diagnosing the Cygwin
problem may then become impossible.
I pulled this from your previous email:

$ grep luke /etc/passwd
luke:unused_by_nt/2000/xp:11021:10513:Luke Kendall,U-CISRA\luke,S-1-5-21-5706737
-76180391-208020174-1021:/home/luke:/bin/bash
lukep:unused_by_nt/2000/xp:12898:10513:Luke Paton,U-CISRA\lukep,S-1-5-21-5706737
-76180391-208020174-2898:/home/lukep:/bin/bash
$ ls -aln ~/.profile
-rwxr-xr-x 1 11021 10513 4327 Aug 30 10:40 /home/luke/.profile


Your uid (11021) and SID (S-1-5-21--76180391-208020174-1021) don't match.
Are you sure this was generated by mkpasswd? You'll want to double check
this and the difference in ownership and permissions between the files that
vi is working with and those (like .profile) that it's not. I expect you'll
see a difference there. It's worth keeping in mind as well that the user
your trying to be in this case is a domain user. While this isn't a no-no,
it does come with some extra potential "gotchas" which I alluded to above
and which are covered in the email archives. But start with these checks
and make sure something here doesn't signal the problem.

Good luck,




Larry Hall ***@rfk.com
RFK Partners, Inc. http://www.rfk.com
838 Washington Street (508) 893-9779 - RFK Office
Holliston, MA 01746 (508) 893-9889 - FAX


--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
Igor Pechtchanski
2002-09-06 02:41:14 UTC
Permalink
Post by l***@cisra.canon.com.au
Post by l***@cisra.canon.com.au
Subject: Re: Can't write .profile from vi
Post by l***@cisra.canon.com.au
Thanks for the thought, but of course the :w! doesn't work (that was
the first thing I tried), and as I said, I can write other files in my
home directory (which is a local directory on the PC, not a network
:w xxx
:q
cp xxx .profile
Actually, vi won't let me write any existing file whose name starts with
a ".". The error is always "E212: Can't open file for writing"
It only affects existing dot files. And yes, I have write permission
for them all. (I can edit them with vi by writing them to a file ~/xxx
and copying that over the top of the file.)
This is on WindowsXP on a FAT32 file system.
Even stranger, is the fact that I can create new dot files (e.g. .xxx),
and write them. I can then copy an old dotfile over .xxx and write
.xxx; and copy .xxx over .xinitrc. But I still can't write .xinitrc
from inside vi.
cp .xinitrc .xxx
rm .xinitrc
mv .xxx .xinitrc
*Then* I can edit .xinitrc and write it.
The "rm" seemed to have a slightly different noise to other rms; it
sounded like there was a little more disc access, and it took a
fraction of a second longer.
Anyway, I'll wait a couple of days in case anyone would like me to try
some diagnostics. Failing that, I'll just write a script that applies
the above workaround and I'll be happy; though diagnosing the Cygwin
problem may then become impossible.
$ grep luke /etc/passwd
luke:unused_by_nt/2000/xp:11021:10513:Luke Kendall,U-CISRA\luke,S-1-5-21-5706737
-76180391-208020174-1021:/home/luke:/bin/bash
lukep:unused_by_nt/2000/xp:12898:10513:Luke Paton,U-CISRA\lukep,S-1-5-21-5706737
-76180391-208020174-2898:/home/lukep:/bin/bash
$ ls -aln ~/.profile
-rwxr-xr-x 1 11021 10513 4327 Aug 30 10:40 /home/luke/.profile
Your uid (11021) and SID (S-1-5-21--76180391-208020174-1021) don't match.
Are you sure this was generated by mkpasswd? You'll want to double check
this and the difference in ownership and permissions between the files that
vi is working with and those (like .profile) that it's not. I expect you'll
see a difference there. It's worth keeping in mind as well that the user
your trying to be in this case is a domain user. While this isn't a no-no,
it does come with some extra potential "gotchas" which I alluded to above
and which are covered in the email archives. But start with these checks
and make sure something here doesn't signal the problem.
Actually, the mismatching ids are fine - this is what mkpasswd generates
for domain users. This might, however, be the reason why this is
failing... Is your home directory on a network drive, by any chance?
I've had some permission troubles with samba drives and cygwin...
What's the output of 'id' for you, by the way?
Igor
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ ***@cs.nyu.edu
ZZZzz /,`.-'`' -. ;-;;,_ ***@watson.ibm.com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!

It took the computational power of three Commodore 64s to fly to the moon.
It takes a 486 to run Windows 95. Something is wrong here. -- SC sig file


--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
l***@cisra.canon.com.au
2002-09-06 06:45:14 UTC
Permalink
I've found what was causing it; might be a Cygwin error.
Post by Larry Hall (RFK Partners, Inc)
Post by l***@cisra.canon.com.au
$ grep luke /etc/passwd
luke:unused_by_nt/2000/xp:11021:10513:Luke Kendall,U-CISRA\luke,S-1-5-21-5706737
-76180391-208020174-1021:/home/luke:/bin/bash
lukep:unused_by_nt/2000/xp:12898:10513:Luke Paton,U-CISRA\lukep,S-1-5-21-5706737
-76180391-208020174-2898:/home/lukep:/bin/bash
$ ls -aln ~/.profile
-rwxr-xr-x 1 11021 10513 4327 Aug 30 10:40 /home/luke/.profile
Your uid (11021) and SID (S-1-5-21--76180391-208020174-1021) don't match.
Are you sure this was generated by mkpasswd?
Absolutely.
Post by Larry Hall (RFK Partners, Inc)
Post by l***@cisra.canon.com.au
You'll want to double check
this and the difference in ownership and permissions between the files that
vi is working with and those (like .profile) that it's not. I expect you'll
see a difference there.
There are no visible differences, except to vi.
Post by Larry Hall (RFK Partners, Inc)
Post by l***@cisra.canon.com.au
It's worth keeping in mind as well that the user
your trying to be in this case is a domain user. While this isn't a no-no,
it does come with some extra potential "gotchas" which I alluded to above
and which are covered in the email archives.
I can search through the archive - any suggestion of topics I should
search by? I don't suppose there's anything in the FAQ or User Guide
that I could read?

Not logging into the domain is not an option, since I would then be
unable to access anything on the network. We'd have to drop Cygwin if
the resolution was to not login to the domain, I think.
Post by Larry Hall (RFK Partners, Inc)
But start with these checks
Post by l***@cisra.canon.com.au
and make sure something here doesn't signal the problem.
Actually, the mismatching ids are fine - this is what mkpasswd generates
for domain users. This might, however, be the reason why this is
failing... Is your home directory on a network drive, by any chance?
I've had some permission troubles with samba drives and cygwin...
No, it's a local hard disc that's FAT32.
Post by Larry Hall (RFK Partners, Inc)
What's the output of 'id' for you, by the way?
Igor
It looks fine to me:

$ vi .profile # Check that I still can't write .profile from vi
$ ls -l .profile .xinitrc
-rwxr-xr-x 1 luke Domain U 4327 Aug 30 10:40 .profile
-rwxr-xr-x 1 luke Domain U 1618 Sep 6 12:13 .xinitrc
$ id
uid=11021(luke) gid=10513(Domain Users) groups=10513(Domain Users)
$ ls -anl .profile .xinitrc
-rwxr-xr-x 1 11021 10513 4327 Aug 30 10:40 .profile
-rwxr-xr-x 1 11021 10513 1618 Sep 6 12:13 .xinitrc
$ grep luke /etc/passwd
luke:unused_by_nt/2000/xp:11021:10513:Luke Kendall,U-CISRA\luke,S-1-5-21-5706737
-76180391-208020174-1021:/home/luke:/bin/bash

Ah, I've resolved it. Behold:

$ ls -d .*
. .bash_profile.old .kshrc .profile~ .viminfo
.. .cvspass .profile .rhosts .vtclrc
.Xresources .epa .profile.bash .sh_history .xinitrc
.bash_history .exrc .profile.mks .ssh
$ attrib | grep '\\\.'
H D:\home\luke\.bash_history
H D:\home\luke\.bash_profile.old
H D:\home\luke\.cvspass
H D:\home\luke\.epa
H D:\home\luke\.exrc
H D:\home\luke\.kshrc
A H D:\home\luke\.profile
H D:\home\luke\.profile.bash
H D:\home\luke\.profile.mks
H D:\home\luke\.profile~
H D:\home\luke\.rhosts
H D:\home\luke\.sh_history
H D:\home\luke\.viminfo
H D:\home\luke\.vtclrc
H D:\home\luke\.Xresources
D:\home\luke\.xinitrc

And in particular:

$ vi .Xresources # Verify that I can't write it.
$ attrib .Xresources
H D:\home\luke\.Xresources
$ attrib -h .Xresources
$ attrib .Xresources
D:\home\luke\.Xresources
$ vi .Xresources # Check if I can now write it? Yes!

Hidden files are meant to have the same semantics as "." files in Unix,
I thought? If so, then I think it's an error that vi is considering
them to be unwriteable.

The reason for marking such files as hidden is the same as in Unix - to
prevent accidental fiddling.

An interesting question is, why does it seem to be only vi (vim) that
exhibits this behaviour? It's vim 6.1, BTW.

luke


--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
Corinna Vinschen
2002-09-06 07:34:12 UTC
Permalink
Post by l***@cisra.canon.com.au
$ vi .Xresources # Verify that I can't write it.
$ attrib .Xresources
H D:\home\luke\.Xresources
$ attrib -h .Xresources
$ attrib .Xresources
D:\home\luke\.Xresources
$ vi .Xresources # Check if I can now write it? Yes!
Hidden files are meant to have the same semantics as "." files in Unix,
I thought? If so, then I think it's an error that vi is considering
them to be unwriteable.
The reason for marking such files as hidden is the same as in Unix - to
prevent accidental fiddling.
An interesting question is, why does it seem to be only vi (vim) that
exhibits this behaviour? It's vim 6.1, BTW.
I'm using vim 6.1 as well, obviously and changing the hidden attribute
doesn't change the behaviour of vim:

$ vi .cshrc # change, save works
$ attrib +H .cshrc
$ vi .cshrc # change, save works
$ attrib -H .cshrc
$ vi .cshrc # change, save works

There's another permission problem somewhere.

Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:***@cygwin.com
Red Hat, Inc.

--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
Loading...