# 문제 해결

이 페이지는 Nix를 사용할 때 겪을 수 있는 문제를 해결하기 위한 팁을 모아 둔 것입니다.

## 바이너리 캐시가 다운되었거나 접근할 수 없으면 어떻게 해야 합니까?

Nix 명령에 [`--option substitute false`](https://nix.dev/manual/nix/stable/command-ref/conf-file#conf-substitute)를 전달하십시오.

## 바이너리 캐시에 무언가가 있는지 Nix가 강제로 다시 확인하게 하려면 어떻게 해야 합니까?

Nix는 명령을 실행할 때마다 바이너리 캐시에 질의하지 않아도 되도록, 바이너리 캐시에서 무엇을 사용할 수 있는지 추적합니다. 여기에는 부정적인 응답, 즉 주어진 스토어 경로를 대체할 수 없다는 정보도 포함됩니다.

캐시 만료 시간을 초 단위로 설정하려면 [`--narinfo-cache-negative-ttl`](https://nix.dev/manual/nix/stable/command-ref/conf-file.html#conf-narinfo-cache-negative-ttl) 옵션을 전달하십시오.

## 해결 방법: `error: querying path in database: database disk image is malformed`

이는 [알려진 문제](https://github.com/NixOS/nix/issues/1353)입니다. 다음을 시도해 보십시오:

```shell-session
$ sqlite3 /nix/var/nix/db/db.sqlite "pragma integrity_check"
```

이 명령은 [데이터베이스](https://nix.dev/manual/nix/stable/glossary#gloss-nix-database)의 오류를 출력합니다. 오류가 누락된 참조 때문이라면 다음 방법이 효과가 있을 수 있습니다:

```shell-session
$ mv /nix/var/nix/db/db.sqlite /nix/var/nix/db/db.sqlite-bkp
$ sqlite3 /nix/var/nix/db/db.sqlite-bkp ".dump" | sqlite3 /nix/var/nix/db/db.sqlite
```

## 해결 방법: `error: current Nix store schema is version 10, but I only support 7`

이는 [알려진 문제](https://github.com/NixOS/nix/issues/1251)입니다.

이는 새 버전의 Nix를 사용하면서 [데이터베이스](https://nix.dev/manual/nix/stable/glossary#gloss-nix-database)의 SQLite 스키마가 업그레이드되었는데, 그 후 이전 버전의 Nix를 사용하려 했다는 의미입니다.

해결 방법은 데이터베이스를 덤프한 다음, 이전 버전의 Nix로 데이터를 다시 가져오는 것입니다:

```shell-session
$ /path/to/nix/unstable/bin/nix-store --dump-db > /tmp/db.dump
$ mv /nix/var/nix/db /nix/var/nix/db.toonew
$ mkdir /nix/var/nix/db
$ nix-store --load-db < /tmp/db.dump
```

## 해결 방법: `writing to file: Connection reset by peer`

이는 너무 큰 파일이나 디렉터리를 [Nix 스토어](https://nix.dev/manual/nix/stable/glossary#gloss-store)로 가져오려 하고 있거나, 머신의 디스크 공간이나 메모리 같은 리소스가 부족하다는 의미일 수 있습니다.

가져올 디렉터리의 크기를 줄이거나 [가비지 컬렉션](https://nix.dev/manual/nix/stable/command-ref/nix-collect-garbage)을 실행해 보십시오.

## macOS 업데이트로 Nix 설치가 망가지는 경우

이는 [알려진 문제](https://github.com/NixOS/nix/issues/3616)입니다. [Nix 설치 프로그램](https://nix.dev/manual/nix/latest/installation/installing-binary)은 `/etc/zshrc`를 수정합니다. macOS가 업데이트되면 일반적으로 `/etc/zshrc`를 다시 덮어씁니다.

임시 해결책으로, 다음 코드 조각을 `/etc/zshrc`의 끝에 추가하고 셸을 다시 시작하십시오:

```bash
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
  . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
```
