﻿---
title: Scoop修炼手册
date: 2024-06-01
excerpt: Scoop —— A command-line installer for Windows.
tags:
  - Productivity
  - Microsoft
  - Windows
cover: https://assets.vluv.space/cover/Dev/Others/Scoop.webp
---

<script data-swup-reload-script type="module" src="/js/components/tab.js"></script>

> Scoop is an installer
> The goal of Scoop is to let you use Unix-y programs in a normal Windows environment
> <cite>Mike Zick</cite>

[Scoop](https://scoop.sh/#/)是一个 Windows 的下载工具，可以方便的安装各种软件。

### Directory Structure

<script data-swup-reload-script type="module" src="/js/components/tree.js"></script>
<x-tree root="%USERPROFILE%\scoop">

- apps/
  - git/
    - current/
    - 2.45.1.windows.1
- buckets/
  - main/
  - extras/
- cache/
- persist/
- shims/

</x-tree>

- **Apps**: 安装的各个软件或程序
- **Buckets**: 存放各种 app 的集合,buckets 目录下存放许多个 bucket，例如 main 为默认的 bucket，extras 包括部分未收录 main bucket 的常用软件，nerdfonts 为存放字体 app 的 bucket,每一个 bucket 都是一个 github 仓库，仓库里维护许多 app 的 json 文件，json 文件里存放了 app 的安装信息，包括 app 的版本，LICENSE，下载地址 url etc,这些 json 文件被称作 App manifest，下面是一个简单的示例

  ```json
  {
    "version": "1.0",
    "url": "https://github.com/lukesampson/cowsay-psh/archive/master.zip",
    "extract_dir": "cowsay-psh-master",
    "bin": "cowsay.ps1"
  }
  ```

- **Cache**: 存放下载的临时文件
- **Shims**: scoop 在 environment variable 中添加了该目录;通过 scoop 安装的程序,scoop 会自动为其在 Shims 目录下生成一个对应的 exe 文件，这样程序安装后可以直接在命令行中调用。对于 GUI 程序，scoop 会自动在开始菜单中添加其快捷方式，目录`C:\Users\<user>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Scoop Apps`

### Installation

<x-tabs>

<x-tab title="Default" active>

默认安装到 `C:\Users\<YOUR USERNAME>\scoop` 目录下

```powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
```

</x-tab>

<x-tab title="Advanced">

自定义安装目录

```shell
$ irm get.scoop.sh -outfile 'install.ps1'
$ .\install.ps1 -ScoopDir 'D:\envir_vars\scoop\' -ScoopGlobalDir 'D:\envir_vars\scoop\GlobalApps' -NoProxy
```

已安装 Scoop 想迁移目录，参考[Change Directory](https://github.com/ScoopInstaller/scoop/issues/249)

迁移应用可通过 `scoop export` 导出 json 再 import，直接移动源目录文件 shims 无效（仍指向原目录）

</x-tab>

</x-tabs>

## Command

### Install & Uninstall

- `{sh} scoop search vim` 查找 app
- `{sh} scoop install neovim` 安装指定 app
- `{sh} scoop install git@2.23.0.windows.1` 安装指定版本 app
- `{sh} scoop install -g git` 安装全局 app
  Install Options:
  -g, --global Install the app globally
  -i, --independent Don't install dependencies automatically
  -k, --no-cache Don't use the download cache
  -u, --no-update-scoop Don't update Scoop before installing if it's outdated
  -s, --skip Skip hash validation (use with caution!)
  -a, --arch <32bit|64bit> Use the specified architecture, if the app supports it

---

- `{sh} scoop uninstall neovim` 卸载指定软件
- `{sh} scoop uninstall -p python` 卸载软件及其配置文件
- `{sh} scoop uninstall -g git` 卸载全局软件

### Update

- `{sh} scoop list` List installed apps
- `{sh} scoop status` Show status and check for new app versions

  ```shell
  Name      Installed Version Latest Version Missing Dependencies Info
  ----      ----------------- -------------- -------------------- ----
  7zip      23.01             24.05
  aria2     1.36.0-1          1.37.0-1
  eza       0.18.15           0.18.16
  fastfetch 2.11.3            2.14.0
  fd        9.0.0             10.1.0
  git       2.42.0.2          2.45.1
  gitui     0.26.1            0.26.2
  kotlin    1.9.22            2.0.0
  neovim    0.9.5             0.10.0
  ```

- `{sh} scoop update` update scoop
- `{sh} scoop update neovim 7zip aria2` 更新指定软件
- `{sh} scoop update *` 更新所有软件
- `{sh} scoop hold/update neovim` hold 命令用于将某些应用程序"冻结"，即禁止更新这些应用程序，unhold 是相应的"解冻"命令，解除对应用程序更新的限制

### Clean

- `{sh} scoop cleanup git` 清理指定软件的旧版本
- `{sh} scoop cleanup *` 清理所有软件的旧版本
- `{sh} scoop cache rm *` 清理下载软件时的缓存文件

### MISC

在同一程序的不同版本之间切换

```powershell
scoop reset python@3.10.6
# do something
scoop reset python@3.12.3
```

- `alias` Manage scoop aliases
- `bucket` Manage Scoop buckets
- `cat` Show content of specified manifest.
- `checkup` Check for potential problems
- `create` Create a custom app manifest
- `depends` List dependencies for an app, in the order they'll be installed
- `download` Download apps in the cache folder and verify hashes
- `export` Exports installed apps, buckets (and optionally configs) in JSON format
- `help` Show help for a command
- `home` Opens the app homepage
- `import` Imports apps, buckets and configs from a Scoopfile in JSON format
- `info` Display information about an app
- `prefix` Returns the path to the specified app
- `shim` Manipulate Scoop shims
- `virustotal` Look for app's hash or url on virustotal.com
- `which` Locate a shim/executable (similar to 'which' on Linux)

## Ref

[Scoop_Wiki](https://github.com/ScoopInstaller/Scoop/wiki)
