Windowsのパッケージマネージャにscoopを使う
これまであまりWindowsでパッケージマネージャは使ってこなかったが、Macのbrew的な便利さがあればやはり便利なので導入を検討していた。
軽くChocolateyを使ったりもしていたが、今の流行りはScoopのようだったので、その時勢に乗っていくことにする。
細かいことはあまり比較していないが、Scoopの場合パッケージの導入に管理者権限をあまり(すべて?)要求しないとのことだったので、その辺りが個人的には高評価。
Scoop導入
公式の手順を実行するだけ。
Power Shellのバージョンが5以上必要らしいので一応事前に確認する(Power Shellのバージョンなんて人生で一度も気にしたことなかった)。
> $PSVersionTable Name Value ---- ----- PSVersion 5.1.19041.1 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.19041.1 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1
また、.Net Frameworkの4.5以上がインストールされている必要もあるらしいので、確認する。
ここで紹介されているレジストリエディタで確認する方法で参照したところ、4.8だった。
とりあえず事前要件は問題なさそうなので、インストールスクリプトを実行する。
公式のNoteにも書かれている例外が発生したので、指示に従って設定を変えつつインストールする。
> iwr -useb get.scoop.sh | iex PowerShell requires an execution policy in [Unrestricted, RemoteSigned, ByPass] to run Scoop. For example, to set the execution policy to 'RemoteSigned' please run : 'Set-ExecutionPolicy RemoteSigned -scope CurrentUser' > Set-ExecutionPolicy RemoteSigned -scope CurrentUser 実行ポリシーの変更 実行ポリシーは、信頼されていないスクリプトからの保護に役立ちます。実行ポリシーを変更すると、about_Execution_Policie s のヘルプ トピック (https://go.microsoft.com/fwlink/?LinkID=135170) で説明されているセキュリティ上の危険にさらされる可能性があります。実行ポリシーを変更しますか? [Y] はい(Y) [A] すべて続行(A) [N] いいえ(N) [L] すべて無視(L) [S] 中断(S) [?] ヘルプ (既定値は "N"): Y > iwr -useb get.scoop.sh | iex Initializing... Downloading scoop... Extracting... Creating shim... Downloading main bucket... Extracting... Adding ~\scoop\shims to your path. 'lastupdate' has been set to '2020-04-25T17:28:34.4295578+09:00' Scoop was installed successfully! Type 'scoop help' for instructions.
無事インストール完了。
ということで早速GitをScoop経由で導入してみる。
> scoop search git 'main' bucket: git-annex (8.20200330) git-chglog (0.9.1) git-crypt (0.6.0-701fb8e) git-filter-repo (2.26.0) git-interactive-rebase-tool (1.2.1) git-istage (0.2.61) git-lfs (2.10.0) git-sizer (1.3.0) git-tfs (0.30) git-town (7.3.0) git-up (1.6.1) git-with-openssh (2.26.2.windows.1) git (2.26.2.windows.1) gitea (1.11.4) gitignore (0.2018.07.25) gitkube (0.3.0) gitlab-runner (12.10.1) gitomatic (0.2) gitversion (5.2.3) mingit-busybox (2.26.2.windows.1) mingit (2.26.2.windows.1) psgithub (2017.01.22) psutils (0.2020.02.27) --> includes 'gitignore.ps1' > scoop install git Installing '7zip' (19.00) [64bit] 7z1900-x64.msi (1.7 MB) [=================================================================================] 100% Checking hash of 7z1900-x64.msi ... ok. Extracting 7z1900-x64.msi ... done. Linking ~\scoop\apps\7zip\current => ~\scoop\apps\7zip\19.00 Creating shim for '7z'. Creating shortcut for 7-Zip (7zFM.exe) '7zip' (19.00) was installed successfully! Installing 'git' (2.26.2.windows.1) [64bit] PortableGit-2.26.2-64-bit.7z.exe (41.1 MB) [================================================================================================] 100% Checking hash of PortableGit-2.26.2-64-bit.7z.exe ... ok. Extracting dl.7z ... done. Linking ~\scoop\apps\git\current => ~\scoop\apps\git\2.26.2.windows.1 Creating shim for 'git'. Creating shim for 'gitk'. Creating shim for 'git-gui'. Creating shim for 'tig'. Creating shim for 'git-bash'. Creating shortcut for Git Bash (git-bash.exe) Creating shortcut for Git GUI (git-gui.exe) Running post-install script... 'git' (2.26.2.windows.1) was installed successfully! > git --version git version 2.26.2.windows.1
GitのWebサイトを開き、Windows用のインストーラをダウンロードして、インストーラ実行して…という手順がワンラインで済むようになるのでこれはかなり嬉しい。
細かい仕様は追々理解していくものとして、とりあえず使えるようになったのでヨシ!