作为磁悬浮的新手,我想从一个小但仍然有用的例子开始。所以我决定开始将用于生成发票的 ruby 类转移到磁悬浮。但是,我在使用(优秀的)虾 PDF 库时遇到了一个意想不到的问题。
在 rvm 上,我为应用程序生成了一个 gemset,它在发票目录的 .rvmrc 中设置。当我 cd 进入它时它会被使用:
Using /Users/patru/.rvm/gems/maglev-head with gemset invoice
当我安装大虾时,一切都开始正常,gem 似乎已安装并且正在生成 ri-docs。但是,当应该创建 rdoc 时,麻烦就开始了,maglev 提供的 gem 命令给了我
gem install prawn
[INFO] The MagLev team publishes customized versions of some gems.
...
Successfully installed prawn-0.12.0
1 gem installed
Installing ri documentation for prawn-0.12.0...
RDoc failure in lib/prawn/images/jpg.rb at or around line 20 column 26
Before reporting this, could you check that the file
you're documenting compiles cleanly--RDoc is not a
full Ruby parser, and gets confused easily if fed
invalid programs.
The internal error was:
ERROR: While generating documentation for prawn-0.12.0
... MESSAGE: global $@ is a read-only variable
... RDOC args: --ri --op /Users/patru/.rvm/gems/maglev-head@invoice/doc/prawn-0.12.0/ri --title Prawn Documentation --main README -q lib README.md LICENSE COPYING GPLv2 GPLv3 --title prawn-0.12.0 Documentation --quiet
a RubySystemExit occurred (error 2752)
没有文档也没什么大不了的,这已经足够了,但似乎还有其他问题,gem list 说
Ascii85 (1.0.1)
bundler (1.0.21)
erector (0.8.3)
pdf-reader (0.10.1)
polyglot (0.3.3)
prawn (0.12.0)
rake (0.9.2)
treetop (1.4.10)
ttfunk (1.0.3)
所以一切似乎都很好,但如果我这样做
require 'ruby gems'
require 'prawn'
在 irb 中(在我的 ree-1.8.7 上完美运行)我感到很奇怪
NoMethodError: NoMethodError: undefined method `ruby_18' for
from /Users/patru/.rvm/gems/maglev-head@invoice/gems/prawn-0.12.0/lib/prawn/core/object_store.rb:246:in `__compileClass'
from /Users/patru/.rvm/gems/maglev-head@invoice/gems/prawn-0.12.0/lib/prawn/core/object_store.rb:14:in `__compileClass'
from /Users/patru/.rvm/gems/maglev-head@invoice/gems/prawn-0.12.0/lib/prawn/core/object_store.rb:13:in `__compileClass'
from /Users/patru/.rvm/gems/maglev-head@invoice/gems/prawn-0.12.0/lib/prawn/core/object_store.rb:12
from /Users/patru/.rvm/rubies/maglev-head/src/kernel/bootstrap/Kernel.rb:831:in `gem_original_require'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:57:in `require'
from /Users/patru/.rvm/gems/maglev-head@invoice/gems/prawn-0.12.0/lib/prawn/core.rb:78
from /Users/patru/.rvm/rubies/maglev-head/src/kernel/bootstrap/Kernel.rb:831:in `gem_original_require'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:57:in `require'
from /Users/patru/.rvm/gems/maglev-head@invoice/gems/prawn-0.12.0/lib/prawn.rb:11
from /Users/patru/.rvm/rubies/maglev-head/src/kernel/bootstrap/Kernel.rb:831:in `gem_original_require'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:59:in `require'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:57:in `require'
from /Users/patru/.rvm/rubies/maglev-head/src/kernel/bootstrap/Kernel.rb:831:in `gem_original_require'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:57:in `require'
from (irb):5:in `__compileEval'
from (irb):7:in `__compileEval'
from /Users/patru/.rvm/rubies/maglev-head/src/kernel/bootstrap/Kernel.rb:394:in `eval'
from /Users/patru/.rvm/rubies/maglev-head/lib/ruby/1.8/irb.rb:159:in `eval_input'
...
我可能在这里遗漏了一些明显的东西。可以说我安装的“竖立器”gem(参见上面的 gem 列表)可以毫无问题地被要求,所以我没有做错一切;-)