# Automatically sets up your devbox environment whenever you cd into this# directory via our direnv integration:eval "$(devbox generate direnv --print-envrc --env-file .env.devbox)"# check out https://www.jetify.com/docs/devbox/ide-configuration/direnv/# for more details
````

Note that if Devbox cannot find the env file provided to the flag, it will ignore the flag and load
your Devbox shell environment as normal

### Global settings for direnv[​](#global-settings-for-direnv "Direct link to Global settings for direnv")

Note that every time changes are made to `devbox.json` via `devbox add ...`, `devbox rm ...` or
directly editing the file, requires `direnv allow` to run so that `direnv` can setup the new
changes.

Alternatively, a project directory can be whitelisted so that changes will be automatically picked
up by `direnv`. This is done by adding following snippet to direnv config file typically at
`~/.config/direnv/direnv.toml`. You can create the file and directory if it doesn't exist.

```bash theme={null}
[whitelist]prefix = [ "/absolute/path/to/project" ]
```

### Direnv Limitations[​](#direnv-limitations "Direct link to Direnv Limitations")

Direnv works by creating a sub-shell using your `.envrc` file, your `devbox.json`, and other direnv
related files, and then exporting the diff in environment variables into your current shell. This
imposes some limitations on what it can load into your shell:

1. Direnv cannot load shell aliases or shell functions that are sourced in your project's
   `init_hook`. If you want to use direnv and also configure custom aliases, we recommend using
   [Devbox Scripts](/docs/devbox/guides/scripts/).
2. Direnv does not allow modifications to the \$PS1 environment variable. This means `init_hooks`
   that modify your prompt will not work as expected. For more information, see the
   [direnv wiki](https://github.com/direnv/direnv/wiki/PS1)

Note that sourcing aliases, functions, and `$PS1` should work as expected when using `devbox shell`,
`devbox run`, and `devbox services`

### VSCode setup with direnv[​](#vscode-setup-with-direnv "Direct link to VSCode setup with direnv")

To seamlessly integrate VSCode with a direnv environment, follow these steps:

1. Open a terminal window and activate direnv with `direnv allow`.
2. Launch VSCode from the same terminal window using the command `code .` This ensures that VSCode
   inherits the direnv environment.

Alternatively, you can use the
[direnv VSCode extension](https://marketplace.visualstudio.com/items?itemName=mkhl.direnv) if your
VSCode workspace has a .envrc file.

If this guide is missing something, feel free to contribute by opening a
[pull request](https://github.com/jetify-com/devbox/pulls) in Github.

[Edit this page](https://github.com/jetify-com/devbox/tree/main/docs/app/docs/ide-configuration/direnv.md)