Ruby:安装一个被淘汰的gem(例如OS X 10.9上的wkpdf)

时间:2015-03-24 00:45:07

标签: ruby macos rubygems osx-mavericks

我想根据https://apple.stackexchange.com/questions/122176/convert-html-to-pdf-with-page-margins-and-hyperlinks安装wkpdf,但是,根据http://plessl.github.io/wkpdf/https://rubygems.org/gems/wkpdf,宝石“wkpdf”被“猛拉”,即使它最有可能仍处于工作状态。

% sudo gem install wkpdf
ERROR:  Could not find a valid gem 'wkpdf' (>= 0) in any repository
11.556u 0.437s 0:29.63 40.4%    0+0k 57+1io 363pf+0w

有没有办法安装呢?我正在运行OS X 10.9,gem -v返回2.0

2 个答案:

答案 0 :(得分:2)

该项目仍然在线:

https://github.com/plessl/wkpdf

您可以执行以下操作:

$ wget https://github.com/plessl/wkpdf/archive/v0.6.11.tar.gz
$ tar -xf v0.6.11.tar.gz
$ cd wkpdf-0.6.11
$ gem build wkpdf.gemspec
$ sudo gem install wkpdf-0.6.11-universal-darwin.gem

答案 1 :(得分:1)

看起来网页提供了对相关gem文件的引用:

% curl https://rubygems.org/gems/wkpdf |& fgrep Download
        <a id="download" class="gem__link t-list__item" href="/downloads/wkpdf-0.6.11-universal-darwin.gem">Download</a>

所以,只需对其进行wget,它就可以在本地进行安装:

% wget https://rubygems.org/downloads/wkpdf-0.6.11-universal-darwin.gem

% sudo gem install wkpdf
Fetching: trollop-2.1.2.gem (100%)
Successfully installed trollop-2.1.2
Successfully installed wkpdf-0.6.11-universal-darwin
Parsing documentation for trollop-2.1.2
Installing ri documentation for trollop-2.1.2
Parsing documentation for wkpdf-0.6.11-universal-darwin
Installing ri documentation for wkpdf-0.6.11-universal-darwin
2 gems installed
2.603u 0.478s 0:15.32 20.0% 0+0k 186+56io 403pf+0w
% wkpdf
Cannot load RubyCocoa library
wkpdf requires that RubyCocoa is installed, which is shipped by default since
Mac OS X 10.5. If you use Mac OS X 10.4, you have to install RubyCocoa
yourself from http://rubycocoa.sourceforge.net/HomePage

但是,在wkpdf的特定情况下,它似乎还需要RubyCocoa(根据https://github.com/plessl/wkpdf/issues/45,首先来自http://www.google.ru/search?q=rubycocoa+10.9),它只适用于Ruby 1.8,而不是使用2.0(在OS X 10.9上已经成为默认值,即使还安装了Ruby 1.8)。

因此,必须从2.0卸载wkpdf,并将其安装到1.8:

% sudo gem uninstall wkpdf

% sudo /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem install wkpdf
Successfully installed trollop-2.1.2
Successfully installed wkpdf-0.6.11-universal-darwin
2 gems installed
Installing ri documentation for trollop-2.1.2...
Installing ri documentation for wkpdf-0.6.11-universal-darwin...
Installing RDoc documentation for trollop-2.1.2...
Installing RDoc documentation for wkpdf-0.6.11-universal-darwin...
4.275u 0.252s 0:11.27 40.1% 0+0k 26+26io 3pf+0w
% wkpdf
Error: option --output must be specified.
Try --help for help.

总之,在OS X 10.9上:

wget https://rubygems.org/downloads/wkpdf-0.6.11-universal-darwin.gem

sudo /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem install wkpdf

wkpdf --source http://www.apple.com --output apple.wkpdf.pdf; open apple.wkpdf.pdf`