cygwin でちゃんと HOME の環境変数を設定してるのに ~/.bash_profile が読み込まれなかったのでその時の対処法。

問題点

結局問題だったのは bash を立ち上げた時に出てくるこのエラーメッセージを無視してたのが原因でした。

Your group is currently “mkpasswd”.

This indicates that your gid is not in /etc/group and your uid is not in /etc/passwd.

The /etc/passwd (and possibly /etc/group) files should be rebuilt. See the man pages for mkpasswd and mkgroup then, for example, run

mkpasswd -l [-d] > /etc/passwd

mkgroup -l [-d] > /etc/group

Note that the -d switch is necessary for domain users.

/etc/passwd を確認してみると、確かに今使ってる Windows でのユーザ名が表示されていない。いつも cygwin のフォルダは上書きし続けて使ってるのでインストール時に既に /etc/passwd があった場合に自動更新されないみたいですね。

指示通りに

mkpasswd -l > /etc/passwd<br /> mkgroup -l > /etc/group

すると.bash_profile を読み込むようになりました。

HOME の設定方法

ちなみに HOME の設定方法は

HOME from the Windows environment, translated to POSIX form.

The entry in /etc/passwd

/home/USERNAME

When using Cygwin from the network (telnet, ssh,…), HOME is set from /etc/passwd.

[cygwin FAQ][1]

にあるように

  1. Windows の環境変数 HOME

  2. /etc/passwd にある記述

  3. /home/USERNAME

  4. ただし telnet,ssh とかのネットワーク経由の場合は /etc/passwd が優先される

とのことです。

このとき cygdrive 外のフォルダを指定するには Windows の環境変数に /cygdrive/c/ などから始まる記述を行います。

自分の場合は Dropbox の直下に home フォルダを作り、それを複数環境で共有してるので

/cygdrive/p/dropbox/home と HOME に設定しています。

参考

Dropbox » Webservice を使っていこう

http://webservice.ironsand.net/category/dropbox/