简体   繁体   English

更改 Cygwin 主文件夹时遇到问题

[英]Trouble with changing Cygwin home folder

I'm trying to change my Cygwin home folder.我正在尝试更改我的 Cygwin 主文件夹。 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%完成所有这些后,我的主目录更改为/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 .我希望主目录更改为C:\\Users\\Myname
  2. %USERPROFILE is not a directory that I can see anywhere, so I have no idea what it is. %USERPROFILE不是我可以在任何地方看到的目录,所以我不知道它是什么。
  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.更改了主目录后,Cygwin 不再自动读取 .bashrc 文件,因为它位于/home/myname或其他位置,而且我不知道应该在哪里添加 .bashrc 文件才能看到它。

Could someone explain this?有人可以解释一下吗?

It's %USERPROFILE% , not %USERPROFILES% ;它是%USERPROFILE% ,而不是%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 .请检查cmd.exe A command echo %HOME% should print命令echo %HOME%应该打印

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 ./etc/fstab /home上挂载C:\\Users 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.您是否想要posix=0noacl取决于您。 They disable the attempts of cygwin to simulate unix permissions using ACLs.他们禁止 cygwin 尝试使用 ACL 模拟 unix 权限。 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.由于您希望您的用户配置文件和 cygwin 主目录一致,我想您将 cygwin 和本机应用程序混合使用,并且由 cygwin 生成的访问控制列表通常会使情况复杂化。

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 .我有同样的问题,我相信这是因为%USERPROFILE%被定义为User 变量而不是System variable

I therefore defined HOME = %USERPROFILE% as a User variable and it worked.因此,我将HOME = %USERPROFILE%定义为 User 变量并且它起作用了。

Right now I am not 100% sure if there are any other impact in putting HOME in User variables, but so far so good.现在我不能 100% 确定将HOME放在用户变量中是否有任何其他影响,但到目前为止一切顺利。 :) :)

I was having a similar problem on a brand new Cygwin installation.我在全新的 Cygwin 安装上遇到了类似的问题。 I was getting the following error when launching Cygwin.启动 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.我确定此错误来自设置HOME目录的/etc/profile脚本。 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%" .在阅读了@Jan-Hudac 对 Windows HOME环境变量定义的评论后,其中%USERPROFILE%不应有引号,我检查了 Windows 中的HOME用户环境变量,发现它被定义为"%USERPROFILE%" I removed the quotes and the Cygwin shell started correctly in the correct home directory.我删除了引号,Cygwin shell 在正确的主目录中正确启动。 Thanks for the insights!感谢您的见解!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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