Skip to content

Instantly share code, notes, and snippets.

@gabrieljoelc
Last active March 5, 2021 20:14
Show Gist options
  • Save gabrieljoelc/33bbd21bff74d47e5102aff1adf3a160 to your computer and use it in GitHub Desktop.
Save gabrieljoelc/33bbd21bff74d47e5102aff1adf3a160 to your computer and use it in GitHub Desktop.
Gabe's Windows Setup

https://www.howtogeek.com/265900/everything-you-can-do-with-windows-10s-new-bash-shell/

  1. Install "Windows Subsystem on Linux" for
  2. Install Debian instead of Ubuntu because it doesn't include GUI which I'm not going to use
  3. Debian WSL requires Windows build 1083 so you'll need to ensure this is upgraded before it'll work
  4. https://www.howtogeek.com/258518/how-to-use-zsh-or-another-shell-in-windows-10/
  5. Install hyper.is Hyper was pretty slow even in typing responsiveness. I switched to just using the out-of-the-box Debian WSL terminal and tmux for tabs (see tmux section below)
  6. Run the following:
sudo apt update && sudo apt upgrade
sudo apt-get install zsh
sudo apt-get install git
# setup zsh
zsh
# ensure it's the default $SHELL before installing oh my zsh by using change shell command
# it will prompt you and then enter /bin/zsh
chsh
# install curl
sudo apt-get install curl
# install oh my zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Add this to .zshrc for making making vi mode default

# make vi mode default
bindkey -v

vim

Copy in config from here.

gist-vim (and webapi-vim)

Used installation steps here.

ctrlp

Used the installation steps here.

Clipboard

~~I used this post to install vim with buffer to Linux clipboard support. Here's the command (took a while to finish):

sudo apt-get install vim-gnome -y

~~

I used this post to install vim with buffer to Linux clipboard support. Here's the command (took a while to finish):

sudo apt-get install vim-gtk3 -y

Despite seeing the +clipboard and +xterm-clipboard, on a vim --version, It still wasn't working after this. I am looking at these resources:

I tried running this:

sudo apt-get install xclip

But still no dice.

Going to try this next: https://superuser.com/a/1345241/222702.

tmux

sudo apt-get install tmux

Copy in config from here

NPM

  1. Install curl
  2. Download node setup
  3. Install node

SSH

Follow the directions here:

sudo apt update && sudo apt upgrade
sudo apt-get install keychain
cd ~/.ssh
ssh-keygen

Add this to .zshrc:

# For Loading the SSH key
/usr/bin/keychain -q --nogui $HOME/.ssh/id_rsa
source $HOME/.keychain/$HOST-sh

To add the public key to a remote (GitHub):

cat ~/.ssh/id_rsa.pub

Other references

cmder

ssh

See cmderdev/cmder#193 (comment). Use:

start-ssh-agent
ssh-add ~/.ssh/id_rsa

Keyboard layout

# this one is required for things like Azure DevOps repos. It requires
# https://github.com/Microsoft/Git-Credential-Manager-for-Windows to be installed
# (see https://stackoverflow.com/questions/45925964/how-to-use-git-credential-store-on-wsl-ubuntu-on-windows#comment81840814_47350274)
# GIT_WIN_CRED_PATH="/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-wincred.exe"
SSH_AGENT_CMD="/c/tools/ssh-agent-wsl/ssh-agent-wsl -r"
eval "$SSH_AGENT_CMD"

Docker for WSL

Attempt #1

https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly

Ran into:

sudo apt-get update
Ign:1 http://deb.debian.org/debian stretch InRelease
Get:2 http://security.debian.org/debian-security stretch/updates InRelease [94.3 kB]
Get:3 http://deb.debian.org/debian stretch-updates InRelease [91.0 kB]
Get:4 http://prerelease.keybase.io/deb stable InRelease [2,407 B]
Hit:5 http://deb.debian.org/debian stretch Release
Get:6 http://prerelease.keybase.io/deb stable/main amd64 Packages [381 B]
Get:7 https://packages.microsoft.com/repos/azure-cli stretch InRelease [2,812 B]
Hit:8 https://deb.nodesource.com/node_9.x stretch InRelease
Get:9 http://deb.debian.org/debian stretch-updates/main amd64 Packages.diff/Index [4,180 B]
Get:10 http://deb.debian.org/debian stretch-updates/main amd64 Packages 2018-05-05-2031.58.pdiff [329 B]
Get:10 http://deb.debian.org/debian stretch-updates/main amd64 Packages 2018-05-05-2031.58.pdiff [329 B]
Get:11 http://security.debian.org/debian-security stretch/updates/main amd64 Packages [353 kB]
Get:12 http://security.debian.org/debian-security stretch/updates/main Translation-en [165 kB]
Err:7 https://packages.microsoft.com/repos/azure-cli stretch InRelease
  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 123
