Captain's Geek-Island Captain's Geek-Island
首页
生活如斯乎
架构师的路
  • 分类
  • 标签
  • 归档
沉洋官网 (opens new window)

SleepyOcean

走,找新大陆去
首页
生活如斯乎
架构师的路
  • 分类
  • 标签
  • 归档
沉洋官网 (opens new window)
  • 计算机基础

  • 并发专题

  • 性能调优专题

  • 工具专题

    • 项目工具 - Maven
    • 项目工具 - Git
    • 服务器 - Nginx
    • 包管理 - scoop
      • Scoop 介绍
      • Scoop 安装
        • 环境需求
        • 安装
        • 配置国内源
      • Scoop 命令
      • Scoop 卸载
      • 常见问题解决方案
      • 附录
        • 1)scoop安装的7zip如何添加到右键菜单?
  • 源码框架专题

  • 设计模式

  • 分布式专题

  • 实战专题

  • 技术杂文

  • 云原生专题

  • 大数据分析专题

  • 前端专题

  • 运维专题

  • 经验专题

  • 面试专题

  • 软实力专题

  • 架构师的路
  • 工具专题
SleepyOcean
2021-06-19

包管理 - scoop

在平常生活中如果要安装像git、java、node这些环境的时都需要先去官网下载安装程序,点击安装,之后还需要配置,不仅过程麻烦,而且工具多了之后整理起来也相当不容易,配置也很杂,整个电脑就像被污染了一样。而scoop可以很好地解决这一问题,安装scoop后,只需要在命令行输入简单的一串命令即可安装你想要的软件。

比如我想安装git,只需要输入

$ scoop install git
1

然后就可以直接使用git命令了,是不是很简单。

如果我想卸载git,只需输入

$ scoop uninstall git
1

然后git就干干净净的从你的电脑中消失啦^_^

# Scoop 介绍

Scoop是Windows的命令行安装程序,是一个强大的包管理工具。详细信息参考官方GitHub项目 (opens new window)

# Scoop 安装

# 环境需求

  1. Windows 7 SP1 + / Windows Server 2008+
  2. PowerShell 5(或更高版本,包括PowerShell Core)和.NET Framework 4.5(或更高版本)
  3. 必须为您的用户帐户启用PowerShell,例如 Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

# 安装

在PowerShell中运行以下命令,将scoop安装到其默认位置

# 配置安装环境
> Set-ExecutionPolicy RemoteSigned -scope CurrentUser
> $env:SCOOP='D:\Program Files\Scoop'
> [Environment]::SetEnvironmentVariable('SCOOP',$env:SCOOP,'User')

# 设置scoop global环境变量
> $env:SCOOP_GLOBAL='D:\Program Files\ScoopGlobalApps'
> [Environment]::SetEnvironmentVariable('SCOOP_GLOBAL',$env:SCOOP_GLOBAL,'User')

# 安装命令 (建议:使用全局科学上网运行最佳。先打开科学上网工具,然后重启shell,执行y安装命令)
> Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
# 或
> iwr -useb get.scoop.sh | iex
# GitHub访问不畅时,上面两条命令都会不成功。当然我们还有备选方案:配置hosts(配上访问raw.githubusercontent.com最快的ip到hosts中),然后再试试下面的命令
> iex (new-object net.webclient).downloadstring('https://raw.githubusercontent.com/lukesampson/scoop/master/bin/install.ps1')  

# 安装完成后,输入下面命令验证是否成功(常见的命令可以通过此方法来查看)
> scoop help
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

关于如何加速访问Github:https://github.com/521xueweihan/GitHub520

Windows的hosts路径: C:\Windows\System32\drivers\etc\hosts

# 配置国内源

由于GitHub在国内访问速度不理想,所以提供国内镜像作为备选方案

# 配置git环境
> scoop install git

# 安装aria2,加速下载
> scoop install aria2

# 配置是否使用aria2下载,false为禁用,true为启用
> scoop config aria2-enabled true
1
2
3
4
5
6
7
8

国内镜像加速方案

scoop bucket add main https://codechina.csdn.net/mirrors/ScoopInstaller/Main.git
1
scoop bucket add extras https://codechina.csdn.net/mirrors/lukesampson/scoop-extras.git
1
scoop bucket add nonportable https://codechina.csdn.net/mirrors/TheRandomLabs/scoop-nonportable
1
scoop bucket add nirsoft https://codechina.csdn.net/mirrors/kodybrown/scoop-nirsoft.git
1
scoop bucket add nerd-fonts https://codechina.csdn.net/mirrors/matthewjberger/scoop-nerd-fonts.git
1
scoop bucket add java https://codechina.csdn.net/mirrors/ScoopInstaller/Java.git
1
scoop bucket add versions https://codechina.csdn.net/mirrors/ScoopInstaller/Versions.git
1
scoop bucket add games https://codechina.csdn.net/mirrors/Calinou/scoop-games.git
1
scoop bucket add dorado https://gitee.com/chawyehsu/dorado
1

配置国内镜像源后,更新下scoop

scoop update
1

更多镜像参考:mirrors - CODE CHINA (opens new window)

# Scoop 命令

# 查看已添加的bucket
> scoop bucket list

# 查看所有已知的bucket
> scoop bucket known

# 添加一个bucket
> scoop bucket add java
1
2
3
4
5
6
7
8

常见的bucket

  1. main - Default bucket for the most common (mostly CLI) apps
  2. extras - Apps that don’t fit the main bucket’s criteria
  3. games - Open source/freeware games and game-related tools
  4. nerd-fonts - Nerd Fonts
  5. nirsoft - A subset of the 250 Nirsoft apps
  6. java - Installers for Oracle Java, OpenJDK, Zulu, ojdkbuild, AdoptOpenJDK, 7. Amazon Corretto, BellSoft Liberica & SapMachine
  7. jetbrains - Installers for all JetBrains utilities and IDEs
  8. nonportable - Non-portable apps (may require UAC)
  9. php - Installers for most versions of PHP
  10. versions - Alternative versions of apps found in other buckets

# Scoop 卸载

> scoop uninstall scoop
1

就这么简单😄

# 常见问题解决方案

  1. 出现使用“1”个参数调用“DownloadString”时发生异常:“请求被中止: 未能创建 SSL/TLS 安全通道。”错误

A: 原因是因为使用HttpWebRequest请求https链接时,无法访问的问题,设置ServicePointManager.SecurityProtocol安全协议。执行一下以下命令即可解决:

> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
1

其他参考文档:scoop最新安装教程2021_路人夹饼的博客-CSDN博客 (opens new window)

# 附录

# 1)scoop安装的7zip如何添加到右键菜单?

使用管理员身份运行7zipGUI,在菜单选项中即可添加。

#包管理
上次更新: 2022/03/10, 07:03:00

← 服务器 - Nginx 框架解读 - SpringBoot →

新鲜出炉
01
记录 - 快速搭建自动化部署平台
04-13
02
Docker搭建各类Paas服务
03-01
03
系统配置 - Android TV配置
02-12
更多文章>
Copyright © 2019-2022 SleepyOcean | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式