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.

1 Like

Thanks for the guide, especially the systemd part!

When I setup systemd, it didnt work because I dont use the default user to run silverbullet. When trying to enabling the service, it would say
“Failed to connect to bus: No medium found”

This can be fixed by setting up the systemd service from an account where systemctl is working using this command:
systemctl --user -M silverbullet-user@ enable silverbullet.service
systemctl --user -M silverbullet-user@ start silverbullet.service
Where silverbullet-user is the username of the user used for silverbullet.

2 Likes

Thanks for the guide.

I’ve been using this method for several months with Deno on FreeBSD and it works very well.

Excepted that I can’t start silverbullet with Deno by adding the new options just implemented in 0.10.4

  • SB_LOCKOUT_LIMIT
  • SB_LOCKOUT_TIMEOUT
  • SB_AUTH_TOKEN

For instance :

deno run --allow-all --no-config --unstable-kv --unstable-worker-options --reload ${silverbullet_script_url} --user ${application_user}:${application_pass} --lockout-time ${silverbullet_lockout_time} --lockout-limit 3 ${silverbullet_notes_path}

Doesn’t want to start SB :frowning:

But :

deno run --allow-all --no-config --unstable-kv --unstable-worker-options --reload ${silverbullet_script_url} --user ${application_user}:${application_pass} ${silverbullet_notes_path}

Works perfectly.

Any idea how to pass the new args with Deno runtime ?

Thanks

Try

deno run --allow-all --no-config --unstable-kv --unstable-worker-options --reload ${silverbullet_script_url} --user ${application_user}:${application_pass} ${silverbullet_notes_path} -- --lockout-time ${silverbullet_lockout_time} --lockout-limit 3 

This worked for me, I tested it without variables though:

deno run --allow-all --no-config --unstable-kv --unstable-worker-options --reload https://edge.silverbullet.md/silverbullet.js  --port 3001 ~/silver/ -- --lockout-time 300 --lockout-lim
it 3

Many thanks it worked !

I don’t know why we have to use this double “- -” with theses new args but it works now ! :partying_face:

-- separates the options intended for the deno run command itself from the arguments that are passed to silverbullet

Thank you so much for mentioning Topgrade. I run Void Linux and Topgrade configured itself on my first run after installing it with xbps-install. I did make a few changes to the toml configuration file but it is an incredible tool. A one stop update package. I love ii!! :grinning:

1 Like

When installing a local version of silverbullet:

$ deno install -f --name silverbullet  --unstable-kv --unstable-worker-options -A https://get.silverbullet.md

I get this error:

error: the following required arguments were not provided:
  --global

Note: Permission flags can only be used in a global setting

Any ideas whats going on? If it helps I’m running Arch Linux.

This guide is slightly outdate, but the answer is basically in the error, you need to add the --global flag. This should work:

deno install -f --global --name silverbullet  --unstable-kv --unstable-worker-options -A https://get.silverbullet.md
2 Likes

Perfect, thanks, got a “:white_check_mark: Successfully installed silverbullet” message:)

1 Like