{"id":2284,"date":"2020-07-07T09:27:28","date_gmt":"2020-07-07T14:27:28","guid":{"rendered":"https:\/\/thepizzy.net\/blog\/?p=2284"},"modified":"2022-02-23T10:45:54","modified_gmt":"2022-02-23T16:45:54","slug":"solved-php-dyld-library-not-loaded","status":"publish","type":"post","link":"https:\/\/thepizzy.net\/blog\/2020\/07\/solved-php-dyld-library-not-loaded\/","title":{"rendered":"Solved &#8211; PHP, dyld: Library not loaded"},"content":{"rendered":"\n<p class=\"has-drop-cap\">I mistakenly ran <code>brew upgrade<\/code> on my macOS Catalina without thinking about how it would impact my production development environment during work, and quickly realized I messed up big time.<\/p>\n\n\n\n<figure class=\"wp-block-pullquote\"><blockquote><p>To fix it, install openssl &amp; icu4c, edit the php 5.6 source (see post for details), and reinstall php 5.6 from source to overwrite.<\/p><cite>131 characters<\/cite><\/blockquote><\/figure>\n\n\n\n<!--more-->\n\n\n\n<p>My production environment has to use PHP 5.6.40 because of some legacy plugins that do not exist, or were not installed with a package manager (e.g. composer) because it didn&#8217;t exist at the time, and the business has not decided to invest the time to update all the features to use newer versions&#8230;and in some cases there are no newer versions. <\/p>\n\n\n\n<p>So after updating my environment, I had to make sure I didn&#8217;t get put back on PHP 7.4.x, and was still on PHP 5.6. I was, but it was now broken.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Error Messages<\/h2>\n\n\n\n<p>The first error message I got when trying to check the PHP version<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tsnMac:~ neotsn$ php -v\ndyld: Library not loaded: \/usr\/local\/opt\/openssl\/lib\/libcrypto.1.0.0.dylib\n  Referenced from: \/usr\/local\/bin\/php\n  Reason: image not found\nAbort trap: 6<\/code><\/pre>\n\n\n\n<p>This is because macOS has its own SSL library installed, and PHP 5.6 requires OpenSSL&#8230;and isn&#8217;t compatible with OpenSSL 1.1, which is what got installed in the update.<\/p>\n\n\n\n<p>After reinstalling OpenSSL 1.0 from a direct package link, I encountered the next message, which was much more difficult to solve, since <code>icu4c<\/code> is covered by macOS Data Integrity Protection.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dyld: Library not loaded: \/usr\/local\/opt\/icu4c\/lib\/libicui18n.64.dylib\n  Referenced from: \/usr\/local\/Cellar\/php@5.6\/5.6.40\/bin\/php\n  Reason: image not found<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">The Fixes<\/h2>\n\n\n\n<p>Thanks to the instructions over in <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/eXolnet\/homebrew-deprecated\/issues\/23#issuecomment-619976586\" target=\"_blank\">this Github Issue<\/a> from <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/JParkinson1991\" target=\"_blank\">JParkinson1991<\/a>, and various other articles and blogs around the internet I&#8217;ve pieced together this solution, but his updated comment provided the majority of the answer.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Starting over?<\/h3>\n\n\n\n<p>Obviously you&#8217;re going to need Homebrew, which you probably already have if you&#8217;re here&#8230; but in case you wiped your hard disk (as I did) and have to start over&#8230;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Install Homebrew\n\/usr\/bin\/ruby -e \"$(curl -fsSL https:\/\/raw.githubusercontent.com\/Homebrew\/install\/master\/install)\"\n\n# Bring in deprecated php versions\nbrew tap exolnet\/homebrew-deprecated<\/code><\/pre>\n\n\n\n<p>Now you&#8217;ll have Homebrew installed and the deprecated PHP versions available to you.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Update these packages<\/h3>\n\n\n\n<p>Before you start down the path, make sure the problematic packages (<code>openssl<\/code> and <code>icu4c<\/code>) are at the latest versions (and indeed installed).<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Make sure these are at the latest versions\nbrew install openssl &amp;&amp; brew upgrade openssl\nbrew upgrade icu4c<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Patching PHP 5.6<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">Note: This will soon be fixed<\/h4>\n\n\n\n<p>At the time of this writing, there exists a <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/eXolnet\/homebrew-deprecated\/pull\/25\" target=\"_blank\">merge request for the php@5.6 package<\/a> where the following patch will no longer be required. I do not have instructions on what to do once it has been, but presumably this article will never reach your eyeballs if you have the latest version of these <a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/eXolnet\/homebrew-deprecated\" target=\"_blank\">eXolnet<\/a> repositories.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">The patch&#8230;<\/h4>\n\n\n\n<p>If the above merge request is still outstanding, then let&#8217;s edit the <code>php@5.6<\/code> package&#8230;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Edit php@5.6 to add a patch \nbrew edit php@5.6<\/code><\/pre>\n\n\n\n<p>This will open up the edited file in vim (or at least it did for me). So jump to line 45-48. Look for the <code>def install<\/code> around there. Right before that line, insert these lines&#8230;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># At line 45, before the `def install` command, add these lines\npatch do\n  url \"https:\/\/raw.githubusercontent.com\/opencomputeproject\/Rack-Manager\/master\/Contrib-Inspur\/openbmc\/meta-openembedded\/meta-oe\/recipes-devtools\/php\/php\/0001-PHP-5.6-LibSSL-1.1-compatibility.patch\"\n  sha256 \"c9715b544ae249c0e76136dfadd9d282237233459694b9e75d0e3e094ab0c993\"\nend<\/code><\/pre>\n\n\n\n<p>Save your changes and exit with an <code>esc<\/code> press and a <code>:wq<\/code>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Reinstall <code>php@5.6<\/code> from source<\/h4>\n\n\n\n<p>Now that our package is different from what was downloaded, we need to reinstall it from that source&#8230;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Reinstall php@5.6 from the edited source\nbrew reinstall --build-from-source php@5.6<\/code><\/pre>\n\n\n\n<p>This will take a minute or two. When it&#8217;s done you should be able to do a <code>php -v<\/code> command to see that there are no more errors and you&#8217;re on the correct version.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Run the checkup<\/h4>\n\n\n\n<p>Afterward, be sure to run the <code>doctor<\/code> and <code>cleanup<\/code> commands to make sure everything is both good, and clean.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Get a checkup\nbrew doctor\nbrew cleanup<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Minor Troubleshooting Suggestions<\/h4>\n\n\n\n<p>If you happen to see you&#8217;re not on the right version of PHP after this, you may have to do a forced overwrite link.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Only if php -v is not 5.6.x\nbrew link --overwrite --force php@5.6<\/code><\/pre>\n\n\n\n<p>If you need to have multiple versions of PHP installed, then you&#8217;re going to want <code>sphp<\/code> installed.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Install sphp to switch versions \ncurl -L https:\/\/gist.githubusercontent.com\/rhukster\/f4c04f1bf59e0b74e335ee5d186a98e2\/raw &gt; \/usr\/local\/bin\/sphp\n# Make it executable\nchmod +x \/usr\/local\/bin\/sphp<\/code><\/pre>\n\n\n\n<p>Then you&#8217;ll be able to switch between them with <code>sphp 5.6<\/code> or any other installed versions using their major\/minor version numbers.<\/p>\n\n\n\n<p>If you have trouble, you can try dropping a comment here, or onto the linked Github pages where there are better experts than I who may be able to help.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I mistakenly ran brew upgrade on my macOS Catalina without thinking about how it would impact my production development environment during work, and quickly realized I messed up big time. To fix it, install openssl &amp; icu4c, edit the php 5.6 source (see post for details), and reinstall php 5.6 from source to overwrite. 131 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2286,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[506,25,910,3],"tags":[983,982,977,986,980,976,984,985,981,975,979,152,978,987],"class_list":["post-2284","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-programming","category-tech-fixes","category-tech","tag-brew","tag-catalina","tag-dyld","tag-exolnet","tag-homebrew","tag-icu4c","tag-libcrypto-1-0-0-dylib","tag-libicui18n-64-dylib","tag-macos","tag-openssl","tag-patch","tag-php","tag-php-5-6","tag-sphp"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/thepizzy.net\/blog\/wp-content\/uploads\/2020\/07\/Screen-Shot-2020-07-07-at-9.40.21-AM.png?fit=1308%2C614&ssl=1","jetpack_likes_enabled":false,"jetpack_shortlink":"https:\/\/wp.me\/prOO4-AQ","jetpack-related-posts":[{"id":17,"url":"https:\/\/thepizzy.net\/blog\/2006\/03\/project-tsnxchat\/","url_meta":{"origin":2284,"position":0},"title":"Project: tsnXchat","author":"[[Neo]]","date":"March 1, 2006","format":false,"excerpt":"After using a flooble chatterbox from www.flooble.com, and trying to (unsuccessfully) hack it to get rid of the ads at the bottom, I have resolved to putting my newly developed AJAX skills to the test, to create an open-source version, with no ads. I'll explain how you can make one\u2026","rel":"","context":"In &quot;Projects&quot;","block_context":{"text":"Projects","link":"https:\/\/thepizzy.net\/blog\/category\/projects\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":67,"url":"https:\/\/thepizzy.net\/blog\/2006\/07\/update-tsnx-tsnx-lite-theme-et-al\/","url_meta":{"origin":2284,"position":1},"title":"Update: tsnX \u00e2\u20ac\u201c tsnX-lite theme, et al.","author":"[[Neo]]","date":"July 3, 2006","format":false,"excerpt":"So it's time for an update. The tsnX-lite theme is up, and has been since the LAN party. Let me know what you think. It's not all the way finished yet...I'm still working on it, and 4 others based on it. I'm also going to be working on two versions\u2026","rel":"","context":"In &quot;Technology&quot;","block_context":{"text":"Technology","link":"https:\/\/thepizzy.net\/blog\/category\/tech\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/thepizzy.net\/blog\/wp-content\/uploads\/2008\/04\/Untitled-2.png?fit=400%2C400&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1116,"url":"https:\/\/thepizzy.net\/blog\/2011\/02\/how-to-connect-to-sql-through-windows-authenticated-odbc-in-php\/","url_meta":{"origin":2284,"position":2},"title":"How to Connect to SQL through Windows Authenticated ODBC in PHP","author":"[[Neo]]","date":"February 6, 2011","format":false,"excerpt":"If you use MSSQL over ODBC, connecting w\/ PHP is simply a DOMAIN\\WEBSERVER acct on the MSSQL server & the DSN in PHP's odbc_connect()","rel":"","context":"In &quot;How To&quot;","block_context":{"text":"How To","link":"https:\/\/thepizzy.net\/blog\/category\/how-to\/"},"img":{"alt_text":"ODBC Connection","src":"https:\/\/i0.wp.com\/thepizzy.net\/blog\/wp-content\/uploads\/2011\/02\/8787717937219497341-150x150.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1750,"url":"https:\/\/thepizzy.net\/blog\/2014\/05\/skywarn-storm-spotter-status-released\/","url_meta":{"origin":2284,"position":3},"title":"SKYWARN Storm Spotter Status released!","author":"[[Neo]]","date":"May 27, 2014","format":false,"excerpt":"A technical look at the SKYWARN Storm Spotter status service offered by thepizzy.net","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/thepizzy.net\/blog\/category\/tech\/programming\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/thepizzy.net\/blog\/wp-content\/uploads\/2014\/05\/2014-05-26_1510.png?fit=900%2C525&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/thepizzy.net\/blog\/wp-content\/uploads\/2014\/05\/2014-05-26_1510.png?fit=900%2C525&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/thepizzy.net\/blog\/wp-content\/uploads\/2014\/05\/2014-05-26_1510.png?fit=900%2C525&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/thepizzy.net\/blog\/wp-content\/uploads\/2014\/05\/2014-05-26_1510.png?fit=900%2C525&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":1132,"url":"https:\/\/thepizzy.net\/blog\/2011\/02\/jasper-just-a-store-platform-experience-reworked\/","url_meta":{"origin":2284,"position":4},"title":"Jasper: Just a store platform experience, reworked","author":"[[Neo]]","date":"February 13, 2011","format":false,"excerpt":"Jasper is an experiment in creating a Yahoo! Store Editor and CMS using only the cloud-based coding solution from Kodingen.com","rel":"","context":"In &quot;Jasper&quot;","block_context":{"text":"Jasper","link":"https:\/\/thepizzy.net\/blog\/category\/projects\/jasper\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/thepizzy.net\/blog\/wp-content\/uploads\/2011\/02\/logo-name1.png?fit=600%2C343&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/thepizzy.net\/blog\/wp-content\/uploads\/2011\/02\/logo-name1.png?fit=600%2C343&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/thepizzy.net\/blog\/wp-content\/uploads\/2011\/02\/logo-name1.png?fit=600%2C343&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":1518,"url":"https:\/\/thepizzy.net\/blog\/2014\/03\/tsn8-in-the-works\/","url_meta":{"origin":2284,"position":5},"title":"tsn8 in the works","author":"[[Neo]]","date":"March 18, 2014","format":false,"excerpt":"Development of tsn8 has begun, with better technology, a new user experience, social media integration, and a planned release of Summer 2014!","rel":"","context":"In &quot;Programming&quot;","block_context":{"text":"Programming","link":"https:\/\/thepizzy.net\/blog\/category\/tech\/programming\/"},"img":{"alt_text":"tsn logo","src":"https:\/\/i0.wp.com\/thepizzy.net\/blog\/wp-content\/uploads\/2014\/03\/tsnlogo-featured.png?fit=690%2C405&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/thepizzy.net\/blog\/wp-content\/uploads\/2014\/03\/tsnlogo-featured.png?fit=690%2C405&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/thepizzy.net\/blog\/wp-content\/uploads\/2014\/03\/tsnlogo-featured.png?fit=690%2C405&ssl=1&resize=525%2C300 1.5x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/posts\/2284","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/comments?post=2284"}],"version-history":[{"count":6,"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/posts\/2284\/revisions"}],"predecessor-version":[{"id":2402,"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/posts\/2284\/revisions\/2402"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/media\/2286"}],"wp:attachment":[{"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/media?parent=2284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/categories?post=2284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thepizzy.net\/blog\/wp-json\/wp\/v2\/tags?post=2284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}