DEV Community

Cover image for Installing Doom Emacs on Windows
Scarlett
Scarlett

Posted on • Edited on

Installing Doom Emacs on Windows

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
  • Ripgrep → Download the windows-gnu version → Unzip the content to a safe directory.
  • fd → 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 and install it like an another program in windows.

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



$ pacman -S mingw-w64-x86_64-emacs


Enter fullscreen mode Exit fullscreen mode

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:



$ mv .\.emacs.d\ .\.emacs.d.old


Enter fullscreen mode Exit fullscreen mode

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

  1. 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

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:



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


Enter fullscreen mode Exit fullscreen mode

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:



$ ~/.emacs.d/bin/doom sync


Enter fullscreen mode Exit fullscreen mode

If you installed Emacs with MSYS2

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



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


Enter fullscreen mode Exit fullscreen mode

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



$ .emacs.d/bin/doom sync


Enter fullscreen mode Exit fullscreen mode

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



$ emacs


Enter fullscreen mode Exit fullscreen mode

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:



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


Enter fullscreen mode Exit fullscreen mode

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



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


Enter fullscreen mode Exit fullscreen mode

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:



all-the-icons-install-fonts


Enter fullscreen mode Exit fullscreen mode

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

my doom emacs on windows

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

Top comments (8)

Collapse
 
shivams profile image
shivams

A minor correction I'd like to suggest. When the emacs is installed with the executable (and not msys2), the ".emacs.d" config folder resides in the "C:\Users\Username\AppData\Roaming" folder and not the user home folder. So, the doom commands (like cloning the doom repo), should be run from this folder.

Collapse
 
adrianthomasrs profile image
Adrian

Thanks for this. Will get this setup on my windows machine. I've been wanting to use Doom on the PC for ages now!

Collapse
 
davelg profile image
David Gillooly

I have been using doom on a mac but wanted to use it on win 10 too.

Emacs installed well by using the suggested ".exe" file. My verison is 28.2

  1. Getting doom from git seems to work
    git clone github.com/hlissner/doom-emacs .emacs.d

  2. Issue involves getting the sync done which would hopefully allow emacs to sytart in Doom mode rather than the standard emacs.

I use powershell so tried running .\doom sync as well as doom sync with an error about 'emacs' not being recognized.
.

C:\Users\Admin\doom-emacs\bin> .\doom sync
**'emacs' is not recognized as an internal or external command,
operable program or batch file.
**
PS C:\Users\Admin\doom-emacs\bin>

Enter fullscreen mode Exit fullscreen mode

Not sure what I have done incorrectly.

Do I need to edit the doom script in some way?

Tks...Dave

Collapse
 
leocozzens profile image
Leo Cozzens • Edited

Hello Dave,

To me it appears that your issue is the 'emacs' command is being run by the script and the environment is subsequently unable to recognize it.

The problem is likely that your msys2 directory or whichever directory contains your mingw emacs bin is not contained within your path; The script is structured assuming you have already done this.

Just add

C:\msys64\mingw64\bin 
Enter fullscreen mode Exit fullscreen mode

or wherever your emacs binary is located into your PATH and this script should work as expected.
This can be done through the GUI in "Edit the system environment variables" or done quickly and temporarily in your PS environment by running

$env:Path += ';C:\msys64\mingw64\bin'
Enter fullscreen mode Exit fullscreen mode

(Substitute your actual bin parent dir)

P.S.
You must run

./doom install 
Enter fullscreen mode Exit fullscreen mode

before

./doom sync
Enter fullscreen mode Exit fullscreen mode

Additionally, it would be a good idea to add your doom bin directory to your path so you can also access your doom script options globally at your leisure. The doom emacs wiki also recommends this.

Collapse
 
andersoyvind profile image
Anders Øyvind Urke-Sætre

Minor note, in case someone spots the difference: It's now more common to clone the doom-emacs repo to .config/emacs, thus also having the doom .el files in .config/doom. I'm a noob, so all I know is that removes some clutter in $HOME.

Collapse
 
niftytommy profile image
Tommmy

Thanks.

Collapse
 
junhyk2tw profile image
이준혁 • Edited

Thank you.

Collapse
 
333438576 profile image
333438576

Dunno if things have changed or I missed something, but I had no icons until I installed "nerd-icons-install-fonts"