Skip to content

Commit 761a196

Browse files
docs: document issue with direnv and nix-shell on macOS (#15990) (#16015)
- @paulroub's contribution to `CONTRIBUTING.md` adds a workaround and a link to the direnv issue - some editing to the format/layout of the doc --------- Co-authored-by: Paul Roub <paul@roub.net>
1 parent cee3656 commit 761a196

File tree

1 file changed

+63
-38
lines changed

1 file changed

+63
-38
lines changed

docs/CONTRIBUTING.md

Lines changed: 63 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,61 @@
22

33
## Requirements
44

5-
We recommend using the [Nix](https://nix.dev/) package manager as it makes any
6-
pain related to maintaining dependency versions
7-
[disappear](https://nixos.org/guides/how-nix-works). Once nix
8-
[has been installed](https://nixos.org/download.html) the development
9-
environment can be _manually instantiated_ through the `nix-shell` command:
5+
<div class="tabs">
106

11-
```shell
12-
cd ~/code/coder
7+
We recommend that you use [Nix](https://nix.dev/) package manager to
8+
[maintain dependency versions](https://nixos.org/guides/how-nix-works).
139

14-
# https://nix.dev/tutorials/declarative-and-reproducible-developer-environments
15-
nix-shell
10+
### Nix
1611

17-
...
18-
copying path '/nix/store/3ms6cs5210n8vfb5a7jkdvzrzdagqzbp-iana-etc-20210225' from 'https://cache.nixos.org'...
19-
copying path '/nix/store/dxg5aijpyy36clz05wjsyk90gqcdzbam-iana-etc-20220520' from 'https://cache.nixos.org'...
20-
copying path '/nix/store/v2gvj8whv241nj4lzha3flq8pnllcmvv-ignore-5.2.0.tgz' from 'https://cache.nixos.org'...
21-
...
22-
```
12+
1. [Install Nix](https://nix.dev/install-nix#install-nix)
2313

24-
If [direnv](https://direnv.net/) is installed and the
25-
[hooks are configured](https://direnv.net/docs/hook.html) then the development
26-
environment can be _automatically instantiated_ by creating the following
27-
`.envrc`, thus removing the need to run `nix-shell` by hand!
14+
1. After you've installed Nix, instantiate the development with the `nix-shell`
15+
command:
2816

29-
```shell
30-
cd ~/code/coder
31-
echo "use nix" >.envrc
32-
direnv allow
33-
```
17+
```shell
18+
cd ~/code/coder
3419

35-
Now, whenever you enter the project folder,
36-
[`direnv`](https://direnv.net/docs/hook.html) will prepare the environment for
37-
you:
20+
# https://nix.dev/tutorials/declarative-and-reproducible-developer-environments
21+
nix-shell
3822

39-
```shell
40-
cd ~/code/coder
23+
...
24+
copying path '/nix/store/3ms6cs5210n8vfb5a7jkdvzrzdagqzbp-iana-etc-20210225' from 'https:// cache.nixos.org'...
25+
copying path '/nix/store/dxg5aijpyy36clz05wjsyk90gqcdzbam-iana-etc-20220520' from 'https:// cache.nixos.org'...
26+
copying path '/nix/store/v2gvj8whv241nj4lzha3flq8pnllcmvv-ignore-5.2.0.tgz' from 'https://cache. nixos.org'...
27+
...
28+
```
4129

42-
direnv: loading ~/code/coder/.envrc
43-
direnv: using nix
44-
direnv: export +AR +AS +CC +CONFIG_SHELL +CXX +HOST_PATH +IN_NIX_SHELL +LD +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_BUILD_CORES +NIX_BUILD_TOP +NIX_CC +NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_INDENT_MAKE +NIX_LDFLAGS +NIX_STORE +NM +NODE_PATH +OBJCOPY +OBJDUMP +RANLIB +READELF +SIZE +SOURCE_DATE_EPOCH +STRINGS +STRIP +TEMP +TEMPDIR +TMP +TMPDIR +XDG_DATA_DIRS +buildInputs +buildPhase +builder +cmakeFlags +configureFlags +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsHostHostPropagated +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +mesonFlags +name +nativeBuildInputs +out +outputs +patches +phases +propagatedBuildInputs +propagatedNativeBuildInputs +shell +shellHook +stdenv +strictDeps +system ~PATH
30+
1. Optional: If you have [direnv](https://direnv.net/) installed with
31+
[hooks configured](https://direnv.net/docs/hook.html), you can add `use nix`
32+
to `.envrc` to automatically instantiate the development environment:
4533

46-
🎉
47-
```
34+
```shell
35+
cd ~/code/coder
36+
echo "use nix" >.envrc
37+
direnv allow
38+
```
39+
40+
Now, whenever you enter the project folder,
41+
[`direnv`](https://direnv.net/docs/hook.html) will prepare the environment
42+
for you:
43+
44+
```shell
45+
cd ~/code/coder
46+
47+
direnv: loading ~/code/coder/.envrc
48+
direnv: using nix
49+
direnv: export +AR +AS +CC +CONFIG_SHELL +CXX +HOST_PATH +IN_NIX_SHELL +LD +NIX_BINTOOLS +NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_BUILD_CORES +NIX_BUILD_TOP +NIX_CC +NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu +NIX_CFLAGS_COMPILE +NIX_ENFORCE_NO_NATIVE +NIX_HARDENING_ENABLE +NIX_INDENT_MAKE +NIX_LDFLAGS +NIX_STORE +NM +NODE_PATH +OBJCOPY +OBJDUMP +RANLIB +READELF +SIZE +SOURCE_DATE_EPOCH +STRINGS +STRIP +TEMP +TEMPDIR +TMP +TMPDIR +XDG_DATA_DIRS +buildInputs +buildPhase +builder +cmakeFlags +configureFlags +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsHostHostPropagated +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +mesonFlags +name +nativeBuildInputs +out +outputs +patches +phases +propagatedBuildInputs +propagatedNativeBuildInputs +shell +shellHook +stdenv +strictDeps +system ~PATH
50+
51+
🎉
52+
```
4853

49-
Alternatively if you do not want to use nix then you'll need to install the need
54+
- If you encounter a `creating directory` error on macOS, check the
55+
[troubleshooting](#troubleshooting) section below.
56+
57+
### Without Nix
58+
59+
Alternatively if you do not want to use Nix then you'll need to install the need
5060
the following tools by hand:
5161

5262
- Go 1.18+
@@ -73,7 +83,9 @@ the following tools by hand:
7383
- `pandoc`
7484
- on macOS, run `brew install pandocomatic`
7585

76-
### Development workflow
86+
</div>
87+
88+
## Development workflow
7789

7890
Use the following `make` commands and scripts in development:
7991

@@ -203,8 +215,7 @@ This helps in naming the dump (e.g. `000069` above).
203215

204216
### Documentation
205217

206-
Our style guide for authoring documentation can be found
207-
[here](./contributing/documentation.md).
218+
Visit our [documentation style guide](./contributing/documentation.md).
208219

209220
### Backend
210221

@@ -334,3 +345,17 @@ The
334345
[`release/experimental`](https://github.com/coder/coder/issues?q=sort%3Aupdated-desc+label%3Arelease%2Fexperimental)
335346
label can be used to move the note to the bottom of the release notes under a
336347
separate title.
348+
349+
## Troubleshooting
350+
351+
### Nix on macOS: `error: creating directory`
352+
353+
On macOS, a [direnv bug](https://github.com/direnv/direnv/issues/1345) can cause
354+
`nix-shell` to fail to build or run `coder`. If you encounter
355+
`error: creating directory` when you attempt to run, build, or test, add a
356+
`mkdir` line to your `.envrc`:
357+
358+
```shell
359+
use nix
360+
mkdir -p "$TMPDIR"
361+
```

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy