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

# rb.env

> Read and set environment variables, and find the user's home, data and download folders.

`rb.env` reads and sets environment variables and returns the paths of the
user's known folders. A script reaches for it to read a value from the
environment, hand a variable to a program it starts through `rb.system`, or pick
a start location for a dialog.

**Needs:** the `exec` [permission](https://docs.rebind.gg/reference/sdk/modeline.md#permissions) for
`set`.

This script picks the downloads folder, falling back to the home and temporary
directories, and reads the user name from the environment:

```luau theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
-- rebind: min_sdk=3.9.0 name=example version=1.0.0
local folder = rb.env.downloads() or rb.env.home() or rb.env.temp()
print("start folder:", folder)

local user = rb.env.get("USERNAME") or rb.env.get("USER")
if user == nil then
  print("the environment names no user")
else
  print("running as", user)
end
```

| Signature | Returns |
| - | - |
| `rb.env.get(name: string) -> string?` | the variable, or `nil` |
| `rb.env.set(name: string, value: string) -> ()` | |
| `rb.env.home() -> string?` | home directory |
| `rb.env.config() -> string?` | user config directory |
| `rb.env.data() -> string?` | user data directory |
| `rb.env.desktop() -> string?` | |
| `rb.env.documents() -> string?` | |
| `rb.env.downloads() -> string?` | |
| `rb.env.appdata() -> string?` | the same directory as `data` |
| `rb.env.temp() -> string?` | the temporary directory; never `nil` |

`rb.env.set` changes the environment of the whole Rebind process: every running
script sees it, and so does any process started later through `rb.system`, until
Rebind exits.

The folder paths lie outside the `rb.file` sandbox; use them for dialog start
locations, not `rb.file` calls.


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