# Setup a Development Environment

## Quick rundown

LRR is written in Perl on the server-side with the help of the [Mojolicious](http://mojolicious.org) framework, with basic JQuery on the clientside.\
**npm** is used for JavaScript dependency management and basic shortcuts, while **cpanm** is used for Perl dependency management.

As of v.0.5.5, a basic Client API is available for you to write clients that can connect to a LANraragi instance.

## Quick setup

Once you've got a running LANraragi instance, you can basically dive right into the files to modify stuff to your needs. As you need raw access to the files, a native OS install is needed!\
I recommend a Linux or WSL install, as the *morbo* development server only works on Linux.

Said development server can be ran with the `npm run dev-server` command.\
The major difference is that this server will automatically reload when you modify any file within LANraragi. Background worker included!

You'll also probably want to enable **Debug Mode** in the LRR Options, as that will allow you to view debug-tier logs, alongside the raw Mojolicious logs.

## Using MSYS2

The environment for development is **UCRT64**, other have not been tested.

Since Mojolicious and other perl dependencies are not designed to run on Windows they need to be patched. The patches can be found in `tools/build/windows` alongside other utility scripts.

You need to provide a redis-compatible server.

You need Visual Studio 2026 /w *.NET desktop development* and *Desktop development with C++* workloads installed as part of the compatibility code is written in C# and compiled with Native AOT. This is a hard dependency and can't be skipped.

To setup an environment that can be used for development you need to do the following steps:

1. Update the environment with the `pacman -Syu` command.
2. cd into the LRR directory.
3. Run the script for installing native dependencies `./tools/build/windows/install-deps.sh`
4. Restart the environment (close and open the shell).
5. Run the script for installing perl dependencies `./tools/build/windows/install.sh`

Finally you can launch LRR with the `perl ./script/launcher.pl -d -v ./script/lanraragi` command.

There is no support for hot-reload, multithreading/multiprocess or a dev server. The only supported Mojo server is Daemon, this applies to development or production installs.

### UTF-8 support

If you have issues with path names getting mangled you need to patch perl to enable support for UTF-8. A recent Windows SDK is required for the patching tools.

1. Open a Visual Studio developer console.
2. cd into `<msys install dir>\ucrt64\bin`.
3. Run the `mt.exe -manifest <lrr dir>\tools\build\windows\perl.exe.manifest "-outputresource:perl.exe;#1"` command.

This will tell perl to use UTF-8 mode and accept any special characters. If you update the environment you might need to patch it again.

## Using Github Codespaces

The LRR Git repository contains [devcontainer.json](https://github.com/Difegue/LANraragi/tree/dev/.devcontainer) configuration for [Codespaces](https://github.com/Difegue/LANraragi/codespaces), so you can easily spin up a development VM using that. Deployment might take some time, as the VM will download all dependencies.

## Using Docker Compose

You can use [Docker Compose](https://docs.docker.com/compose/) for quickly bringing up a LANraragi instance suitable for development. Run `docker compose up -d` inside `tools/build/docker` and hack away!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sugoi.gitbook.io/lanraragi/dev/extending-lanraragi/index.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
