<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Solution on Notes</title>
    <link>https://www.simplicidade.org/tags/solution/index.xml</link>
    <description>Recent content in Solution on Notes</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <managingEditor>melo@simplicidade.org (Pedro Melo)</managingEditor>
    <webMaster>melo@simplicidade.org (Pedro Melo)</webMaster>
    <copyright>(c) 2016 Pedro Melo.</copyright>
    <atom:link href="/tags/solution/index.xml" rel="self" type="application/rss+xml" />
    <atom:link rel="hub" href="https://pubsuhhubbub.superfeedr.com/"/>
    
    <item>
      <title>DBD::mysql fails to install on Mac OS X</title>
      <link>https://www.simplicidade.org/errors/dbd_mysql_macos_lion/</link>
      <pubDate>Mon, 01 Aug 2016 18:59:05 +0100</pubDate>
      <author>melo@simplicidade.org (Pedro Melo)</author>
      <guid>https://www.simplicidade.org/errors/dbd_mysql_macos_lion/</guid>
      <description>&lt;p&gt;Some versions of &lt;a href=&#34;https://metacpan.org/release/DBD-mysql&#34;&gt;DBD::mysql&lt;/a&gt; fail to install on Mac OS X with this error:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;DBI Connection failed: install_driver(mysql) failed: Can&#39;t load &#39;.../lib/perl5/darwin-2level/auto/DBD/mysql/mysql.bundle&#39; for module DBD::mysql: dlopen(.../lib/perl5/darwin-2level/auto/DBD/mysql/mysql.bundle, 1): Library not loaded: libmysqlclient.18.dylib
#   Referenced from: .../lib/perl5/darwin-2level/auto/DBD/mysql/mysql.bundle
#   Reason: image not found at .../lib/5.16.3/darwin-2level/DynaLoader.pm line 194.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The issue is that for some reason the DBD::mysql &lt;code&gt;mysql.bundle&lt;/code&gt; references a relative path to &lt;code&gt;libmysqlclient.18.dylib&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To check you can do:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;otool -L .../lib/perl5/darwin-2level/auto/DBD/mysql/mysql.bundle
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Check that &lt;code&gt;libmysqlclient.18.dylib&lt;/code&gt; file that the bundle references is a relative path or does not exist.&lt;/p&gt;

&lt;p&gt;To work around the issue, I use this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;chmod 755 mysql.bundle
install_name_tool -change libmysqlclient.18.dylib \
    /usr/local/mysql/lib/libmysqlclient.18.dylib  \
    mysql.bundle
chmod 555 mysql.bundle
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Replace &lt;code&gt;/usr/local/mysql/lib/libmysqlclient.18.dylib&lt;/code&gt; with the full path of &lt;code&gt;libmysqlclient.18.dylib&lt;/code&gt; on your system.&lt;/p&gt;
</description>
    </item>
    
    <item>
      <title>LibMagic regexp error 17</title>
      <link>https://www.simplicidade.org/errors/libmagic_regext_error_17/</link>
      <pubDate>Mon, 01 Aug 2016 18:41:32 +0100</pubDate>
      <author>melo@simplicidade.org (Pedro Melo)</author>
      <guid>https://www.simplicidade.org/errors/libmagic_regext_error_17/</guid>
      <description>&lt;p&gt;Got the following error using &lt;a href=&#34;https://metacpan.org/release/File-LibMagic&#34;&gt;File::LibMagic&lt;/a&gt; (uses libmagic):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;error calling magic_file: line 163: regex error 17, (illegal byte sequence)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is usually caused by two separate issues:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;first, you are probably using an old version of libmagic. Version 5.17 had problems for me, but a &lt;code&gt;brew upgrade libmagic&lt;/code&gt; updated to 5.25;&lt;/li&gt;
&lt;li&gt;second, &lt;code&gt;libmagic&lt;/code&gt; is very sensible to ENV&amp;rsquo;s &lt;code&gt;LC_CTYPE&lt;/code&gt; and &lt;code&gt;LC_LANG&lt;/code&gt;. Set both temporarily to &lt;code&gt;C&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One or both of this two actions will need to be used to solve the issue.&lt;/p&gt;

&lt;p&gt;More information on this ticket: &lt;a href=&#34;https://trac.macports.org/ticket/38771&#34;&gt;https://trac.macports.org/ticket/38771&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I wrote a small utility function that takes care of all the details of figuring out the mime_type of a file:&lt;/p&gt;

&lt;pre&gt;&lt;code class=&#34;language-perl&#34;&gt;sub mime_type {
  my ($path, $default) = @_;

  return $default unless eval { require File::LibMagic };
  $path = $path-&amp;gt;stringify if blessed($path); ## Path::Tiny support

  ## We need the ENV&#39;s to avoid https://trac.macports.org/ticket/38771
  local $ENV{LC_CTYPE} = &#39;C&#39;;
  local $ENV{LANG}     = &#39;C&#39;;
  state $fm = File::LibMagic-&amp;gt;new;
  my $info = $fm-&amp;gt;info_from_filename($path);

  return $info-&amp;gt;{mime_type} if $info and $info-&amp;gt;{mime_type};
  return $default;
}
&lt;/code&gt;&lt;/pre&gt;
</description>
    </item>
    
  </channel>
</rss>