如何在 Windows 上安装和使用 ack 库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1023710/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I install and use ack library on Windows?
提问by rajesh pillai
回答by Nifle
Start by installing perl http://strawberryperl.com/
首先安装 perl http://strawberryperl.com/
Install App::Ackby typing (in a windows command shell)
通过键入(在 Windows 命令外壳中)安装App::Ack
C:\>cpan App::Ack
And undoubtedly this will prove useful http://learn.perl.org/
毫无疑问,这将证明是有用的http://learn.perl.org/
回答by Robert Wahler
Not all the tests pass on all versions of Windows. You can most likely get 100% functionality from ack even if the install tests fail. Here is the command to force installation if failing tests prevent a normal install:
并非所有测试都通过所有版本的 Windows。即使安装测试失败,您也很可能从 ack 获得 100% 的功能。如果失败的测试阻止正常安装,则这是强制安装的命令:
perl -MCPAN -e "CPAN::Shell->force(qw(install App::Ack));"
回答by Rich
If you already have msysgit installed, then you don't need to install Perl, because you already have a version. You just need to download the standalone version of ackand put it somewhere in your bash path1. You can then run ack from your msysgit bash prompt.
如果您已经安装了 msysgit,那么您不需要安装 Perl,因为您已经有了一个版本。您只需要下载独立版本的 ack并将其放在 bash 路径1 中的某个位置。然后您可以从您的 msysgit bash 提示符运行 ack。
If you also want to be able to run ack from the Windows command prompt, then you will need to create a batch script somewhere in your Windows path2with the contents:
如果您还希望能够从 Windows 命令提示符运行 ack,那么您需要在 Windows 路径2 的某处创建一个批处理脚本,内容如下:
@"C:\Program Files\Git\bin\perl" C:\path\to\ack-standalone.pl %*
(You'll obviously need to edit the paths above to match your msysgit installation and where you placed the ack script.)
(您显然需要编辑上面的路径以匹配您的 msysgit 安装和放置 ack 脚本的位置。)
1: I just stuck mine in the mysysgit bin directory: C:\Program Files\Git\bin\ack
. This isn't the most sensible location for it, but it works.
2: Again, I just created the file ack.bat
in the msysgit bin directory C:\Program File\Git\bin
.
1:我只是把我的放在 mysysgit bin 目录中:C:\Program Files\Git\bin\ack
. 这不是它最明智的位置,但它有效。
2:同样,我刚刚ack.bat
在 msysgit bin 目录中创建了文件C:\Program File\Git\bin
。
回答by Swoogan
If you have cygwin installed, you can simply download the standalone version. Perl is installed with cygwin. Here are the steps:
如果您安装了 cygwin,则只需下载独立版本即可。Perl 与 cygwin 一起安装。以下是步骤:
$ vim .bash_profile
Remove the comments from the lines:
从行中删除注释:
# if [ -d "${HOME}/bin" ] ; then
# PATH="${HOME}/bin:${PATH}"
# fi
Load the changes:
加载更改:
$ source .bash_profile
Make a bin directory:
创建一个 bin 目录:
$ mkdir ~/bin
Download ack (from the homepage):
下载 ack(从主页):
$ curl https://beyondgrep.com/ack-2.22-single-file > ~/bin/ack && chmod 0755 ~/bin/ack
Note:you will have to manually install curl as it doesn't come with cygwin by default.
注意:您必须手动安装 curl,因为默认情况下它不随 cygwin 一起提供。
回答by Jay
You should also run the following command to enable color highlights: cpan Win32::Console::ANSI
您还应该运行以下命令来启用颜色高亮: cpan Win32::Console::ANSI
回答by Tom
I had to force cpan to install App::Ack
since some of the tests didn't pass:
App::Ack
由于某些测试未通过,我不得不强制安装 cpan :
C:\> cpan
cpan> force install App::Ack
cpan> q
回答by h-rai
回答by Jim Hunziker
Depending on how you feel about installing pre-built binaries from open source projects, you might also consider The Silver Searcher (ag). It's ack-compatible and faster than ack. It's also available on Linux from the repositories in recent distros.
根据您对从开源项目安装预构建二进制文件的感受,您还可以考虑 The Silver Searcher (ag)。它与 ack 兼容并且比 ack 更快。它也可以在 Linux 上从最近发行版的存储库中获得。
http://blog.kowalczyk.info/software/the-silver-searcher-for-windows.html
http://blog.kowalczyk.info/software/the-silver-searcher-for-windows.html
回答by netsmith
You can install ack via cpan:
您可以通过 cpan 安装 ack:
install strawberry perl
安装草莓 perl
run cmd as admin
以管理员身份运行cmd
install ack:
安装确认:
cpan> force install App::Ack
cpan> 强制安装 App::Ack
it should work from there, followed this guide: http://www.jeedo.net/how-to-install-ack-on-windows-10/
它应该从那里开始工作,遵循本指南:http: //www.jeedo.net/how-to-install-ack-on-windows-10/
Worked without any hitches.
工作没有任何障碍。