> ## Documentation Index
> Fetch the complete documentation index at: https://docs.localdev.build/llms.txt
> Use this file to discover all available pages before exploring further.

# Projectfile

> Every Projectfile setting, and how the file is checked

A Projectfile is a YAML file, not too different from Docker Compose. The file can have any name.

A very simple Projectfile looks like this:

```yaml theme={null}
services:
    my_lovely_service:
        command: ./main
```

The location of `./main` is relative to the Projectfile's directory, but the command can be anything.

## Top-level keys

| Key | Required | Purpose |
| - | - | - |
| `services` | yes | The services to run, by name |
| `env` | no | Variables given to every service |
| `store` | no | How much telemetry to keep in memory |
| `collector` | no | Use your own collector |

## `services.<name>`

| Key | Required | Notes |
| - | - | - |
| `command` | yes | What to run |
| `env` | no | Variables for this service; wins over the top-level `env` |

The name is used as `service.name` in telemetry, and in the UI.

### How `command` is run

There is no shell, but arguments are split the way a shell splits them:

* Spaces, tabs and newlines separate arguments. Several in a row count as one.
* `"double"` and `'single'` quotes group words: `./app "hello world"` passes one argument, `hello world`.
* `''` or `""` passes an empty argument.
* A backslash keeps the next character as it is: `./app My\ File`. Inside double quotes, it only
  escapes `"`, `\`, `$` and `` ` ``. Inside single quotes nothing is special.
* Quoted parts join: `--name="a b"` passes `--name=a b`.
* **Shell syntax is refused**, unless quoted: `|`, `&`, `;`, `<`, `>`, `(`, `)`, `$` and `` ` ``. So are
  `$` and `` ` `` inside double quotes, because Localdev doesn't expand variables. The Projectfile doesn't
  load, with, for example,
  `line 3: services.api.command: invalid command: "$" is variable or command substitution, and ldev runs commands without a shell: quote it to pass it as it is, or put the command in a script (or run sh -c '…')`
* Not refused, and passed as they are: globs (`*.txt`) and `~`.
* Need a pipe, `&&`, a redirect or `$VAR`? Put it in a script, or `sh -c '…'`:
  `command: sh -c './main --port $PORT > out.log'`.
* A path with a slash is relative to the Projectfile's directory: `./main`, `bin/server`.
* A bare name is found through `PATH`: `node app.js`, `go run ./cmd/api`.
* The working directory is always the Projectfile's directory, wherever you run `ldev` from.

### What happens when a command can't run

Localdev keeps going. The other services run, and this one shows as **Failed** with the reason:

| Problem | Reason shown |
| - | - |
| No `command`, an empty one, or a service with no settings (`api:`) | `no command configured` |
| File doesn't exist | `could not start ./x: fork/exec ./x: no such file or directory` |
| Not executable | `could not start ./x: fork/exec ./x: permission denied` |

## `env`

```yaml theme={null}
env:
    PORT: 10001      # the service gets "10001"
    DEBUG: true      # "true"
    RATIO: 1.10      # "1.10", exactly as written
    EMPTY:           # empty string
```

* Values are taken as the text in the file.
* A nested value is an error: `services.a.env.N must be a single value`.
* YAML anchors, aliases and merge keys work when reading. The UI can't edit an `env` that uses them.
* Some variables are refused: see [Variables Localdev refuses](https://docs.localdev.build/configuration/environment-variables.md#variables-localdev-refuses).

## `store`

| Key | Default | Maximum |
| - | - | - |
| `logs` | 30,000 | 10,000,000 |
| `metric_points` | 1,000,000 | 100,000,000 |
| `trace_spans` | 50,000 | 10,000,000 |

* Each is optional. Must be a whole number from 1 to the maximum.
* Override order: flag, then environment variable, then Projectfile, then default.
* Read once at start-up. Changing a size needs an `ldev` restart.
* Invalid values and misspelled keys stop start-up:
  * `store.logs must be a whole number between 1 and 10000000`
  * `unknown setting store.log: use logs, metric_points, trace_spans`

## `collector`

| Key | Notes |
| - | - |
| `command` | Your collector binary and arguments. See [Custom collectors](https://docs.localdev.build/custom-collector.md) |
| `receivers.grpc` | Port the collector receives OTLP gRPC on. Default 4998 |
| `receivers.http` | Port the collector receives OTLP HTTP on. Default 4999 |

```yaml theme={null}
collector:
    receivers:
        grpc: 5998
        http: 5999
```

* Ports are on localhost, from 1 to 65535, and must differ.
* Services get `OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:<grpc port>`.
* Together with `-server` and `-collector-address`, this lets two instances of Localdev run at once
  (see the [CLI reference](https://docs.localdev.build/CLI-reference.md)).

## What the Projectfile is checked for

The Projectfile is checked when Localdev starts. Errors include the line number, and Localdev exits with code 1
before running anything. The messages are:

| Problem | Message |
| - | - |
| No `services:` | `the Projectfile has no services section; add one, e.g.` + an example |
| `binaries:` (old name) | `line 1: binaries is now called services; rename it` |
| `services:` as a list | `line 2: services must map each service's name to its settings, not be a list, e.g.` + example |
| `services:` empty | `line 1: services is empty; add at least one service` |
| Unknown top-level key, e.g. `project:` | `line 1: unknown setting project: a Projectfile can have services, env, collector and store (and x-… keys for YAML anchors)` |
| Unknown service key | `line 4: unknown setting services.api.port: services.api can have command and env` |
| Key given twice | `line 4: services.a is already set on line 2` |
| Service name with `/`, or `.`/`..` | `line 2: "../escape" can't be a service name: it can't contain / or be . or ..` |
| `command` as a list | `line 3: services.api.command must be a single line of text, like ./main --port 8080` |
| Port out of range | `line 3: collector.receivers.grpc must be a port number from 1 to 65535` |

Errors are printed as plain text, prefixed with the path given to `ldev`: `ldev: Projectfile: line 2: …`.

### Keys for YAML anchors

Top-level keys starting with `x-` are ignored (as in Docker Compose), so they can hold anchors:

```yaml theme={null}
x-common-env: &common
    LOG_LEVEL: debug
services:
    api:
        command: ./api
        env:
            <<: *common
            PORT: "8080"
```

## Changing the file while Localdev runs

* Localdev doesn't watch the file.
* Service commands and new services need an `ldev` restart.
* **Discard** in the environment editor re-reads the variables from the file. See [Change variables while Localdev runs](https://docs.localdev.build/configuration/environment-variables.md#change-variables-while-localdev-runs).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.