Installing nokogiri with --use-system-libraries (was: Re: Migrating the guide to AsciiDoc)

Mojca Miklavec mojca at macports.org
Tue Apr 24 05:50:29 UTC 2018


Hi,

On 23 April 2018 at 17:42, Rainer Müller wrote:
>
> Ruby and gems are really strange...
>
> Apparently, installing nokogiri with bundle fails

Wasn't it you who said that we don't need a port for it as it's just a
one-time conversion? :)
(I'm honestly not sure who said that.)

Looking at how elegant the asciidoctor port is ... I still believe we
should make a port for docbookrx.
(I guess someone first needs to document how to use a ruby portgroup,
so we need to get the conversion to asciidoc done first, right? :) :)
:)

> Here is a way to get it working:
>
> $ git clone https://github.com/asciidoctor/docbookrx
> $ cd docbookrx
> $ sudo port install rb23-bundler
> $ bundle-2.3 config --local build.nokogiri --use-system-libraries --with-xml2-dir=/opt/local --with-xml2-include=/opt/local/include/libxml2 --with-xslt-dir=/opt/local --with-zlib-dir=/opt/local --with-exslt-dir=/opt/local --without-pkg-config
> $ bundle-2.3 install --path=.bundle/gems

Installing gems is a genuinely error-prone process on Mac, you can
find lots and lots of reports of broken behaviour and they are not
always responsive, sometimes deleting comments from tickets etc.

One example (which eventually got fixed, but there are a number of those):
    https://github.com/sparklemotion/nokogiri/issues/1423
(I would have linked to another ticket, but my comments were boldly deleted.)

I was initially following this procedure:
    https://gorails.com/setup/osx/10.13-high-sierra
basically
    sudo port install rbenv ruby-build
(which should be up to date) and then installed bundler with rbenv.
For once, it magically worked and I was surprised since I've been
fighting with issues for years (on admittedly an older OS).

I have huge philosophical problems with this line:
    --use-system-libraries --with-xml2-dir=/opt/local
--with-xml2-include=/opt/local/include/libxml2
--with-xslt-dir=/opt/local --with-zlib-dir=/opt/local
--with-exslt-dir=/opt/local
because this will lead to broken software as soon as one updates some
libraries under MacPorts. (Does HomeBrew ever delete old versions or
do their old versions of libraries remain installed forever until the
user removes them?)

I did not use any of those workarounds this time for once (I didn't
use external libraries).

You'll get an impression about the quality of the build system by
reading this (copy-pasted at the bottom) as "reference installation
instructions":
    http://installrails.com/steps/install_rails

> Then go to the guide/xml/ directory of macports-guide:
>
> $ BUNDLE_GEMFILE=~/src/docbookrx/Gemfile bundle-2.3 exec docbookrx guide.xml
> $ mv *.adoc ../adoc/

I eventually managed to use
    ~/app/docbookrx/bin/docbookrx guide.xml
but I also didn't manage to make docbookrx a simple executable that I
could put or symlink into PATH.

On 24 April 2018 at 00:23, Rainer Müller wrote:
> On 2018-04-23 20:35, Andrew Moore wrote:
>> You might try:
>>
>> $ sudo gem update —system
>>
>> which should install the latest version of bundler (you really want that), and go from there.
>> In the particular case of nokogiri, you might also try running `gem install nokogiri` as user root.
>
> I am very cautious about running third-party package managers as root
> and let them write to ${prefix}. That is supposed to be managed by
> MacPorts and no other package manager should update files.

Brrrr .... no!!!
Why "sudo gem"? This sounds like a terrible idea. You should
absolutely install gems locally, not as sudo, and in particular not
under /opt/local.

Mojca


PS: Quotation from http://installrails.com/steps/install_rails:

If Rails cannot install, check the failure message. if it contains:

    -----
    libxml2 is missing.  Please locate mkmf.log to investigate how it
is failing.
    -----

and you are using OS X 10.10 or later, then run:

    brew install libxml2
    env ARCHFLAGS="-arch x86_64" gem install nokogiri:1.6.4.1 --
--use-system-libraries --with-xml=/usr/local/Cellar/libxml2/

to install libxml2 and nokogiri and rerun the rails instalation.

Else, try running the code below and then restarting your computer:

    brew install apple-gcc42


More information about the macports-dev mailing list