Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

links not created on WSL2 #222

Closed
latipun7 opened this issue May 29, 2020 · 2 comments
Closed

links not created on WSL2 #222

latipun7 opened this issue May 29, 2020 · 2 comments
Labels

Comments

@latipun7
Copy link

latipun7 commented May 29, 2020

I run Ubuntu 20.04 on Windows Subsystem Linux 2 (WSL2).

I have install.conf.yaml like this:

- clean: ["~", "~/.config"]

- defaults:
    link:
      create: true
      relink: true
      force: true

- link:
    ~/.ansi-arts:
    ~/.bin: linux/bin
    ~/.config/neofetch: linux/neofetch
    ~/.gitconfig: linux/git/linux.gitconfig
    ~/.oh-my-zsh-custom: linux/oh-my-zsh
    ~/.p10k.zsh: linux/zsh/p10k.zsh
    ~/.zshrc: linux/zsh/zshrc.zsh
    ~/Brewfile: linux/linuxbrew/Brewfile

- create: [~/projects, ~/downloads]

- shell:
    - [git submodule sync --recursive, Synchronize the URLs of submodules]
    - [git submodule update --init --recursive, Update the submodules]

My dotfiles folder in /mnt/e/Projects/dotfiles.
When I run

cd /mnt/e/Projects/dotfiles
sudo ./install

it run without error with this logs:

[sudo] password for latipun7:
Link /root/Brewfile -> /mnt/e/Projects/dotfiles/linux/linuxbrew/Brewfile not removed.
Link /root/.gitconfig -> /mnt/e/Projects/dotfiles/linux/git/linux.gitconfig not removed.
Link /root/.bin -> /mnt/e/Projects/dotfiles/linux/bin not removed.
Link /root/.zshrc -> /mnt/e/Projects/dotfiles/linux/zsh/zshrc.zsh not removed.
Link /root/.p10k.zsh -> /mnt/e/Projects/dotfiles/linux/zsh/p10k.zsh not removed.
Link /root/.oh-my-zsh-custom -> /mnt/e/Projects/dotfiles/linux/oh-my-zsh not removed.
Link /root/.ansi-arts -> /mnt/e/Projects/dotfiles/ansi-arts not removed.
Link /root/.config/neofetch -> /mnt/e/Projects/dotfiles/linux/neofetch not removed.
All targets have been cleaned
Removing ~/.ansi-arts
Creating link ~/.ansi-arts -> /e/Projects/dotfiles/ansi-arts
Removing ~/.bin
Creating link ~/.bin -> /e/Projects/dotfiles/linux/bin
Removing ~/.config/neofetch
Creating link ~/.config/neofetch -> /e/Projects/dotfiles/linux/neofetch
Removing ~/.oh-my-zsh-custom
Creating link ~/.oh-my-zsh-custom -> /e/Projects/dotfiles/linux/oh-my-zsh
Removing ~/.p10k.zsh
Creating link ~/.p10k.zsh -> /e/Projects/dotfiles/linux/zsh/p10k.zsh
Removing ~/.zshrc
Creating link ~/.zshrc -> /e/Projects/dotfiles/linux/zsh/zshrc.zsh
Removing ~/Brewfile
Creating link ~/Brewfile -> /e/Projects/dotfiles/linux/linuxbrew/Brewfile
Removing ~/.gitconfig
Creating link ~/.gitconfig -> /e/Projects/dotfiles/linux/git/linux.gitconfig
All links have been set up
Path exists /root/projects
Path exists /root/downloads
All paths have been set up
Synchronize the URLs of submodules [git submodule sync --recursive]
Update the submodules [git submodule update --init --recursive]
All commands have been executed

==> All tasks executed successfully

But when I want to see the configuration with cat ~/.gitconfig, the file didn't exist. Then, when I list the directory of my home, all those files didn't exist. ls -la ~:

total 64
drwxr-xr-x 7 latipun7 latipun7 4096 May 28 23:15 .
drwxr-xr-x 3 root     root     4096 May 28 20:15 ..
-rw------- 1 latipun7 latipun7 2108 May 29 05:51 .bash_history
-rw-r--r-- 1 latipun7 latipun7  220 May 28 20:15 .bash_logout
-rw-r--r-- 1 latipun7 latipun7 3771 May 28 20:15 .bashrc
drwxr-xr-x 2 latipun7 latipun7 4096 May 28 20:15 .landscape
-rw-r--r-- 1 latipun7 latipun7    0 May 29 05:49 .motd_shown
-rw-r--r-- 1 latipun7 latipun7  807 May 28 20:15 .profile
-rw------- 1 latipun7 latipun7    5 May 28 22:07 .python_history
drwxr-xr-x 3 latipun7 latipun7 4096 May 28 22:22 .quokka
-rw-r--r-- 1 latipun7 latipun7    0 May 28 20:34 .sudo_as_admin_successful
drwxr-xr-x 5 latipun7 latipun7 4096 May 28 21:43 .vscode-server
drwxr-xr-x 2 latipun7 latipun7 4096 May 28 21:49 .vsliveshare
-rw-r--r-- 1 latipun7 latipun7   58 May 28 21:49 .wakatime.cfg
-rw-r--r-- 1 latipun7 latipun7 4096 May 28 23:15 .wakatime.db
-rw-r--r-- 1 latipun7 latipun7    0 May 28 22:22 .wakatime.log
drwxr-xr-x 2 latipun7 latipun7 4096 May 28 22:22 .wallaby
-rw-r--r-- 1 latipun7 latipun7  183 May 28 21:43 .wget-hsts

Notice, the directories of projects and downloads not created too in $HOME. By looking on that logs, it seems link and create are messing on /root/ instead of $HOME.

I use sudo ./install because just like in #125 , I have configuration that modify in /etc/ and need sudo, so I add the following lines on install script:

if [[ "$(uname -a)" = *[M,m]icrosoft* ]]; then
  cp --remove-destination "$BASEDIR/linux/wsl/wsl.conf" /etc/wsl.conf
fi

Please tell me if you want more information.
Thank you.

@anishathalye
Copy link
Owner

When the script is run with sudo, it's run as the root user. The root user's $HOME is in /root on your machine, so that's why the symlinks are going there. If you want to use Dotbot to put links in /etc or other locations only writable by root, you could use this approach of having two separate YAML configs, and having separate install scripts, so you can run ./install to set up the regular symlinks, and then run sudo ./install-sudo to run the stuff that must be done as root.

@latipun7
Copy link
Author

As a workaround, yeah, I run without sudo, but I add this line in install.conf.yaml at shell directive:

- shell:
    - [git submodule sync --recursive, Synchronize the URLs of submodules]
    - [git submodule update --init --recursive, Update the submodules]
    - [
        '[[ "$(uname -a)" = *[M,m]icrosoft* ]] && sudo cp --remove-destination "linux/wsl/wsl.conf" /etc/wsl.conf',
        Force re-copy wsl configs,
      ]

and remove my additional lines on install.

Well, its work. Thanks to this #125 (comment)

And I could use that workaround you pointed out too.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants