2026-04-10 23:27:55 +02:00
---
layout: page
published: true
2026-04-11 00:18:36 +02:00
noToc: false
2026-04-10 23:27:55 +02:00
noComments: false
noDate: false
2026-06-12 18:45:22 +02:00
title: Troubleshooting Guide
2026-04-10 23:27:55 +02:00
subtitle: Common issues and quick fixes for build, includes, and REPL usage.
description: Common issues and quick fixes for build, includes, and REPL usage.
permalink: /documentation/troubleshooting/
lang: en
tags:
2026-04-11 00:18:36 +02:00
- build
- common
- fixes
- includes
- issues
- quick
- troubleshooting
2026-04-10 23:27:55 +02:00
---
2026-02-11 17:34:24 +01:00
This page lists common issues when building and running Fun from a source checkout and how to fix them quickly.
## Includes cannot be found
Error example:
2026-04-15 01:25:17 +02:00
<pre>Include error: cannot read '<io/console.fun>'</pre>
2026-02-11 17:34:24 +01:00
Fix:
2026-04-15 01:25:17 +02:00
2026-02-11 17:34:24 +01:00
- When running from the repository without installing, set `FUN_LIB_DIR` to the local `./lib` directory so angle‑ bracket includes resolve correctly.
Linux/macOS/BSD:
2026-04-11 02:38:47 +02:00
<pre>export FUN_LIB_DIR="$(pwd)/lib"
2026-04-15 01:25:17 +02:00
./build/fun examples/include_lib.fun</pre>
2026-02-11 17:34:24 +01:00
Windows (PowerShell):
2026-04-11 02:38:47 +02:00
<pre>$env:FUN_LIB_DIR = "$PWD/lib"
2026-04-15 01:25:17 +02:00
./build/fun.exe .\examples\include_lib.fun</pre>
2026-02-11 17:34:24 +01:00
If `FUN_LIB_DIR` is not set, the interpreter tries a compile‑ time `DEFAULT_LIB_DIR` , and finally falls back to `./lib` relative to the current working directory. Be mindful of where you run the `fun` binary from.
See includes.md for more details.
## REPL does not start
Symptoms:
2026-04-15 01:25:17 +02:00
2026-02-11 17:34:24 +01:00
- Running the executable just exits, or `--repl-on-error` is not recognized.
Fix:
- Build with `-DFUN_WITH_REPL=ON` and rebuild the `fun` target. Then launch without arguments:
2026-04-11 02:38:47 +02:00
<pre>cmake -S . -B build -DFUN_WITH_REPL=ON
2026-02-19 14:05:14 +01:00
cmake --build build --target fun
2026-04-15 01:25:17 +02:00
FUN_LIB_DIR="$(pwd)/lib" ./build/fun</pre>
2026-02-11 17:34:24 +01:00
See repl.md for usage tips and features.
## Linker errors for optional libraries (JSON, PCRE2, CURL, SQLite, etc.)
Symptoms:
- Build fails when enabling an optional feature.
Fix:
- Ensure the development packages for the chosen library are installed (headers + libs).
- Toggle features individually with `-DFUN_WITH_JSON=ON` , `-DFUN_WITH_PCRE2=ON` , etc., and verify your system provides them.
## Bytecode or opcode mismatch errors after refactors
Symptoms:
- Crashes or incorrect behavior after editing src/vm or src/bytecode.h.
Fix:
- Rebuild cleanly to ensure all amalgamated C units are recompiled.
- Verify opcode_names[] in src/vm.h matches enum ordering in src/bytecode.h.
- Re-run with `--trace` and (optionally) `--dump-bytecode` to inspect control flow.
## Paths differ when running from IDE vs. shell
Symptoms:
- Includes resolve in one environment but not the other; `./lib` fallback behaves differently.
Fix:
- Always set `FUN_LIB_DIR` explicitly in the run configuration of your IDE and in your shell session.
- Confirm the working directory of the launch configuration; relative includes use `$PWD` .
## Windows-specific quoting issues
Symptoms:
- Setting environment variables has no effect; include paths remain unresolved.
Fix:
2026-02-11 17:55:04 +01:00
- In CMD use: `set FUN_LIB_DIR=%CD%\lib && build\fun.exe examples\include_lib.fun`
2026-02-11 17:34:24 +01:00
- In PowerShell use: `$env:FUN_LIB_DIR = "$PWD\lib"; .\build\fun.exe .\examples\include_lib.fun`
## Getting help
- Run the interpreter with `--help` to see supported flags.
2026-04-10 23:27:55 +02:00
- Explore documentation/handbook.md and documentation/repl.md.
2026-02-11 17:55:04 +01:00
- Check the examples under `examples/` for an interactive tour.