Fetched 713 kB in 17s (40.8 kB/s)
Reading package lists... Done
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://packages.microsoft.com/repos/azure-cli stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 123
W: Failed to fetch https://packages.microsoft.com/repos/azure-cli/dists/stretch/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
W: Some index files failed to download. They have been ignored, or old ones used instead.

This post told me to run the following and it worked:

➜  ~ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 123

I had apparently installed the Debian stretch Linux distro instead of the Ubuntu one so I had to use these commands instead (I got E: Failed to fetch https://download.docker.com/linux/ubuntu/dists/stretch/stable/binary-amd64/Packages 404 Not Found when I ran the command from the post):

# Add Docker's official GPG key.
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

# Pick the release channel.
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/debian \
   $(lsb_release -cs) \
   ${DOCKER_CHANNEL}"

Attempt #2

Using this again: https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly. Couldn't use the Ubuntu install steps though because I use Debian:

➜ ~ lsb_release -irc
Distributor ID: Debian
Release:        9.5
Codename:       stretch

Followed steps from here:

➜ ~ sudo apt-get update
# ... stuff installing this:
Setting up packagekit (1.1.5-2+deb9u1) ...
invoke-rc.d: could not determine current runlevel
[....] Reloading system message bus config...Failed to open connection to "system" message bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
invoke-rc.d: initscript dbus, action "force-reload" failed.
Failed to open connection to "system" message bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory

Googling the error I found this closed issue and this open issue. Gonna try to just do the rest of the steps.

➜ ~ sudo apt-get install \
>      apt-transport-https \
>      ca-certificates \
>      curl \
>      gnupg2 \
>      software-properties-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
apt-transport-https is already the newest version (1.4.8).
ca-certificates is already the newest version (20161130+nmu1+deb9u1).
curl is already the newest version (7.52.1-5+deb9u8).
gnupg2 is already the newest version (2.1.18-8~deb9u3).
software-properties-common is already the newest version (0.96.20.2-1).
0 upgraded, 0 newly installed, 0 to remove and 37 not upgraded.
➜ ~ curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
OK
➜ ~ sudo apt-key fingerprint 0EBFCD88
pub   rsa4096 2017-02-22 [SCEA]
      9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
uid           [ unknown] Docker Release (CE deb) <[email protected]>
sub   rsa4096 2017-02-22 [S]
➜ ~ git:() sudo add-apt-repository \
>    "deb [arch=amd64] https://download.docker.com/linux/debian \
dquote>    $(lsb_release -cs) \
dquote>    stable"

No output

INSTALL DOCKER CE

  1. Updated ap-get

➜ ~ sudo apt-get install docker-ce

Lots and lots of output.

Didn't do 3. and 4. Did this instead:

➜  ~ docker --version
Docker version 18.09.0, build 4d60db4

Post Debian Docker install

# .oh-my-zsh/custom/docker.zsh
export DOCKER_HOST=tcp://localhost:2375

Windows Key and then typed "about". Under "Windows specifications" I see "Version 1803" which means I have Windows 18.03 (Spring 2018) version which means I can configure WSL to change the mount path to be compatible with docker volumes.

~ sudo vim /etc/wsl.conf
/etc/wsl.conf
[automount]
root = /
options = "metadata"
  1. Restart windows

  2. Open WSL

docker info

Should show that it's running.

  1. It was running...
~ docker info
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
~ docker -H $DOCKER_HOST info
Containers: 2
 Running: 0
 Paused: 0
 Stopped: 2
Images: 0
Server Version: 18.09.1
...

Not sure why. It's like it's not picking up the environment variable when I do docker info without explicitly specifying the hose.

I found this other blog post and everything looked pretty much the same. I decided to try

export DOCKER_HOST='tcp://0.0.0.0:2375'

and it worked!

I restarted and tried adding this:

# ~/.oh-my-zsh/custom/docker.zsh

DOCKER_HOST='tcp://0.0.0.0:2375'

and sourcing ~/.zshrc, but it didn't work. I added:

# ~/.oh-my-zsh/custom/docker.zsh
export DOCKER_HOST='tcp://0.0.0.0:2375'

and it worked again. ¯\(ツ)

I tried doing:

~ docker run -i -t -v $(pwd):/app/ -w /app/ hashicorp/terraform:light init
... image pulling output and then...
docker: image operating system "linux" cannot be used on this platform.

I found this forum post and tried this in PS console:

$Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchLinuxEngine

Gonna try looking through this open issue next time...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment