How to use Joplin desktop app on FreeBSD


This is a quick note on how I build and use the latest Joplin desktop app on FreeBSD.

For my initial exploration of Joplin on FreeBSD, please refer to the previous post.

Target Version

The current target version of this article is Joplin Electron release v1.0.201 (Apr 2020).
I confirmed that the app could be built using my fork at the tag freebsd-20200421. Joplin Version

Building Joplin

I take the following steps to build Joplin desktop on my FreeBSD 12.1-RELEASE system (with XFCE4 desktop).

  1. Install dependencies such as Electron and Nodejs.
    Now all dependencies can be installed from the FreeBSD’s official packages.

    sudo pkg install electron7 node12 npm-node12 python vips git rsync
    

    NOTE
    To use the latest electron7 package, you might have to switch the package repository from ‘quarterly’ to ‘latest’ to install electron7.
    Please refer to the relevant section of the FreeBSD Handbook.

    NOTE
    (2020/5/13 Update) It turned out not to be the 7.2.2’s fault.
    When the electron7 port was upgrade from 7.1.x to 7.2.2, the sqlite3 native module was not rebuilt and Joplin couldn’t find a file in ElectronClient/node_modules/sqlite3/lib/binding/electron-v7.2-freebsd-x64 directory.
    Rebuilding Joplin after deleting ElectronClient/node_modules/sqlite3 directory solved the problem.

    (2020/5/2) The recent update of the electron7 port to 7.2.2 seems to cause trouble.
    Im my environment, Joplin doesn’t start correctly with the version.
    I’m not sure what the cause is but if you have the same trouble, please try 7.1.14 on the pre-release repository. If your system has currently 7.1.x, you can run pkg lock electron7 to lock its version.

    Then I created symbolic links for compatibility.

    cd /usr/local/bin
    sudo ln -s electron7 electron
    cd /usr/local/share
    sudo ln -s electron7 electron
    
  2. Clone my forked version of Joplin and switch to electron_freebsd branch, which includes some modifications for FreeBSD.

    cd ~/tmp/or/somewhere
    git clone https://github.com/genneko/joplin.git
    cd joplin
    git checkout electron_freebsd
    

    NOTE
    If the head of the branch cannot be built (it occurs from time to time), please try the tagged version which I confirmed to be built.
    As of 21 April 2020, the latest confirmed tag is freebsd-20200421 and it can be checked out as follows:

    git checkout freebsd-20200421
    
  3. Build the desktop (Electron) application by mostly following the original build instruction.

    npm install
    cd ElectronClient
    npm run build
    

    I use npm run build instead of npm run start because it looks like the latter doesn’t expect I’m using the globally installed electron.

  4. Now you can run the app by running the following command

    electron .
    

    or by running a script included in my fork

    ./joplin-desktop
    

Workaround for LSEP showing up in CJK input methods

NOTE: This is not FreeBSD-specific. But anyway, I wrote it down here for future reference.

This issue was reported several times as below.

As pointed out in the issue #1500, it looks like unfixable as it might be an Ace Editor issue.
But for users who have to use some “input method” for entering text, it is really annoying.

Joplin LSEP

Fortunately, this issue can be worked around by using a special font which has only a single zero-width glyph for the weird character (U+2028 Line Separator).

References

Revision History


  1. Before the Joplin-wide stylesheet was implemented in v1.0.176, I had been using a small patch to make “Editor font family” accept multiple fonts separated by comma, just for this purpose. ↩︎

  2. The menu creates and edits ~/.config/joplin-desktop/userchrome.css. ↩︎

  3. As NoLSEP font is used only for this specific purpose, I didn’t want to install it in the system-wide directory such as /usr/local/share/fonts/TTF. So I put it under my home directory and defined @font-face rule to use it. ↩︎