Integrating with Windows Home #289

Closed
nfarrar opened this Issue Apr 12, 2015 · 12 comments

Projects

None yet
@nfarrar
nfarrar commented Apr 12, 2015

Is there a recommended way for integrating babun with my HOME directory on windows? On cygwin (before trying out babun) I would set my home directoy to my windows home directory using:

mkpasswd -l -p "$(cygpath -H)" > /etc/passwd

Which was nice - it eliminated having multiple "homes" and file confusion.

As a work around (with babun), I'm currently just symlinking folders into babun's home:

ln -s /cygdrive/c/Users/nfarrar/Documents ~/Documents
ln -s /cygdrive/c/Users/nfarrar/Music ~/Music
ln -s /cygdrive/c/Users/nfarrar/Pictures ~/Pictures
ln -s /cygdrive/c/Users/nfarrar/Videos ~/Videos

This works, but I'd prefer to avoid having 'multiple homes' to keep things more straight forward.

@nfarrar nfarrar changed the title from Integrating with Home Folder to Integrating with Windows Home Apr 12, 2015
@kubamarchwicki
Contributor

According to some tweets, setting HOME env variable upfront does the magic. See the twitter conversation: https://twitter.com/lukaseder/status/585800784786370560

- close babun
- set HOME env
- start babun (don't be shocked by the theme)
- execute babun install
- restart babun
@nfarrar
nfarrar commented Apr 14, 2015

Thank you @kubamarchwicki. Worked perfectly. Easy as pie.

  1. Add HOME to windows environment variables:
    • Windows Key
    • Type (in search): env
    • Select Edit environment variables for your account
    • . Select New
      • Name: HOME
      • Value: C:\Users\nfarrar
  2. Launch babun
  3. Type: babun install
  4. Restart babun

Appears that babun itself is still installed to $HOME/.babun but is now using C:\Users\nfarrar as $HOME (desired behavior) and as an added bonus, babun install moved my user files/configuration from C:\Users\nfarrar\.babun\ to C:\Users\nfarrar. Very awesome. Thank you!

@nfarrar
nfarrar commented Apr 20, 2015

Thought I'd update this thread in case anyone else reads this. The instructions above are just a bit incomplete - if you change your HOME using the environment variable, you're original $HOME remains intact (it isn't actually moved).

So, when I discovered my old $HOME still existed, I moved it - and suddenly ssh stopped working. This is because your home directory is also configured in /etc/passwd - and several applications (including ssh) will use this value, rather than the value of $HOME (so even though I'm starting up in C:\Users\nfarrar, ssh was still using the key from /home/nfarrar/.ssh.

To resolve this, update the path to your home in /etc/passwd as well with the command mkpasswd -l -p $(cygpath -H) > /etc/passwd. Now it appears I'm actually fixed. :)

@nfarrar nfarrar closed this Apr 20, 2015
@toddpi314

+1 - Thanks @nfarrar

@bobkocisko

One thing I would like to add: Following the instructions from @nfarrar (thanks!) I lost zsh after running mkpasswd; it defaulted to bash. So rather than running mkpasswd, I recommend editing your /etc/passwd file and editing the one line for your user name, to replace the home directory with the new one you want. I found that then I didn't lose zsh.

@webcaetano

@nfarrar thanks

@Velvorn
Velvorn commented Jan 27, 2016

Thanks @nfarrar and @bobkocisko!

@AndySw
AndySw commented Feb 12, 2016

Hi guys - I would highly recommend putting the same warning that you get when installing Babun regarding the HOME variable not being fully supported on the website. This process is not without risk and I ended up reinstalling Babun and picking through my Windows home directory deleting left over files - not fun!

:)

@saikatm
saikatm commented Aug 8, 2016

@nfarrar i was having problem after setting environment path to HOME . after some just landed here and tried this commend mkpasswd -l -p "$(cygpath -H)" > /etc/passwd that just helped me, thanks!

@jckegelman

Hi guys. Thanks @nfarrar for the helpful instructions. I experienced some file permission problems even after issuing the suggested mkpasswd command and came upon this document that recommends against using /etc/passwd and /etc/group in favor of /etc/nsswitch.conf starting with Cygwin 1.7.34.

To resolve the issues I was having, I backed up my existing /etc/passwd and /etc/group files, just in case

mv /etc/passwd /etc/passwd.old
mv /etc/group /etc/group.old

Then I created a blank /etc/passwd file (required to pass babun check - see /usr/local/etc/babun/source/babun-core/tools/check.sh

touch /etc/passwd

To keep zsh as the shell on startup, add the following line to /etc/nsswitch.conf (default is bash)

db_shell: /bin/zsh

After that, everything seems to be working. Thanks!

@batandwa
batandwa commented Nov 4, 2016

Thanks guys your suggestions worked. @kubamarchwicki's suggestion to change the HOME variable helped a bit but lead to #683.
I then tried the mkpasswd approach mentioned by @nfarrar.
All seems fine now.

@hedgehog

I think mapping ~ to $USERPROFILE is most easily done as follows:

{ ~ }  » mount -f "$USERPROFILE" ~                                                           
{ ~ }  » mount -m > /etc/fstab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment