使用自制软件安装 optipng:找不到命令(rbenv?)

Installing optipng with homebrew: command not found (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 -> 同样的错误!

好的,我发现我在我的一个项目中安装了 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