Install SilverBullet on Linux with Deno

This is a simple guide on how to install SilverBullet on a Linux based environment using deno and configure it to start at boot.

Requirements:

  • Deno

Deno, can be installed in many ways.
I personally prefer using cargo, the Rust package manager.

If you don’t have rust, you can follow the instructions here which requires just 1 or 2 steps:

  1. Run the command curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  2. If the above command didn’t manage to add ~/.cargo/bin to your $PATH environment variable, you’ll have to add it manually

You can check your $PATH variable by running:

$ echo $PATH

Once, you have rust and cargo available in your environment, you can proceed to install deno

$ cargo install deno --locked

After the installation, check that ~/.deno/bin has been added to your $PATH environment variable

Install SilverBullet

Follow the official instructions located here

  1. Run the following command
$  deno install -f --name silverbullet  --unstable-kv --unstable-worker-options -A https://get.silverbullet.md

silverbullet should be installed under ~/.deno/bin/

At this stage you can test that SilverBullet is working as expected by running
(let’s assume that your space is located in ~/silverbullet

$ silverbullet ~/silverbullet

How to run at boot with systemd (–user)

NOTE Stop silverbullet if you tested it in the previous step

NOTE: replace user with your real username in the commands below

  • Add ~/.local/bin to your $PATH environment variable

  • Create /home/user/.local/bin/silverbullet.sh file:

#!/bin/bash
## Script to start SilverBullet through Deno

/home/user/.cargo/bin/deno run --allow-all --no-config --unstable-kv --unstable-worker-options --reload https://get.silverbullet.md /home/user/silverbullet > /home/user/silverbullet.log 2> /home/user/silverbullet.err

This script will start SilverBullet, through the systemd service we will create below.
It will also create silverbullet.log and silverbullet.err files in your home directory for debugging.

NOTE
If you don’t care about log files, you can remove that part of the command:

/home/user/.cargo/bin/deno run --allow-all --no-config --unstable-kv --unstable-worker-options --reload https://get.silverbullet.md /home/user/silverbullet

NOTE
If you’d like to run the edge version instead, you can modify the command like below:

/home/user/.cargo/bin/deno run --allow-all --no-config --unstable-kv --unstable-worker-options --reload https://edge.silverbullet.md/silverbullet.js /home/user/silverbullet > /home/user/silverbullet.log 2> /home/user/silverbullet.err

NOTE

If you’d like to start your service in --sync-only mode, you can modify the command like below:

/home/user/.cargo/bin/deno run --allow-all --no-config --unstable-kv --unstable-worker-options --reload https://get.silverbullet.md --sync-only /home/user/silverbullet > /home/user/silverbullet.log 2> /home/user/silverbullet.err

  • Create ~/.config/systemd/user/silverbullet.service file:
[Unit]
Description=SilverBullet

[Service]
Type=simple
ExecStart=/home/user/.local/bin/silverbullet.sh

[Install]
WantedBy=default.target
  • Execute the following commands to enable and start the new silverbullet service
$ systemctl --user enable silverbullet.service
$ systemctl --user start silverbullet.service

At this point you can test that silverbullet is running by going to http://localhost:3000 (or 127.0.0.1)

NOTE: sb.log and sb.err files are located in /home/user

How to upgrade SilverBullet

  • First stop the silverbullet service
$ systemctl --user stop silverbullet.service
  • Run the upgrade
$ silverbullet upgrade
  • Re enable the service
$ systemctl --user start silverbullet.service
2 Likes

Nice! Why do you prefer installing Deno with cargo? Doesn’t that have to do a full compilation? Or does it download binaries?

Just personal preference, and probably not for the best reasons :sweat_smile:

Yes, it has a huge downside that it has to compile each time it updates, and I have to say that deno is the most intensive binary I have within the cargo environment.

The upsides for me:

  • Standardization: I got into rust and cargo a few months back and now i have more than 40 applications that I use daily installed this way

  • Simplification: One of my most loved applications is topgrade, which, as it description says, it upgrades all the things.
    I run topgrade daily and it upgrades everything that I have installed through apt, cargo, docker, flatpack, etc… deno being one of them.
    If i install things separately as binaries, I’ll have to maintain them manually.
    Like this, my system is up-to-date all the time.