[CT-3470] [Bug] `dbt deps` fails silently if user has no write perms to project directory
- Dominant language
- Rust
- Stars
- 13.8k
- Forks
- 2.6k
- Avg merge
- 21h 31m
- Merged PRs (30d)
- 56
Description
### Is this a new bug in dbt-core?
- [X] I believe this is a new bug in dbt-core
- [X] I have searched the existing issues, and I could not find an existing issue for this bug
### Current Behavior
In trying to run `dbt deps` within a container, I found that it was failing silently if run in a project directory where I don't have write permissions -- assumedly because it is trying to write to the `package-lock.yml` file and cannot.
### Expected Behavior
Should fail loudly with an error about inability to write to `package-lock.yml` file. Could potentially also offer a CLI option to ignore that / proceed without trying to write to the lock file.
### Steps To Reproduce
1. Create a dbt project directory
2. Switch to a user without write permissions to that directory
3. Within that project directory, run `dbt deps`. This will fail silently.
### Relevant log output
Running from a directory where I do not have write permissions, I get a silent failure:
```shell
$ whoami
flytekit
$ ls -al
total 32
drwxr-xr-x 5 501 dialout 4096 Dec 6 22:16 .
drwx------ 1 flytekit flytekit 4096 Dec 6 22:08 ..
-rw-r--r-- 1 501 dialout 21 Jan 1 1970 README.md
-rw-r--r-- 1 501 dialout 591 Jan 1 1970 dbt_project.yml
drwxr-xr-x 3 501 dialout 4096 Jan 1 1970 models
-rw-r--r-- 1 501 dialout 139 Jan 1 1970 packages.yml
drwxr-xr-x 2 501 dialout 4096 Jan 1 1970 remote_config
drwxr-xr-x 2 501 dialout 4096 Jan 1 1970 seeds
$ dbt deps
$
```
Running from directory with the same contents and with write permissions, I get normal behavior:
```
$ whoami
flytekit
$ ls -al
total 32
drwxr-xr-x 5 flytekit flytekit 4096 Dec 6 22:44 .
drwx------ 1 flytekit flytekit 4096 Dec 6 22:08 ..
-rw-r--r-- 1 flytekit flytekit 21 Dec 6 22:09 README.md
-rw-r--r-- 1 flytekit flytekit 591 Dec 6 22:09 dbt_project.yml
drwxr-xr-x 3 flytekit flytekit 4096 Dec 6 22:09 models
-rw-r--r-- 1 flytekit flytekit 139 Dec 6 22:09 packages.yml
drwxr-xr-x 3 flytekit flytekit 4096 Dec 6 22:09 remote_config
drwxr-xr-x 2 flytekit flytekit 4096 Dec 6 22:09 seeds
$ dbt deps
22:45:43 Running with dbt=1.7.3
22:45:43 Updating lock file in file path: /root/dbt_2/package-lock.yml
22:45:43 Installing dbt-labs/dbt_utils
22:45:44 Installed from version 1.1.1
22:45:44 Up to date!
22:45:44 Installing Snowflake-Labs/dbt_constraints
22:45:44 Installed from version 0.6.2
22:45:44 Up to date!
$
```
### Environment
```markdown
- OS: Linux 61732b189083 6.4.16-linuxkit #1 SMP PREEMPT Thu Nov 16 10:49:20 UTC 2023 x86_64 GNU/Linux
- Python: Python 3.11.4
- dbt: 1.7.3
```
### Which database adapter are you using with dbt?
postgres
### Additional Context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.