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
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
Install Xcode Command Line Tools and Homebrew:xcode-select --install
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install dependencies:brew install cmake python pkg-config git
brew install fontconfig freetype
Using MSYS2 (Recommended):
- Install MSYS2
- Open MSYS2 MinGW 64-bit terminal
- Install dependencies:
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake
pacman -S mingw-w64-x86_64-python mingw-w64-x86_64-python-pip
pacman -S mingw-w64-x86_64-pkg-config git
Native Windows support is planned. Current installation requires MSYS2 environment.
Quick Install (Recommended)
The easiest way to install Fern is using the automated installation script:
Clone the repository
git clone https://github.com/fernkit/fern.git
cd fern
Run the install script
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
Restart your terminal
After installation, restart your terminal or run:source ~/.bashrc # or ~/.zshrc
Verify installation
Check that Fern is installed correctly: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
Configure with CMake
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/.local ..
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
Create CLI directory
mkdir -p ~/.fern/cli
cp -r cli/* ~/.fern/cli/
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
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 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:
Install Emscripten
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source ./emsdk_env.sh
Add to shell profile
Add to ~/.bashrc or ~/.zshrc:source "$HOME/emsdk/emsdk_env.sh"
Build for web
fern fire --web
# or
./build.sh web
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:
Install Node.js 16+
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
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
Configure VS Code (optional)
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
X11 libraries not found (Linux)
Install X11 development packages:# Ubuntu/Debian
sudo apt-get install libx11-dev
# Fedora/RHEL
sudo dnf install libX11-devel
# Arch
sudo pacman -S libx11
Fontconfig/Freetype errors
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.