Files and environment
localspace keeps all its files in one directory, the localspace home. The files that you edit are in it too. To see the paths on your machine, run lo about.
The localspace home
Section titled “The localspace home”The localspace home is $LOCALSPACE_HOME. When LOCALSPACE_HOME is not set, it is ~/.localspace. localspace makes the directory when it is necessary, and only your user can read it.
The files that you edit are in the home:
| Path | Content |
|---|---|
config.yaml |
The machine settings. The file is optional. |
templates/ |
The templates. Each subdirectory that has a localspace.yaml is a template. The machine setting templates can name other directories. |
The files that localspace makes and manages are in the home too:
| Path | Content |
|---|---|
localspace.db |
The state database (SQLite). It records the workspaces, the sources, the units, the ports and the usage samples. |
worktrees/<workspace>/<repo> |
The worktrees that localspace made for a workspace. The directory of a shared instance is worktrees/shared/<id>/<repo>. |
logs/<workspace>/<unit>.log |
The log of the latest run of a unit. |
logs/<workspace>/history/<unit>/<run>.log |
The log of an earlier run. The name of the file is the start time of the run, such as 20261129T195800Z.log. See the machine setting logs. |
logs/ui.log |
The log of the dashboard server. |
plugins/ |
The installed plugins, as executables with the name lo-plugin-<name>. |
secrets/ |
The secrets of the file secret store: one file for each secret, named by its path. The directory has the mode 0700 and each file has the mode 0600. |
ui.token |
The token of the dashboard. lo ui and the dashboard URL use it. |
ui.json |
The address of the running dashboard server. localspace deletes it when the server stops. |
ca/root.crt |
The certificate of the local certificate authority of the proxy. It signs the HTTPS public URLs. |
proxy/ |
The configuration files of the proxy. |
dns/ |
The files of the DNS server of localspace. |
locks/ |
The lock files that stop two commands from changing one workspace at the same time. |
workspaces/<id>/init/<resource>/ |
The initialization scripts of a postgres instance. <id> is the ID of the workspace in the state database. |
Docker objects that localspace makes have names that start with ls-. A localspace home that is not ~/.localspace has a separate proxy, separate shared servers and separate networks. Their names have a suffix that comes from the path of the home. Two homes on one machine do not stop each other’s containers.
Move from the previous location
Section titled “Move from the previous location”Earlier versions kept config.yaml and templates/ in ~/.config/localspace. When lo starts for the first time after the update, it moves that directory to ~/.localspace. It changes the previous path in config.yaml and in the templates of the workspaces. It tells you about the move one time. The move does not happen when LOCALSPACE_HOME or XDG_CONFIG_HOME has a value.
Environment variables that lo reads
Section titled “Environment variables that lo reads”| Variable | Meaning |
|---|---|
LOCALSPACE_HOME |
The path of the localspace home. It moves config.yaml, templates/ and all the state. The default is ~/.localspace. |
XDG_CONFIG_HOME |
Optional. When it has a value, config.yaml and templates/ are in $XDG_CONFIG_HOME/localspace. The state stays in the home. |
HOME |
The home directory of the user. localspace uses it for ~/ in paths and for the default directories. |
NO_COLOR |
When it has a value, lo writes plain text, and localspace does not set the color variables in services. |
GITHUB_TOKEN, GH_TOKEN |
A token that lo plugin install sends to GitHub. GITHUB_TOKEN has priority. It is necessary to install from a private repository. |
PM2_HOME |
The pm2 directory. The pm2 plugin uses it. The default is ~/.pm2. |
<NAME> |
Any variable that a template reads with ${env:<NAME>}. See references. |
Host processes that localspace starts also get the variables of the lo process. The service env replaces a variable of the same name.
Variables that localspace sets in services
Section titled “Variables that localspace sets in services”localspace builds the environment of a service from the env of the template, the overrides of the workspace and the flags of the run. Then it sets the variables in this table. See references.
| Variable | Value | When |
|---|---|---|
PORT |
The port of the service. It is the port in the container for a container, and the host port for a process. It replaces a PORT of the template. |
The service has a port. |
LOCALSPACE_WORKSPACE |
The name of the workspace. | Always. |
LOCALSPACE_SERVICE |
The name of the service. | Always. |
LOCALSPACE_CA_FILE |
The path of the certificate of the local certificate authority: a host path for a process, /etc/localspace/ca.crt for a container. |
The proxy address is domain and the certificate is present. |
NODE_EXTRA_CA_CERTS |
The same path as LOCALSPACE_CA_FILE. Node adds the certificate to its trusted certificates. The template can set a different value. |
The same as LOCALSPACE_CA_FILE. |
FORCE_COLOR, CLICOLOR_FORCE, PY_COLORS |
1. They make the tools in the service write colors to the log. The service env can set a different value. |
NO_COLOR is not set in lo and not in the env of the service. |
lo env <workspace> <service> prints the resolved environment of a service. It hides the secret values. See lo env.
The runtimes other than Node replace their list of trusted certificates when they read a variable for a certificate file. For this reason, localspace does not set those variables. The service reads LOCALSPACE_CA_FILE and sets them.