sportngin / brew-gem

Install gems as homebrew formulas
MIT License
198 stars 22 forks source link

asciidoctor-diagram #70

Open marmalodak opened 3 years ago

marmalodak commented 3 years ago

The following worked well:

brew install brew-gem
brew gem install asciidoctor-diagram

However, using asciidoctor-diagram doesn't seem to work:

asciidoctor --trace -b html5 -r asciidoctor-diagram index.adoc
Traceback (most recent call last):
        10: from /opt/brew/Cellar/asciidoctor/2.0.13/libexec/bin/asciidoctor:23:in `<main>'
         9: from /opt/brew/Cellar/asciidoctor/2.0.13/libexec/bin/asciidoctor:23:in `load'
         8: from /opt/brew/Cellar/asciidoctor/2.0.13/libexec/gems/asciidoctor-2.0.13/bin/asciidoctor:13:in `<top (required)>'
         7: from /opt/brew/Cellar/asciidoctor/2.0.13/libexec/gems/asciidoctor-2.0.13/bin/asciidoctor:13:in `new'
         6: from /opt/brew/Cellar/asciidoctor/2.0.13/libexec/gems/asciidoctor-2.0.13/lib/asciidoctor/cli/invoker.rb:24:in `initialize'
         5: from /opt/brew/Cellar/asciidoctor/2.0.13/libexec/gems/asciidoctor-2.0.13/lib/asciidoctor/cli/options.rb:34:in `parse!'
         4: from /opt/brew/Cellar/asciidoctor/2.0.13/libexec/gems/asciidoctor-2.0.13/lib/asciidoctor/cli/options.rb:275:in `parse!'
         3: from /opt/brew/Cellar/asciidoctor/2.0.13/libexec/gems/asciidoctor-2.0.13/lib/asciidoctor/cli/options.rb:275:in `each'
         2: from /opt/brew/Cellar/asciidoctor/2.0.13/libexec/gems/asciidoctor-2.0.13/lib/asciidoctor/cli/options.rb:277:in `block in parse!'
         1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- asciidoctor-diagram (LoadError)

What can I do to make this work?

NickLaMuro commented 3 years ago

@marmalodak This is a bit of a invalid use case for brew gem since you are really doing:

brew install brew-gem
brew gem install asciidoctor
brew gem install asciidoctor-diagram

In which you are installing asciidoctor with a plugin, asciidoctor-diagram. As mentioned in the README.md:

brew gem allows you to install any rubygem as a homebrew formula.

It works by generating a stub formula for homebrew...

This formula installs and unpacks all the dependencies under the Cellar path. So the package is completely self contained.

The "self contained" part being the key words here. You can see what I mean by taking a look at the generated bin file for your asciidoctor installation:

$ which asciidoctor
/usr/local/bin/asciidoctor
#!/usr/local/opt/ruby/bin/ruby --disable-gems
ENV['GEM_HOME']="/usr/local/Cellar/gem-asciidoctor/2.0.15"
ENV['GEM_PATH']="/usr/local/Cellar/gem-asciidoctor/2.0.15"
require 'rubygems'
$:.unshift("/usr/local/Cellar/gem-asciidoctor/2.0.15/gems/asciidoctor-2.0.15/lib")
load "/usr/local/Cellar/gem-asciidoctor/2.0.15/gems/asciidoctor-2.0.15/bin/asciidoctor"

The /usr/local/Cellar/gem-asciidoctor/2.0.15 is the self contained gem path. This means that the brew gem install asciidoctor-diagram was placed into it's own /usr/local/Cellar/gem-asciidoctor-diagram dir, and the asciidoctor bin has no knowledge of it's existence.


An unsupported work around for this is the following:

$ brew gem install asciidoctor
$ export GEM_HOME=/usr/local/Cellar/gem-asciidoctor/2.0.15
$ export GEM_PATH=/usr/local/Cellar/gem-asciidoctor/2.0.15
/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/gem install asciidoctor-diagram

But I think at this point, the use case for using brew gem in this fashion is less desirable.

marmalodak commented 3 years ago

Thank you for your thoughtful response.