|
| 1 | +--- |
| 2 | +title: dart pub unpack |
| 3 | +description: Downloads a package and unpacks its contents in place. |
| 4 | +--- |
| 5 | + |
| 6 | +:::version-note |
| 7 | +The `unpack` subcommand was introduced in Dart 3.4. |
| 8 | +To download the archive of a package with an earlier SDK, |
| 9 | +visit the **Versions** tab of a package on the [pub.dev site]({{site.pub}}). |
| 10 | +::: |
| 11 | + |
| 12 | +_Unpack_ is one of the commands of the [pub tool](/tools/pub/cmd). |
| 13 | + |
| 14 | +```plaintext |
| 15 | +$ dart pub unpack <package>[:descriptor] [--[no-]resolve] [--output=<output directory>] [--[no-]force] [other options] |
| 16 | +``` |
| 17 | + |
| 18 | +This command downloads the specified `<package>` and |
| 19 | +extracts its contents to a `<package>-<version>` directory. |
| 20 | + |
| 21 | +For example, the following command downloads and extracts the |
| 22 | +latest stable version of `package:http` from the [pub.dev site]({{site.pub}}), |
| 23 | +to the current directory: |
| 24 | + |
| 25 | +```console |
| 26 | +$ dart pub unpack http |
| 27 | +``` |
| 28 | + |
| 29 | +To change the source or version of the downloaded package, |
| 30 | +add a source descriptor after the package name and a colon. |
| 31 | +For example, the following command downloads the `1.2.0` release |
| 32 | +of `package:http` from the pub.dev site: |
| 33 | + |
| 34 | +```console |
| 35 | +$ dart pub unpack http:1.2.0 |
| 36 | +``` |
| 37 | + |
| 38 | +The source descriptor supports more configuration |
| 39 | +with the same syntax as `dart pub add`. |
| 40 | +To learn more about source descriptors and their syntax, check out |
| 41 | +the [source descriptor][] documentation for `dart pub add`. |
| 42 | + |
| 43 | +[source descriptor]: /tools/pub/cmd/pub-add#source-descriptor |
| 44 | + |
| 45 | +## Options |
| 46 | + |
| 47 | +For options that apply to all pub commands, check out |
| 48 | +[Global options](/tools/pub/cmd#global-options). |
| 49 | + |
| 50 | +### `--force` or `-f` {:#force-option} |
| 51 | + |
| 52 | +Overwrite existing folders that conflict |
| 53 | +with the package folder or its contents during extraction. |
| 54 | + |
| 55 | +### `--[no-]resolve` {:#resolve-option} |
| 56 | + |
| 57 | +By default, `dart pub get` runs automatically to complete |
| 58 | +package resolution after downloading and unpacking a package. |
| 59 | +To disable automatic resolution, |
| 60 | +specify the `--no-resolve` flag: |
| 61 | + |
| 62 | +```console |
| 63 | +$ dart pub unpack http --no-resolve |
| 64 | +``` |
| 65 | + |
| 66 | +### `--output=<dir>` or `-o <dir>` {:#output-option} |
| 67 | + |
| 68 | +By default, extract the package to the current directory (`.`). |
| 69 | +To change the directory the package is extracted to, |
| 70 | +specify the desired output directory with the `--output` option. |
| 71 | + |
| 72 | +For example, the following commands unpacks the |
| 73 | +`1.2.0` release of `package:http` to the `local_http_copies` directory. |
| 74 | + |
| 75 | +```console |
| 76 | +$ dart pub unpack http:1.2.0 -o local_http_copies |
| 77 | +``` |
| 78 | + |
| 79 | + |
| 80 | +{% render 'pub-problems.md' %} |
0 commit comments