Windowsの開発環境をScoopで管理する

Windows

Scoopを使用することで開発に使用するパッケージのインストールやアップデートなどの管理を管理者権限不要で簡単に行うことができる。

Scoopとは

Windows向けのパッケージマネージャー。
ChocolateyやUbuntuのaptのようにコマンドラインでパッケージ管理(インストール/アップデートなど)を行うことができる。
Chocolateyと違い管理者権限不要でパッケージを管理できる点が素晴らしい。
公式サイトはこちら。

ScoopとScoopアプリのインストール先

ScoopやScoopアプリは以下のようにユーザーディレクトリにインストールされるため管理者権限が不要。

C:\Users\username\scoop
├─apps
│  ├─7zip
│  ├─git
│  └─scoop
├─buckets
├─cache
└─shims

Scoopをインストールする

インストールの流れ

細かい説明はフヨウラというせっかちな兄貴たちのためにコマンド一覧を記載する。

# Scoopをインストール
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
scoop help # Scoopのコマンド動作確認
scoop install git # gitをインストール(Scoop自身が使用する)
scoop status # Scoopのバージョンを確認
scoop update # Scoopのアップデート
scoop status # Scoopのバージョンを確認

インストール方法(詳細)

環境要件

公式サイトにもあるように以下を満たす必要がある。

  • PowerShell5以上
  • .NetFramework4.5以上

PowerShellを開く

コマンドを入力してscoopをインストールする

PS C:\Users\username> Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
PS C:\Users\username> Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')

Scoopコマンドを確認する

helpコマンドでScoopがインストールされて動作することを確認する。

PS C:\Users\username> scoop help
Usage: scoop <command> [<args>]

Some useful commands are:

alias       Manage scoop aliases
bucket      Manage Scoop buckets
cache       Show or clear the download cache
checkup     Check for potential problems
cleanup     Cleanup apps by removing old versions
config      Get or set configuration values
create      Create a custom app manifest
depends     List dependencies for an app
export      Exports (an importable) list of installed apps
help        Show help for a command
hold        Hold an app to disable updates
home        Opens the app homepage
info        Display information about an app
install     Install apps
list        List installed apps
prefix      Returns the path to the specified app
reset       Reset an app to resolve conflicts
search      Search available apps
status      Show status and check for new app versions
unhold      Unhold an app to enable updates
uninstall   Uninstall an app
update      Update apps, or Scoop itself
virustotal  Look for app's hash on virustotal.com
which       Locate a shim/executable (similar to 'which' on Linux)

gitをインストールする

Scoopがgitを使用するのでまずはgitをインストールする。

PS C:\Users\username> scoop install git

なお、gitをインストールしないと以下のようにコマンド実行時にエラーとなる。

PS C:\Users\username> scoop update
Scoop uses Git to update itself. Run 'scoop install git' and try again.

scoopを最新版にアップデートする

statusコマンドで最新版かどうかを確認する。

PS C:\Users\username> scoop status
WARN  Scoop is out of date. Run 'scoop update' to get the latest changes.

上のように最新版でないと指摘されたらupdateコマンドでアップデートする。

PS C:\Users\username> scoop update
Updating Scoop...
Updating 'main' bucket...
Checking repo... ok
The main bucket was added successfully.
Scoop was updated successfully!

最新版になっている場合、以下のように表示される。
これでScoopを利用してパッケージ管理を行えるようになった。

PS C:\Users\username> scoop status
Scoop is up to date.
Everything is ok!

Scoopの代表的なコマンド

以下に代表的なコマンドをリストする。

コマンド処理内容
statusScoopの状態とアップデートを確認するscoop status
listインストール済みのScoopアプリをリストするscoop list
search利用可能なScoopアプリを検索するscoop search git
install指定したScoopアプリをインストールするscoop install git
updateScoop自身もしくはインストール済みのScoopアプリをアップデートするscoop update git
uninstall指定したScoopアプリをアンインストールするscoop uninstall git

コメント

タイトルとURLをコピーしました