如何使用命令行检查是否安装了 c-blosc?
How can I check if c-blosc is installed using the command line?
使用 command -v c-blosc
returns 什么都没有,即使它已安装
c-blosc 将自己描述为 compression library,因此它不是命令
我试过的一些东西
% c-blosc
zsh: command not found: c-blosc
where c-blosc
c-blosc not found
brew install c-blosc
...
Warning: c-blosc 1.21.0 is already installed and up-to-date.
To reinstall 1.21.0, run:
brew reinstall c-blosc
% brew info c-blosc
c-blosc: stable 1.21.0 (bottled)
Blocking, shuffling and loss-less compression library
https://blosc.org/
/usr/local/Cellar/c-blosc/1.21.0 (10 files, 1.7MB) *
Poured from bottle on 2021-07-07 at 23:44:40
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/c-blosc.rb
License: BSD-3-Clause
==> Dependencies
Build: cmake ✘
==> Analytics
install: 312 (30 days), 1,190 (90 days), 3,168 (365 days)
install-on-request: 249 (30 days), 998 (90 days), 2,263 (365 days)
build-error: 0 (30 days)
brew search c-blosc
==> Formulae
c-blosc ✔
以下
if [ brew info c-blosc 2>&1 >/dev/null ]; then
echo "Installed"
else
echo "Nope"
fi
和
if [ brew search c-blosc 2>&1 >/dev/null ]; then
echo "Installed"
else
echo "Nope"
fi
尽管我安装了它,但它们都打印 Nope
根据https://apple.stackexchange.com/q/145437,你可以做到
brew info c-blosc
除其他外,这将打印安装位置。
您可以使用相关命令,例如 search
:
brew search c-blosc
唯一明确 documented 到 return 缺少公式的失败代码是
brew --prefix --installed c-blosc
它没有具体的输出,所以你可以做
if brew --prefix --installed c-blosc 2>/dev/null; then
echo "Installed"
else
echo "Nope"
fi
由于 c-blosc
软件包不包含任何命令,您将无法找到是否使用以下任一命令安装它:
command c-blosc
type c-blosc
该包实际上提供了一个动态的link库和一个头文件,您可以使用以下命令列出包内容来查看:
brew ls c-blosc
/usr/local/Cellar/c-blosc/1.21.0/include/ (2 files)
/usr/local/Cellar/c-blosc/1.21.0/lib/libblosc.1.21.0.dylib
/usr/local/Cellar/c-blosc/1.21.0/lib/pkgconfig/blosc.pc
/usr/local/Cellar/c-blosc/1.21.0/lib/ (3 other files)
现在 homebrew 在 /usr/local/lib
中创建符号 links 供您 link 您的程序反对 - 让我们看一下:
ls -l /usr/local/lib/*blosc*
lrwxr-xr-x 1 mark admin 50 14 Jul 07:52 /usr/local/lib/libblosc.1.21.0.dylib -> ../Cellar/c-blosc/1.21.0/lib/libblosc.1.21.0.dylib
lrwxr-xr-x 1 mark admin 45 14 Jul 07:52 /usr/local/lib/libblosc.1.dylib -> ../Cellar/c-blosc/1.21.0/lib/libblosc.1.dylib
lrwxr-xr-x 1 mark admin 39 14 Jul 07:52 /usr/local/lib/libblosc.a -> ../Cellar/c-blosc/1.21.0/lib/libblosc.a
lrwxr-xr-x 1 mark admin 43 14 Jul 07:52 /usr/local/lib/libblosc.dylib -> ../Cellar/c-blosc/1.21.0/lib/libblosc.dylib
因此,最通用的是 libblosc.dylib
,无论版本如何,它都会存在,因此我将使用它作为我的测试:
if [ -e /usr/local/lib/libblosc.dylib ] ; then echo "Installed" ; fi
请注意,您可以 更明确地测试该文件是否存在 并且是 link 与 if [ -L ... ]
但如果 liblosc
是通过某些非符号-linking 方法安装的,则 可能 不起作用,例如来自可能将实际库复制到该位置而不是制作 symlink.
的源
另一个可行的替代命令如下,它向您显示给定 homebrew 包的安装位置:
brew --prefix --installed c-blosc
/usr/local/opt/c-blosc
echo $?
0
相对于:
brew --prefix --installed MadeUpNonExistentPackage
Error: No available formula with the name "madeupnonexistentpackage".
echo $?
1
使用 command -v c-blosc
returns 什么都没有,即使它已安装
c-blosc 将自己描述为 compression library,因此它不是命令
我试过的一些东西
% c-blosc
zsh: command not found: c-blosc
where c-blosc
c-blosc not found
brew install c-blosc
...
Warning: c-blosc 1.21.0 is already installed and up-to-date.
To reinstall 1.21.0, run:
brew reinstall c-blosc
% brew info c-blosc
c-blosc: stable 1.21.0 (bottled)
Blocking, shuffling and loss-less compression library
https://blosc.org/
/usr/local/Cellar/c-blosc/1.21.0 (10 files, 1.7MB) *
Poured from bottle on 2021-07-07 at 23:44:40
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/c-blosc.rb
License: BSD-3-Clause
==> Dependencies
Build: cmake ✘
==> Analytics
install: 312 (30 days), 1,190 (90 days), 3,168 (365 days)
install-on-request: 249 (30 days), 998 (90 days), 2,263 (365 days)
build-error: 0 (30 days)
brew search c-blosc
==> Formulae
c-blosc ✔
以下
if [ brew info c-blosc 2>&1 >/dev/null ]; then
echo "Installed"
else
echo "Nope"
fi
和
if [ brew search c-blosc 2>&1 >/dev/null ]; then
echo "Installed"
else
echo "Nope"
fi
尽管我安装了它,但它们都打印 Nope
根据https://apple.stackexchange.com/q/145437,你可以做到
brew info c-blosc
除其他外,这将打印安装位置。
您可以使用相关命令,例如 search
:
brew search c-blosc
唯一明确 documented 到 return 缺少公式的失败代码是
brew --prefix --installed c-blosc
它没有具体的输出,所以你可以做
if brew --prefix --installed c-blosc 2>/dev/null; then
echo "Installed"
else
echo "Nope"
fi
由于 c-blosc
软件包不包含任何命令,您将无法找到是否使用以下任一命令安装它:
command c-blosc
type c-blosc
该包实际上提供了一个动态的link库和一个头文件,您可以使用以下命令列出包内容来查看:
brew ls c-blosc
/usr/local/Cellar/c-blosc/1.21.0/include/ (2 files)
/usr/local/Cellar/c-blosc/1.21.0/lib/libblosc.1.21.0.dylib
/usr/local/Cellar/c-blosc/1.21.0/lib/pkgconfig/blosc.pc
/usr/local/Cellar/c-blosc/1.21.0/lib/ (3 other files)
现在 homebrew 在 /usr/local/lib
中创建符号 links 供您 link 您的程序反对 - 让我们看一下:
ls -l /usr/local/lib/*blosc*
lrwxr-xr-x 1 mark admin 50 14 Jul 07:52 /usr/local/lib/libblosc.1.21.0.dylib -> ../Cellar/c-blosc/1.21.0/lib/libblosc.1.21.0.dylib
lrwxr-xr-x 1 mark admin 45 14 Jul 07:52 /usr/local/lib/libblosc.1.dylib -> ../Cellar/c-blosc/1.21.0/lib/libblosc.1.dylib
lrwxr-xr-x 1 mark admin 39 14 Jul 07:52 /usr/local/lib/libblosc.a -> ../Cellar/c-blosc/1.21.0/lib/libblosc.a
lrwxr-xr-x 1 mark admin 43 14 Jul 07:52 /usr/local/lib/libblosc.dylib -> ../Cellar/c-blosc/1.21.0/lib/libblosc.dylib
因此,最通用的是 libblosc.dylib
,无论版本如何,它都会存在,因此我将使用它作为我的测试:
if [ -e /usr/local/lib/libblosc.dylib ] ; then echo "Installed" ; fi
请注意,您可以 更明确地测试该文件是否存在 并且是 link 与 if [ -L ... ]
但如果 liblosc
是通过某些非符号-linking 方法安装的,则 可能 不起作用,例如来自可能将实际库复制到该位置而不是制作 symlink.
另一个可行的替代命令如下,它向您显示给定 homebrew 包的安装位置:
brew --prefix --installed c-blosc
/usr/local/opt/c-blosc
echo $?
0
相对于:
brew --prefix --installed MadeUpNonExistentPackage
Error: No available formula with the name "madeupnonexistentpackage".
echo $?
1