用homebrew安装optipng:找不到命令(rbenv?)

时间:2015-02-27 10:01:20

标签: macos terminal rubygems homebrew rbenv

我已经成功安装了optipng:

  $ brew install optipng
  ==> Downloading https://downloads.sourceforge.net/project/optipng/OptiPNG/optipng-0.7.5/optipng-0.7.5.tar.gz
  Already downloaded: /Library/Caches/Homebrew/optipng-0.7.5.tar.gz
  ==> Patching
  patching file src/optipng/osys.c
  ==> ./configure --with-system-zlib --prefix=/usr/local/Cellar/optipng/0.7.5 --mandir=/usr/local/Cellar/optipng/0.7.5/share/man
  ==> make install
    /usr/local/Cellar/optipng/0.7.5: 6 files, 156K, built in 2 seconds

但是当我使用命令它时会说:

$ optipng
rbenv: optipng: command not found

The `optipng' command exists in these Ruby versions:
  jruby-1.7.10
  jruby-1.7.11
  jruby-1.7.9

如果我使用此路径/usr/local/Cellar/optipng/0.7.5/bin/optipng它可以正常工作!!

这与rbenv有关吗?或者为什么optipng命令不是全局的?

$ rbenv global
1.9.3-p429

我还尝试了brew unlink optipngbrew link optipng - >同样的错误!

1 个答案:

答案 0 :(得分:1)

好的,我发现我的一个项目安装了image_optim_bin gem,在为所有ruby版本卸载这个gem后,命令终于有效了!

$ gem uninstall image_optim_bin
Remove executables:
  advdef, advmng, advpng, advzip, jpegoptim, jpegtran, optipng, pngcrush, pngout

in addition to the gem? [Yn]  
Removing advdef
Removing advmng
Removing advpng
Removing advzip
Removing jpegoptim
Removing jpegtran
Removing optipng
Removing pngcrush
Removing pngout
Successfully uninstalled image_optim_bin-0.0.4 

打开新终端,现在可以运行:

$ optipng
Synopsis:
    optipng [options] files ...
Files:
    Image files of type: PNG, BMP, GIF, PNM or TIFF
Basic options:
    -?, -h, -help show the extended help
    -o <level>    optimization level (0-7)    [default: 2]
    -v      run in verbose mode / show copyright and version info