前提
本文推荐给以下人群。
- 我正在使用Windows Update的Windows 10上进行开发
- 我想节省安装和设置工作的时间
- 我想正确使用同一应用程序的不同版本
- 安装了瓢
如果不确定Scoop是哪种工具,或者尚未安装,请阅读Windows命令行工具中Scoop的建议(基本知识)。
用Scoop进行版本控制
Scoop公开了存储区 1,用于版本控制,但不是所有应用程序。
使用Scoop安全版本化的应用程序已在"版本"存储桶中注册。包括node.js,python等
此外,PHP和Java都有各自的存储桶。
由于无法在初始状态下使用每个存储桶,因此请在使用前使用
在这里,我想尝试一下还没有专用存储桶的node.js。
添加"版本"存储桶
允许
1 2 3 | PS C:\Users\user> scoop bucket add versions Checking repo... ok The versions bucket was added successfully. |
它简单地结束了,但是让我们搜索node.js。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | PS C:\Users\user> scoop search node.js No matches found. #node.jsでは見つからなかった PS C:\Users\user> scoop search node 'main' bucket: eventstore (4.1.2) --> includes 'EventStore.ClusterNode.exe' node-chakracore (10.13.0) nodejs-lts (10.15.3) nodejs (12.2.0) sliksvn (1.9.7) --> includes 'svn-populate-node-origins-index.exe' 'versions' bucket: nodejs010 (0.10.48) nodejs012 (0.12.18) nodejs10 (10.15.3) nodejs11 (11.15.0) nodejs12 (12.2.0) nodejs4 (4.9.1) nodejs5 (5.12.0) nodejs6 (6.17.1) nodejs7 (7.10.1) nodejs8 (8.16.0) nodejs9 (9.11.2) |
已注册许多版本,但是主存储桶中的" nodejs"是默认安装的最新版本。主目录中似乎也有LTS版本。
除nodejs以外的版本规范实际上已注册为单独的应用程序,并且已注册每个版本的稳定版本或最新版本。
在这里,我将在具有最新版本和先前版本的版本存储桶中安装nodejs11。
一起安装
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | PS C:\Users\user> scoop install nodejs nodejs11 Installing 'nodejs' (12.2.0) [64bit] node-v12.2.0-win-x64.7z (9.5 MB) [============================================================] 100% Checking hash of node-v12.2.0-win-x64.7z ... ok. Extracting node-v12.2.0-win-x64.7z ... done. Linking D:\Applications\Scoop\apps\nodejs\current => D:\Applications\Scoop\apps\nodejs\12.2.0 Persisting bin Persisting cache Running post-install script... 'nodejs' (12.2.0) was installed successfully! Installing 'nodejs11' (11.15.0) [64bit] node-v11.15.0-win-x64.7z (9.3 MB) [===========================================================] 100% Checking hash of node-v11.15.0-win-x64.7z ... ok. Extracting node-v11.15.0-win-x64.7z ... done. Linking D:\Applications\Scoop\apps\nodejs11\current => D:\Applications\Scoop\apps\nodejs11\11.15.0 Persisting bin Persisting cache Running post-install script... 'nodejs11' (11.15.0) was installed successfully! |
我在安装时指定了多个应用程序名称(版本),并一次安装了所有这些名称。 2
让我们检查已安装的node.js版本。
1 2 | PS C:\Users\user> node --version v11.15.0 |
根据安装时指定的顺序,当前设置了以后安装的版本11。
版本切换
检查如何切换。
使用
可以通过指定
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | PS C:\Users\user> scoop reset nodejs #最新バージョンに切り替え Resetting nodejs (12.2.0). Linking D:\Applications\Scoop\apps\nodejs\current => D:\Applications\Scoop\apps\nodejs\12.2.0 Persisting bin Persisting cache PS C:\Users\user> node --version #確認 v12.2.0 PS C:\Users\user> scoop reset nodejs11 #古いバージョンにもどして Resetting nodejs11 (11.15.0). Linking D:\Applications\Scoop\apps\nodejs11\current => D:\Applications\Scoop\apps\nodejs11\11.15.0 Persisting bin Persisting cache PS C:\Users\user> node --version #確認 v11.15.0 |
这只是对版本切换的确认,但可以像这样轻松完成。这与Linux Alternatives命令非常相似。
即使使用具有独立存储区的Java和php,您也可以在版本之间进行切换,甚至可以在每个供应商的JDK(如果是Java)之间进行切换。
在开发过程中检查跨版本的操作时,这非常有用。
Scoop上的应用程序版本升级
使用
Scoop更新已安装的应用程序。
3非常容易和方便,但是使用Scoop进行更新有一些技巧。
更新机制
手动更新命令行工具时,通常会覆盖已安装文件夹中的新文件。这是因为有必要继承难以更改的设置,例如PATH和设置的存储位置,但是此方法当然不容易还原到以前的版本。
Scoop更新不会覆盖相同的文件夹,而是在另一个文件夹中安装新版本,并将路径切换到应用程序 4。此任务与上述的reset命令相同。
因此,旧版本的应用仍受Scoop的控制。用于设置的环境变量(除非版本升级中进行了破坏性更改),并且应用程序的PATH未更改。
通过这种机制,您可以更新Scoop安装的应用程序
发生问题时,也可以将应用程序切换到旧版本。
切换具有相同名称
的已安装应用程序的版本
根据帮助,
输入
假设您已经有两个版本的Git 2.20.1.windows.1和2.21.0.windows.1,请尝试在这些版本之间进行切换。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | PS C:\Users\user> scoop reset [email protected] Resetting git (2.20.1.windows.1). Linking D:\Applications\Scoop\apps\git\current => D:\Applications\Scoop\apps\git\2.20.1.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) PS C:\Users\user> git --version git version 2.20.1.windows.1 PS C:\Users\user> scoop reset [email protected] Resetting git (2.21.0.windows.1). Linking D:\Applications\Scoop\apps\git\current => D:\Applications\Scoop\apps\git\2.21.0.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) PS C:\Users\user> git --version git version 2.21.0.windows.1 |
这样,您甚至可以在已安装的同名应用程序之间切换版本。
我认为当检查在特定点添加或修复的功能的兼容性或更新中出现问题时,它可以用作回滚。
结合上面提到的存储桶版本控制,您不必担心Java和node.js的频繁更新和安全补丁。我很高兴。
检查安装的版本
您可以使用
这是先前使用Git运行它的示例。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | PS C:\Users\user> scoop info git Name: git Version: 2.21.0.windows.1 Website: https://git-for-windows.github.io/ License: GPL-2.0 (https://spdx.org/licenses/GPL-2.0.html) Manifest: D:\Applications\Scoop\buckets\main\bucket\git.json Installed: D:\Applications\Scoop\apps\git\2.20.1.windows.1 D:\Applications\Scoop\apps\git\2.21.0.windows.1 Binaries: cmd\git.exe cmd\gitk.exe cmd\git-gui.exe usr\bin\tig.exe git-bash.exe Environment: GIT_INSTALL_ROOT=D:\Applications\Scoop\apps\git\current Notes ----- To get Git to recognise OpenSSH, you will need to run scoop install openssh \[environment]::setenvironmentvariable('GIT_SSH', (resolve-path (scoop which ssh)), 'USER') and then restart powershell. |
如上所述,已安装的版本显示在
使用相同名称的应用程序
进行版本切换的注意事项
还将发布安全补丁,因此,如果最新版本没有问题,则应为具有相同名称的应用程序使用最新版本。
在版本和主存储区中搜索托管维护版本(例如LTS)也是一个好主意。
删除(卸载)旧版本
如上所述,Scoop不会在更新时删除较旧的版本。大多数命令行应用程序都不大,但不能无休止地存储。
为了解决这个问题,还有一个
累积太多是不好的,但是保留旧版本是有好处的,因此最好适当使用它。
最后
在开发环境中更新工具和应用程序需要花费时间和精力,但是Scoop大大减轻了负担。
特别是,我们建议您主动更新Scoop管理的语言的运行时,并不时使用
是通过分类注册应用程序的Git存储库吗?
如果您为完全不同的应用程序指定了多个应用程序,它们将按照指定的顺序安装吗?
当然,如果应用程序更新本身发生了破坏性的更改,则必须对其进行处理,并且备份设置文件等更为安全。 ?
严格来说,要访问的版本的目录是通过切换结点的连接目标来更改的https://github.com/lukesampson/scoop/wiki/The-'Current'-Version-Alias?
也许不是推荐的用法,因为官方文档中没有提到它?