简体   繁体   English

如何通过 git-bash 在 windows 上卸载没有 package 管理器的工具?

[英]How do I uninstall a tool that was installed without a package manager on windows via git-bash?

Clarification:澄清:

So my question is rather general and doesn't address a specific tool, however, my issue came as a consequence of the need to remove the tool jq.所以我的问题很笼统,没有针对特定工具,但是,我的问题是由于需要删除工具 jq 而出现的。 I would appreciate a more generic approach to address all tools but if not possible, then specifically for jq would be appreciated.我希望有一种更通用的方法来解决所有工具,但如果不可能,那么特别针对 jq 将不胜感激。

The background:的背景:

I installed the jq tool using git-bash on Windows without a package manager (eg, Chocolatey) by using curl -L -o /usr/bin/jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe我使用curl -L -o /usr/bin/jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe在 Windows 上使用 git-bash 安装了 jq 工具,没有 package 管理器(例如 Chocolatey) curl -L -o /usr/bin/jq.exe https://github.com/stedolan/jq/releases/latest/download/jq-win64.exe

This added jq.exe to the folder C:\Program Files\Git\usr\bin这将 jq.exe 添加到文件夹C:\Program Files\Git\usr\bin

I created a script that does this installation for my team, but we need to erase this for various reasons.我创建了一个脚本来为我的团队执行此安装,但由于各种原因我们需要删除它。 I don't want to tell every team member to go to that folder and erase the jq.exe file.我不想告诉每个团队成员到 go 到那个文件夹并删除 jq.exe 文件。 Nor do I want to write a script that erases the exe file because I am not sure if erasing the exe file would constitute a proper uninstallation, so perhaps a solution that would involve a more comprehensive approach would be preferable.我也不想编写擦除 exe 文件的脚本,因为我不确定擦除 exe 文件是否会构成正确的卸载,所以也许涉及更全面方法的解决方案会更可取。

The Question:问题:

So is there a way to erase this tool (or any other tool for that matter that was installed in a similar way via git-bash) via the command line (so I could write a script for it) that would work for any user regardless of where they installed their Git folder?那么有没有一种方法可以通过命令行(这样我就可以为它编写一个脚本)擦除这个工具(或任何其他通过 git-bash 以类似方式安装的工具),这对任何用户都有效他们在哪里安装了 Git 文件夹?

It depends.这取决于。

When you download a binary ( .exe ) using curl (or wget , or even your browser), there are multiple ways that the binary might work, and resulting multiple ways that it might need to be uninstalled.当您使用curl (或wget甚至您的浏览器)下载二进制文件 ( .exe ) 时,二进制文件可能有多种工作方式,因此可能需要通过多种方式将其卸载。

As mentioned in the comments, jq.exe is a single binary that doesn't create any configuration data by default.如评论中所述, jq.exe是一个单一的二进制文件,默认情况下不创建任何配置数据。 So deleting it will be sufficient.所以删除它就足够了。

However, it's entirely possible for you to curl /download a binary that is:但是,您完全有可能通过curl / 下载一个二进制文件:

  • A Windows installer : In this case, the first time you run the .exe , its files will be installed via the normal Windows installation method. Windows 安装程序:在这种情况下,第一次运行.exe时,将通过正常的 Windows 安装方法安装其文件。 Uninstalling would be done through the Windows Add or remove programs settings page.卸载将通过 Windows添加或删除程序设置页面完成。

  • A self-extracting archive: Some applications will extract the files contained inside the download.自解压存档:某些应用程序将解压下载内容中包含的文件。 The files will be located in either the current directory or a newly created subdirectory.这些文件将位于当前目录或新创建的子目录中。 In this case, deleting the files in the directory will be sufficient.在这种情况下,删除目录中的文件就足够了。

    For this reason, it's best to place the download in a directory of its own before executing, so that you can easily identify which files were created and need to be removed.出于这个原因,最好在执行之前将下载文件放在它自己的目录中,这样您就可以轻松识别创建了哪些文件以及需要删除哪些文件。

  • A single-binary that creates configuration data the first time it is run: Some applications will automatically create configuration data in a known location the first time they are run.第一次运行时创建配置数据的单一二进制文件:一些应用程序会在第一次运行时自动在已知位置创建配置数据。 Nushell ( nu ) for instance, is one of these.例如,Nushell ( nu ) 就是其中之一。 It would be entirely possible to download just the nu binary, and the first time it is executed, configuration files will be created in your home directory.完全可以只下载nu二进制文件,并且第一次执行时,将在您的主目录中创建配置文件。 In this case, to completely remove the files, you'll probably need to refer to the documentation or ask the developer.在这种情况下,要完全删除文件,您可能需要参考文档或询问开发人员。

  • A self-extracting source archive : I haven't seen this in a long time (honestly, if ever, in this exact form - It's a bit of a pathologic case the way I'm describing it here), but it would be possible for the payload of a self-extracting archive to be the source code for an application that needs to be built/compiled, usually with something like make install (and a number of build dependencies).自解压源存档:我很久没见过这个了(老实说,如果有的话,以这种确切的形式 - 我在这里描述它的方式有点病态),但它是可能的自解压存档的有效负载是需要构建/编译的应用程序的源代码,通常使用诸如make install之类的东西(以及一些构建依赖项)。 Some developers will include a make uninstall , but others will just require that you "use the source, Luke" and determine which files you need to remove.一些开发人员会包含make uninstall ,但其他开发人员只需要您“使用源代码,Luke”并确定需要删除哪些文件。

And these are just .exe cases.这些只是.exe案例。 As also mentioned in the comments, if you weren't using Git Bash here (perhaps Windows Subsystem for Linux), you could curl an application package that would then be installed by a package manager.正如评论中还提到的,如果您在这里没有使用 Git Bash(可能是 Windows Linux 子系统),您可以curl一个应用程序package然后由 package 管理器安装。 In that case, the package manager would also be used to remove the application.在这种情况下,package 管理器也将用于删除应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM