Installing Doom Emacs on Windows
Tags: emacs, doomemacs, installemacs
Published: 2021-06-27 05:27:41

You heard about something called Emacs and a couple of searches later you decided that you were going to try Doom Emacs for the first time, but… Oh, No — Most of the guides show how to make the installation just on Linux— So you think, where do I begin?

If this is your case, let me show you how I install Doom Emacs on Windows.

## Previous Requiriments

- [Git](https://git-scm.com/downloads)
- [Ripgrep](https://github.com/BurntSushi/ripgrep/releases) → Download the  windows-gnu  version → Unzip the content to a safe directory.
- [fd](https://github.com/sharkdp/fd/releases) → Download the  windows-gnu  version → Unzip the content to a safe directory.

## Installing Emacs (Vanilla)

To get Emacs on Windows, you have two mainly options. Through MSYS2 or with an Emacs executable (.exe).

The way that I recommend if you don't have a lot of experience working with Unix/Linux is to directly download the executable from a [nearby GNU mirror](https://www.gnu.org/software/emacs/download.html) and install it like an another program in windows.

If you are a MSYS2 user, in MSYS2 you have to use the follow command:

```powershell
$ pacman -S mingw-w64-x86_64-emacs
```

_Emacs GUI will be at  C:\msys64\mingw64\bin\runemacs.exe_

### Creating an Emacs Files Backup (Optional)

If you installed emacs using the executable, in  HOME  directory rename the `.emacs.d` or if you are using MSYS2 the configuration files are in  `C:/Users/Scarlett/AppData/Roaming/`

Renaming the .emacs.d directory:

```powershell
$ mv .\.emacs.d\ .\.emacs.d.old
```

## Set Environment Variables

Go to Settings → System → About → Advanced System Settings → Advanced → Environment Variables…

1. On `User Variables` section→ Click on New button… → Set HOME to the variable name and set your path user `C:\Users\USERNAME` to variable value → Finally click on OK

![set user dir in env variables](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7adeb4mgg889zi6rai7e.png)

2. Also, on User Variables → Select Path Variable and click on Edit button →  
    * Add `C:\msys64\mingw64\bin (MSYS2)` or `C:\ProgramFiles\Emacs\x86_64\bin (Executable)`
    * Add your `C:\path\to\the\ripgrep` directory
    * Add your `C:\path\to\the\fd` directory

![Emacs in the environment variables](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iauj21msenjd49wfyacu.png)

> Note: You don’t need to restart the system but the console (MSYS2, git bash, powershell…)

## Installing Doom Emacs

At this point we should have a vanilla Emacs running correctly in our system, so in the next steps we are going to do a clean installation of Doom Emacs, also I will show you how to do that with both kind of Emacs installation that we have been seeing.    

### If you installed Emacs with the executable (.exe)

Open PowerShell or gitbash.exe to install Doom. Make sure that you are in your user directory, then clone doom:

```powershell
$ git clone https://github.com/hlissner/doom-emacs .emacs.d
$ ~/.emacs.d/bin/doom install
```

> Note: If the powershell or gitbash prompt: _fatal: destination path 'C:/Users/Scarlett/.emacs.d' already exists and is not an empty directory._ 
> We need to remove the `.emacs.d` directory

Once the installation is done, we need to ensure that the necessary packages are installed:
```powershell
$ ~/.emacs.d/bin/doom sync
```

### If you installed Emacs with MSYS2

Inside the `C:/Users/your user/AppData/Roaming/` directory, clone and install doom:

```powershell
$ git clone https://github.com/hlissner/doom-emacs .emacs.d
$ .emacs.d/bin/doom install
```

Once the installation is done, we need to ensure that the necessary packages are installed:

```powershell
$ .emacs.d/bin/doom sync
```

Now you can start Emacs executing the `emacs` command, and it will display vanilla Emacs:

```powershell
$ emacs
```

As you can see, apparently the doom installation is not working, however, we need to take one more step:

We have to remove the `.emacs.d` directory created when we ran Emacs:

```powershell
$ rm C:\Users\USER\.emacs.d\
```

We need to create a symbolic link. For that, run **cmd** as administrator and execute the following command (remember change ‘USER’ on the path):

```powershell
$ mklink /j "C:\Users\USER\.emacs.d" "C:\Users\USER\AppData\Roaming\.emacs.d"
```

## Installing the Icons

Finally, if you don’t see the icons, you will need to install them, in Emacs type M-x (Alt + x) and write the following:

```powershell
all-the-icons-install-fonts
```

Go to the folder where you downloaded the fonts and install manually all the files.

![my doom emacs on windows](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/05186vjb3991xe415dga.png)


As you can see, there are more than one way to install Doom Emacs on Windows. If you know others, share in the comments for everyone!

> **I hope this post has allowed you to start exploring the Emacs world.**
> Thanks For Reading, Follow Me For More