简体   繁体   中英

Trouble with changing Cygwin home folder

I'm trying to change my Cygwin home folder. To do this I followed Christopher's answer here , but I'm having some trouble with the instructions given there.

After doing all of this my home directory was changed to /cygdrive/c/Windows/system32/%USERPROFILE%

There are several things I don't seem to understand:

  1. I expected the home directory to be changed to C:\\Users\\Myname .
  2. %USERPROFILE is not a directory that I can see anywhere, so I have no idea what it is.
  3. Having changed the home directory, Cygwin doesn't read the .bashrc file automatically anymore since it's in /home/myname or whatever and I don't see where I should add the .bashrc file for it to be seen.

Could someone explain this?

It's %USERPROFILE% , not %USERPROFILES% ; make sure you have the correct name. It is a variable reference, so you have to expand it. In the environment variables settings it should be expanded, so if it isn't, you most probably have a typo there.

Please, check in cmd.exe . A command echo %HOME% should print

C:\Users\Myname

(that is the expected home directory). If it does not, the variable is not set correctly and the rest of the instructions won't work.

However there is another way, which I consider easier. Mounting C:\\Users on /home in /etc/fstab . I have entry like:

c:/Users /home ntfs binary,posix=0,user,noacl 0 0

Whether you want posix=0 and noacl is up to you. They disable the attempts of cygwin to simulate unix permissions using ACLs. Since you want your user profile and cygwin home dir to coincide, I suppose you mix cygwin and native applications and the access control lists generated by cygwin often complicate that.

Old question but for future reference:

I had the same issue, and I believe it is because %USERPROFILE% is defined as a User variable rather than as a System variable .

I therefore defined HOME = %USERPROFILE% as a User variable and it worked.

Right now I am not 100% sure if there are any other impact in putting HOME in User variables, but so far so good. :)

I was having a similar problem on a brand new Cygwin installation. I was getting the following error when launching Cygwin.

mkdir: cannot create directory '/cygdrive/c/WINDOWS/system32/"C:': Permission denied
/cygdrive/c/WINDOWS/system32/"C:/Users/[username]" could not be created.
Setting HOME to /tmp.

I determined this error was coming from the /etc/profile script where the HOME directory is set. After reading the comment from @Jan-Hudac on the Windows HOME environment variable definition where %USERPROFILE% should not have quotes around it, I checked the HOME User Environment Variable in Windows and found that it was defined as "%USERPROFILE%" . I removed the quotes and the Cygwin shell started correctly in the correct home directory. Thanks for the insights!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM