7
2
I'm trying to change the home directory for Cygwin on a computer at work. Our home directories mapped to a network share by default. This seems to cause some confusion for Cygwin, as it created a directory on my desktop that follows the same path as the network share would, some other prefix based on where I open cygwin from.
If I open Cygwin from the default shortcut created on installation:
$ echo $HOME
/cygdrive/c/Users/shaun/Desktop/SERVER/USERS:USERS/SHAUN
If I open Cygwin from PowerShell:
$ echo $HOME
/usr/bin/SERVER/USERS:USERS/SHAUN
I would rather have my home directory in a local programs directory I set up for managing programs myself. Like this:
/cygdrive/c/users/shaun/apps/cygwin/home/shaun
The preferred way to do this, as recommended by cygwin, is to make an entry in /etc/nsswitch.conf
. This looks like it should do it:
db_home: unix /%H/Apps/cygwin/home/shaun
Any changes I have made to this file seemed to be ignored. I restart the terminal, and even when I intentionally mess up the syntax I get no errors. Some of the options I tried in and have failed:
db_home: /cygdrive/c/users/shaun/apps/cygwin/home/shaun
db_home: /%H/Apps/cygwin/home/shaun
db_home: unix /%H/Apps/cygwin/home/shaun
db_home: cygwin desc
db_home: cygwin /path /%H/Apps/cygwin/home/shaun
I restarted the Cygwin process after each attempt. I also tried changing the db_shell
option to /bin/sh
just as an experiment, but the shell did not change.
Past questions in StackExchange have suggested changing the /etc/passwd
file, I was able to get this to work only after commenting out a block of code in /etc/profile
that was automatically creating the HOME directory. And then, after some time it went back to the old HOME.
Is there something I'm missing about the /etc/nsswitch.conf
file? It seems like it would be a simple and convenient way to set up custom configurations. The alternatives seem like they're outdated hacks that are not recommended by Cygwin, but if I'm wrong please let me know which method is preferred.
My current /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# This file is read once by the first process in a Cygwin process tree.
# To pick up changes, restart all Cygwin processes. For a description
# see https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-mapping-nsswitch
#
# Defaults:
# passwd: files db
# group: files db
# db_enum: cache builtin
# db_home: /home/%U
db_home: /cygdrive/c/users/shaun/apps/cygwin/home/shaun
# db_shell: /bin/bash
# db_gecos: <empty>
Please [edit] your question to include the complete contents of
/etc/nsswitch.conf
– DavidPostill – 2015-07-20T15:16:15.713Do you have a cygwin server running? Or any cygwin processes running as wndows services? If so you need to restart all of those if you change nsswitch.conf. – DavidPostill – 2015-07-20T15:20:15.053
As per note in the docs " The /etc/nsswitch.conf file is read exactly once by the first process of a Cygwin process tree. If there was no /etc/nsswitch.conf file when this first process started, then no other process in the running Cygwin process tree will try to read the file.
If you create or change /etc/nsswitch.conf, you have to restart all Cygwin processes that need to see the change. If the process you want to see the change is a child of another process, you need to restart all of that process's parents, too." – DavidPostill – 2015-07-20T15:20:19.170
@DavidPostill I've restarted the terminal and checked for any running services. Just now I restarted my machine to be sure, and there was no change to the result of the
echo $HOME
command in Cygwin. – Shaun – 2015-07-20T15:42:44.217Then I'm out of ideas :/ I've never run cygwin on a networked PC using a network share for home directories. You might get a quicker answer posting on the cygwin mailing list where the developers and experts hang out. You want the first (Cygwin) mailing list mentioned on https://cygwin.com/lists.html " In general, you should send questions and bug reports here. This is the list for discussion of just about all things related to the Cygwin community release. If you have questions about how to use Cygwin...
– DavidPostill – 2015-07-20T15:49:48.140Please read https://cygwin.com/problems.html first, in particular "Run cygcheck -s -v -r > cygcheck.out and include that file as an attachment in your report. Please do not compress or otherwise encode the output. Just attach it as a straight text file so that it can be easily viewed." If you don't someone will just ask for it ;)
– DavidPostill – 2015-07-20T15:51:44.683Do you set HOME before starting cygwin, in your Windows environment? If so, what's the value? (Win-R cmd: echo %HOME%) – user1274247 – 2015-08-05T12:17:08.897