Platform:

Building Pulsar

If you want to investigate a bug, implement a new feature in Pulsar’s core, or just tinker, you’ll need to build and run Pulsar from source.

The Pulsar application code can be found in the pulsar-edit/pulsar repository.

Requirements and dependencies

To build Pulsar you will need to meet some basic requirements:

For OS- or distribution-specific instructions, see below:

On Linux, certain libraries must be installed in order to build Pulsar:

  • Standard packages for compiling code (gcc, make, etc.) — often available bundled into their own package
  • libsecret development headers (for storage of secrets)
  • libx11 and various libraries relating to XKB (so that Pulsar can detect and handle keyboard layouts in X11)
  • libwayland (so that Pulsar can detect and handle keyboard layouts in Wayland)

Listed below are the specific packages believed to be necessary for various distributions. If any of these are wrong or insufficient, please open an issue so we can keep these instructions accurate.

Ubuntu/Debian

# Install development packages
apt install build-essential libsecret-1-dev libx11-dev libxkbfile-dev libxkbcommon-dev libxkbcommon-x11-dev libxkbcommon0 xkb-data libwayland-dev libwayland-client0 python3-setuptools pkg-config

Fedora/RHEL

# Install development packages
dnf --assumeyes install make gcc gcc-c++ glibc-devel git-core libsecret-devel rpmdevtools libX11-devel libxkbfile-devel libxkbcommon-devel nss atk gdk-pixbuf2 gtk3 mesa-dri-drivers wayland-devel libwayland-client

Arch

# Install development packges
pacman -S base-devel libxkbfile libsecret libx11 libxcrypt-compat libxkbcommon libxkbcommon-x11 wayland

OpenSUSE

# Install development packages
zypper in -t pattern devel_basis
zypper in libX11-devel libxkbfile-devel libsecret-devel libxkbcommon libxkbcommon-x11-0 libxkbcommon0 libwayland-client0 wayland

macOS installations must have the components described on the Installing dependencies for some community packages page.

You can run xcode-select --install to setup these build tools if you think they’re not already present. You do not need a full installation of Xcode.

Install all of the components described on the Installing dependencies for some community packages page.

In particular, you must have either Visual Studio or Build Tools for Visual Studio (Visual Studio Code isn’t the same thing!) and the “Desktop development with C++” and “Windows 10 SDK” components must be enabled.

If you don’t have either one installed and you want to get set up quickly, install Visual Studio Tools as directed in the instructions above.

Building and running the application

Check out the code

First, check out the source to a directory of your choosing.

git clone https://github.com/pulsar-edit/pulsar.git && cd pulsar

Pick the right Node version and ensure Yarn is present

Switch to the correct version of Node for the project; if you’re running nvm, this should be as simple as nvm install (which will install the version of Node specified in specified in pulsar/.nvmrc, or else use it if it’s already installed). Then, in order to get yarn, you’ll need to run corepack enable.

nvm install # Or the equivalent for your version manager
corepack enable

You’ll only need to run corepack enable the first time for a given version of Node.

Certain tool version managers might require a “reshim” step here; for instance, if you’re using asdf, you should run asdf reshim to ensure it creates a shim executable for yarn.

Initialize the submodules

Run the following to initialize and update the submodules:

git submodule init && git submodule update

Build the dependencies

For reasons mainly having to do with dependency resolution, we use yarn rather than npm for installing dependencies.

Here’s how to install the dependencies for Pulsar and ppm:

yarn install
yarn build
yarn build:apm

Depending on which option you choose below, ppm might need additional configuration.

Option 1: yarn start

Here your options diverge; you can choose the one that fits your style of development best.

The first option is to run the start task; it’ll spawn a debug copy of Pulsar by invoking the electron binary directly. Logging information will go into your terminal.

yarn start

Option 2: ATOM_DEV_RESOURCE_PATH

If you have Pulsar installed already, you don’t have to build your own copy just to run it from source. Instead, do this:

  1. Ensure no instance of Pulsar is currently running.
  2. Set the ATOM_DEV_RESOURCE_PATH environment variable to the full path of where the Pulsar source code exists on disk.
  3. Launch Pulsar with the --dev flag so that dev mode is enabled.

The exact method of doing so varies by platform, but on macOS/Linux you could do:

ATOM_DEV_RESOURCE_PATH=/path/to/pulsar pulsar --dev .

direnv is a handy way of associating certain environment variables with certain working directories and might make this workflow even easier.

Option 3: Build binaries

The first two options are great for iterating on changes to the Pulsar source code, but they don’t actually build the app as a standalone binary. For that you need the build script, invoked via yarn dist.

The build script will detect your OS and build the right binary for it; it’ll also automatically build for your system’s CPU architecture. For example, building on an x86_64 CPU will produce binaries for x86_64, and building on arm64 will only produce binaries for arm64. After running you will find your built application in pulsar/binaries.

Running yarn dist will attempt to create all four variants: tar.gz (suitable for most Linux distributions), AppImage (suitable for most Linux distributions and more self-contained than the tar.gz), deb (for Debian or Ubuntu based distributions), and rpm (for Red Hat or Fedora based distributions) binaries.

yarn dist will create a .dmg and a .zip. These are nearly identical in practice.

As noted above, the build will be targeted to the system’s CPU architecture. On an Intel Mac this will create Intel binaries; on Apple silicon (M1, M2, etc.) this will create Apple Silicon binaries.

By default, running yarn dist will attempt to create an NSIS installer as well as a “portable” executable which does not require installation.