Skip to content
Luna
Esc
↑↓navigate↵open⌘Jpreview
On this page

luna env

Create, list, select and delete the environments of a project.

luna env makes and deletes a project’s environments, and chooses the one the current folder uses.

luna env create dev

Reference

luna env <COMMAND>

Every subcommand takes these options.

Option Type Default Does
--dir <DIR> path . The app’s folder. Its env file names the project and environment.
--project <PROJECT> text LUNA_PROJECT The project, by name or as organisation/project.
--token <TOKEN> text LUNA_TOKEN, then your login An API token or account key to act with.

luna env list

Lists the project’s environments with their version, URL and added tenants. The one this folder uses is marked with *.

luna env list [OPTIONS]
Option Type Default Does
--json flag Off Prints the answer as JSON.

luna env create

Makes an environment, and this folder then uses it.

luna env create [OPTIONS] <NAME>
Option Type Default Does
<NAME> text Required The new environment’s name: lowercase letters, digits and single dashes, starting and ending with a letter or digit.
--from <FROM> text None Copies code and settings from this environment. Secrets are never copied.
--data flag Off With --from, also copies its lunas’ data as it is now.
--no-wait flag Off With --data, returns without waiting for the copy to finish.
--expires-in <LENGTH> length None Deletes the environment by itself after this long, such as 90m, 12h or 7d, or a number of seconds.
--json flag Off Prints Luna’s answer as JSON.

Without --from, the environment starts empty. The environment --from names must have been deployed to. With --data, Luna does the copying, and the CLI prints its progress until it is done. Stopping the CLI does not stop the copy, and luna env list shows when it is there.

luna env use

Makes this folder use an environment of its project.

luna env use [OPTIONS] <NAME>
Option Type Default Does
<NAME> text Required The environment, by name.

It writes LUNA_PROJECT and LUNA_ENV to .env.local. Once the environment has been deployed to, it also writes LUNA_URL and LUNA_KEY, the environment’s URL and a publishable key that any origin may use. When the environment has no such key, one is made.

When the app’s package.json uses Next.js, Vite or Expo, the URL and key are also written as NEXT_PUBLIC_LUNA_URL, VITE_LUNA_URL or EXPO_PUBLIC_LUNA_URL, with a matching _LUNA_KEY.

luna env delete

Deletes an environment, with all its data, keys and secrets.

luna env delete [OPTIONS] <NAME>
Option Type Default Does
<NAME> text Required The environment. Never production, which is deleted with its project.
--yes flag Off Deletes it without asking first.

When the folder uses the deleted environment, the CLI takes it out of .env.local.

Good to know

  • luna env is also luna environments.
  • Every project starts with a production environment.
  • luna deploy and luna env use both refuse a name the project has no environment for.

Examples

Make your own environment

luna env create dev-ann

Copy production, with its data, for a pull request

luna env create pr-42 --from production --data --expires-in 7d

Switch this folder to staging

luna env use staging

Delete an environment from a script

luna env delete pr-42 --yes

Was this page helpful?