Repository: iterative/dvc

Issue:
install: pre-push hook fails when installed with `--use-pre-commit-tool`
# Bug Report

<!--
## Issue name

Issue names must follow the pattern `command: description` where the command is the dvc command that you are trying to run. The description should describe the consequence of the bug.

Example: `repro: doesn't detect input changes`
-->

## Description

On a new, empty repo where `dvc install --use-pre-commit-tool` has been run, the pre-push hook fails with:

```console
DVC pre-push.............................................................Failed
- hook id: dvc-pre-push
- exit code: 255

ERROR: unexpected error - s3 is supported, but requires 'dvc-s3' to be installed: No module named 'dvc_s3'
```

Running `dvc push` directly, or removing the hooks installed by `pre-commit` and using `dvc install`, both work as expected. 

<!--
A clear and concise description of what the bug is.
-->

### Reproduce

1. `dvc init`
2. `dvc remote add -d myremote s3://<bucket>/<key>`
3. `dvc install --use-pre-commit-tool`
4. `pre-commit install --hook-type pre-push --hook-type post-checkout --hook-type pre-commit`
5. Commit any changes to branch
6. `git push origin branchname`

<!--
Step list of how to reproduce the bug
-->

<!--
Example:

1. dvc init
2. Copy dataset.zip to the directory
7. dvc add dataset.zip
8. dvc run -d dataset.zip -o model ./train.sh
9. modify dataset.zip
10. dvc repro
-->

### Expected

`git push` completes successfully. 

<!--
A clear and concise description of what you expect to happen.
-->

### Environment information

<!--
This is required to ensure that we can reproduce the bug.
-->

**Output of `dvc doctor`:**

```console
DVC version: 2.48.0 (brew)
--------------------------
Platform: Python 3.11.2 on macOS-13.2.1-x86_64-i386-64bit
Subprojects:
	dvc_data = 0.42.3
	dvc_objects = 0.21.1
	dvc_render = 0.2.0
	dvc_task = 0.2.0
	scmrepo = 0.1.15
Supports:
	azure (adlfs = 2023.1.0, knack = 0.10.1, azure-identity = 1.12.0),
	gdrive (pydrive2 = 1.15.1),
	gs (gcsfs = 2023.3.0),
	http (aiohttp = 3.8.4, aiohttp-retry = 2.8.3),
	https (aiohttp = 3.8.4, aiohttp-retry = 2.8.3),
	oss (ossfs = 2021.8.0),
	s3 (s3fs = 2023.3.0, boto3 = 1.24.59),
	ssh (sshfs = 2023.1.0),
	webdav (webdav4 = 0.9.8),
	webdavs (webdav4 = 0.9.8),
	webhdfs (fsspec = 2023.3.0)
Cache types: <https://error.dvc.org/no-dvc-cache>
Caches: local
Remotes: s3
Workspace directory: apfs on /dev/disk1s5s1
Repo: dvc, git
Repo.site_cache_dir: /Library/Caches/dvc/repo/9988c90982ca2ee8e3f32c488d733d83
```

**Additional Information (if any):**

Using `pre-commit 3.1.1` installed via `brew install pre-commit`. 

<!--
Please check https://github.com/iterative/dvc/wiki/Debugging-DVC on ways to gather more information regarding the issue.

If applicable, please also provide a `--verbose` output of the command, eg: `dvc add --verbose`.
If the issue is regarding the performance, please attach the profiling information and the benchmark comparisons.
-->



Discussion:
@gtebbutt You need to add `additional_dependencies` as in https://dvc.org/doc/command-reference/install#using-the-pre-commit-tool by hand.

We might want to reconsider and add that automatically and let anyone not needing all deps just tailor it to their liking https://github.com/iterative/dvc/blob/12955da3c3ea03fcd25216297bc606df8ceb522e/dvc/repo/install.py#L20


Resolving patch:
diff --git a/dvc/repo/install.py b/dvc/repo/install.py
--- a/dvc/repo/install.py
+++ b/dvc/repo/install.py
@@ -20,16 +20,19 @@ def pre_commit_install(scm: "Git") -> None:
             "hooks": [
                 {
                     "id": "dvc-pre-commit",
+                    "additional_dependencies": [".[all]"],
                     "language_version": "python3",
                     "stages": ["commit"],
                 },
                 {
                     "id": "dvc-pre-push",
+                    "additional_dependencies": [".[all]"],
                     "language_version": "python3",
                     "stages": ["push"],
                 },
                 {
                     "id": "dvc-post-checkout",
+                    "additional_dependencies": [".[all]"],
                     "language_version": "python3",
                     "stages": ["post-checkout"],
                     "always_run": True,


Test patch: