Skip to main content

Installation

Get Fern up and running on your system with the Terra CLI and C++ library. This guide covers installation for Linux, macOS, and Windows.

Prerequisites

Before installing Fern, ensure you have the following tools:
Required Dependencies:
  • C++17 or later compiler (g++, clang++, or MSVC)
  • CMake 3.10+
  • Python 3.x and pip3
  • pkg-config
  • Git

Platform-Specific Requirements

Ubuntu/Debian:
sudo apt-get update
sudo apt-get install build-essential cmake python3 python3-pip pkg-config git
sudo apt-get install libx11-dev libfontconfig1-dev libfreetype6-dev
Fedora/RHEL:
sudo dnf install gcc-c++ cmake python3 python3-pip pkgconfig git
sudo dnf install libX11-devel fontconfig-devel freetype-devel
Arch Linux:
sudo pacman -S base-devel cmake python python-pip pkg-config git
sudo pacman -S libx11 fontconfig freetype2
The easiest way to install Fern is using the automated installation script:
1

Clone the repository

git clone https://github.com/fernkit/fern.git
cd fern
2

Run the install script

./install.sh
This script will:
  • Check all dependencies
  • Install the Terra CLI to ~/.fern/cli
  • Build and install the C++ library to ~/.local
  • Install Fern source files for web builds
  • Set up global templates and configuration
  • Install the Gleeb LSP server (optional)
  • Add CLI commands to your PATH
3

Restart your terminal

After installation, restart your terminal or run:
source ~/.bashrc  # or ~/.zshrc
4

Verify installation

Check that Fern is installed correctly:
fern bloom
You should see a health check output confirming your installation.

Manual Installation

If you prefer to install components manually or need more control:

1. Install the C++ Library

1

Configure with CMake

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/.local ..
2

Build the library

make -j$(nproc)
3

Install

make install
This installs:
  • Headers to ~/.local/include/fern/
  • Library to ~/.local/lib/libfern.a
  • CMake config to ~/.local/lib/cmake/Fern/
  • pkg-config file to ~/.local/lib/pkgconfig/fern.pc

2. Install Terra CLI

1

Create CLI directory

mkdir -p ~/.fern/cli
cp -r cli/* ~/.fern/cli/
2

Create launcher script

mkdir -p ~/.local/bin
cat > ~/.local/bin/fern << 'EOF'
#!/bin/bash
CLI_DIR="$HOME/.fern/cli"
export ORIGINAL_CWD="$(pwd)"
python3 "$CLI_DIR/terra_cli.py" "$@"
EOF
chmod +x ~/.local/bin/fern
3

Add to PATH

Add to your ~/.bashrc or ~/.zshrc:
export PATH="$HOME/.local/bin:$PATH"
Then reload:
source ~/.bashrc  # or ~/.zshrc

3. Set Up Templates and Configuration

mkdir -p ~/.fern/templates
cp -r cli/templates/* ~/.fern/templates/
Create ~/.fern/config.yaml:
version: "0.1.0"
cpp_library_path: "$HOME/.local"
templates_path: "$HOME/.fern/templates"
default_template: "basic"
build:
  default_flags: ["-std=c++17", "-O2"]
  debug_flags: ["-std=c++17", "-g", "-O0"]
  include_paths: ["$HOME/.local/include"]
  library_paths: ["$HOME/.local/lib"]
  libraries: ["fern", "X11", "Xext", "fontconfig", "freetype"]

Building from Source (Alternative Method)

You can also build Fern projects directly without the CLI using the build script:
./build.sh linux

Build Script Options

  • Platforms: linux, web, all
  • Flags:
    • -d, --debug: Build in debug mode
    • -c, --clean: Clean build directory first
    • -v, --verbose: Verbose output
    • -h, --help: Show help

Web Development Setup

To build Fern apps for the web, install Emscripten:
1

Install Emscripten

git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
2

Add to shell profile

Add to ~/.bashrc or ~/.zshrc:
source "$HOME/emsdk/emsdk_env.sh"
3

Build for web

fern fire --web
# or
./build.sh web
4

Serve locally

cd build/web
python3 -m http.server 8000
Open http://localhost:8000 in your browser.

LSP Server Setup (Optional)

Install the Gleeb LSP server for enhanced editor support:
1

Install Node.js 16+

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
2

Install Gleeb LSP

If using the install script, this is done automatically. Otherwise:
mkdir -p ~/.fern/gleeb
# Clone or copy Gleeb LSP to ~/.fern/gleeb
cd ~/.fern/gleeb
npm install
npm run build
3

Configure VS Code (optional)

gleeb-configure-vscode

Verify Installation

Run these commands to verify everything is working:
# Check Fern CLI
fern bloom

# List available commands
fern --help

# Check compiler
g++ --version

# Check CMake
cmake --version

# Check pkg-config can find Fern
pkg-config --cflags --libs fern

CLI Commands

Once installed, you have access to these commands:
  • fern bloom - Check system health
  • fern sprout - Create new project
  • fern fire - Run project (build and execute)
  • fern prepare - Build project
  • fern templates - Manage templates
  • fern lsp start - Start LSP server
  • fern lsp stop - Stop LSP server
  • fern lsp config - Configure editor
  • fern lsp status - Check LSP status

Troubleshooting

Ensure ~/.local/bin is in your PATH:
echo $PATH | grep -q "$HOME/.local/bin" || echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Install X11 development packages:
# Ubuntu/Debian
sudo apt-get install libx11-dev
# Fedora/RHEL
sudo dnf install libX11-devel
# Arch
sudo pacman -S libx11
Install font libraries:
# Ubuntu/Debian
sudo apt-get install libfontconfig1-dev libfreetype6-dev
# Fedora/RHEL
sudo dnf install fontconfig-devel freetype-devel
# macOS
brew install fontconfig freetype
Update CMake:
# Using pip
pip3 install --upgrade cmake
# Or download from cmake.org
Make sure you’ve activated Emscripten:
source ~/emsdk/emsdk_env.sh

Next Steps

Quick Start Tutorial

Build your first Fern app in minutes

Widget System

Explore the comprehensive widget library
Pro Tip: Run fern bloom after installation to verify all dependencies and get a health report of your setup.

Build docs developers (and LLMs) love