Skip to content

Instantly share code, notes, and snippets.

@ESKYoung
Last active February 26, 2021 10:50
Show Gist options
  • Save ESKYoung/2f7d48c8dab97edf47da19767090e816 to your computer and use it in GitHub Desktop.
Save ESKYoung/2f7d48c8dab97edf47da19767090e816 to your computer and use it in GitHub Desktop.
`govcookiecutter` support for Windows

Windows support

The govcookiecutter project includes useful functionality such as loading secrets as environment variables, but ignoring them from version control. However, some of this functionality is Unix-based, and not supported natively on Windows. This page covers how to configure your Windows system to use this Unix-based functionality in its entirety.

Requirements

⚠️ We have only tested Windows support with the following requirements. Your experience may differ!

Git for Windows setup

If you do not have Git for Windows, following the fresh installs instructions. Otherwise, check the configuration options for your existing install.

Fresh installs

  1. Download Git for Windows on to your machine
  2. In the folder containing the download, double-click on the executable .exe file
    • The file should be called Git-<<<VERSION>>>-64-bit.exe, where <<<VERSION>>> is the version of Git for Windows
  3. Go through all the installation instructions until Step 10 "Configuring extra options", and check the Enable symbolic links checkbox
  4. Continue with the rest of the installation instructions, and finish the installation
  5. Check that symbolic links have been configured, as outlined in the next section

Existing installs

  1. Open the Run dialog box (shortcut: Win + R), and type %PROGRAMDATA%/Git and press the "OK" button
  2. In the File Explorer, you should see a file called config. Open this in your favourite text editor, and check that the symlinks variable is set to true
    • If not, you will need to re-open the config file in your text editor with administrator privileges to change the symlinks value to true

Once complete, you can now set up direnv

Setting up direnv

Once you have set up Git for Windows, you need to download the Windows release of direnv locally, and set up symbolic links to the direnv command.

Download direnv

Go to the direnv releases page, and, for the latest release, download the Windows 64-bit executable; this is usually called direnv.windows-amd64.exe.

For maintainability, create a direnv folder within your Git for Windows installation location, e.g. C:\Program Files\Git\usr\bin\direnv, and move the download there. You may need administrator privileges to do this. Now set up the symbolic link.

Set up direnv symbolic link

  1. Open the Run dialog box (shortcut: Win + R)
  2. Type cmd to open the command prompt
  3. Create a symbolic link so that entering the direnv command runs the direnv.windows-amd64.exe executable file.
    mklink direnv <<<FILEPATH TO direnv.windows-amd64.exe>>>
    where <<FILEPATH TO direnv.windows-amd64.exe>>> is the filepath to the direnv.windows-amd64.exe executable file. Remember, if your filepath contains spaces, you will need to double quote it, for example:
    mklink direnv "C:\Program Files\Git\usr\bin\direnv\direnv.windows-amd64.exe"

Now you can add the direnv hooks to Git for Windows.

Add direnv hooks to git-bash

  1. Open git-bash — in the Start menu this should be listed in the Git folder as "Git Bash"
  2. Create a .bash_profile, and add the direnv hook to it by entering the following command:
    echo 'eval "$(direnv hook bash)"' >> ~/.bash_profile
  3. Restart git-bash by closing it, and opening git-bash again
  4. Check that direnv has been correctly installed by entering direnv:
    direnv
    You should see a list of available direnv commands printed out!

Setting up Make in git-bash

Follow these steps to get Make installed in git-bash:

  1. Go to ezwinports
  2. Download the make-<<<VERSION>>>-without-guile-w32-bin.zip file, where <<<VERSION>>> is the version of the Make port
  3. Unzip the download
  4. Copy all the folders except share
  5. Paste into the mingw64 folder of your Git installation, for example at C:\Program Files\Git\mingw64. Do not overwrite or replace any files, only merge in the folders
  6. Open git-bash, and type make — you should see the following message:
    make: *** No targets specified and no makefile found.  Stop.

To get all the make commands in the Makefile work, you also need to create a symbolic link to the Windows more command:

  1. Open the Run dialog box (shortcut: Win + R)
  2. Type cmd to open the command prompt
  3. Enter the following command:
    mklink more C:\Windows\System32\more.com

You should now be able to run all the make commands within the Makefile.

Other useful instructions

Here are links to other useful instructions for getting this project running on Windows:

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