PHP, Net-SNMP and OS X 10.10.5

Today I upgraded to the latest “Public Beta” of OS X 10.10.5 and suddenly PHP CLI was returning the following error:

$ php
dyld: Library not loaded: /usr/lib/libnetsnmp.25.dylib
  Referenced from: /usr/bin/php
  Reason: image not found
Trace/BPT trap: 5

so I checked the contents of the /usr/lib folder and discovered some recent changes to the Net-SNMP libraries:

$ ls -la /usr/lib/libnetsnmp.*
lrwxr-xr-x  1 root  wheel       28 Jul 16 21:55 /usr/lib/libnetsnmp.25.dylib -> /usr/lib/libnetsnmp.30.dylib
-rwxr-xr-x  1 root  wheel  1241136 Jul  9 10:38 /usr/lib/libnetsnmp.30.dylib
lrwxr-xr-x  1 root  wheel       19 Jul 16 13:04 /usr/lib/libnetsnmp.dylib -> libnetsnmp.30.dylib

The Solution

Symlinking libnetsnmp.25.dylib to the latest version of libnetsnmp.dylib fixes the issue:

$ sudo ln -s /usr/lib/libnetsnmp.dylib /usr/lib/libnetsnmp.25.dylib

I wonder why they didn’t update PHP to match the system changes:

$ php -v
PHP 5.5.24 (cli) (built: May 19 2015 10:10:05) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

8 Comments

  1. Elise says:

    Thank you so much for posting this! After the El Capitan latest beta update my localhost was failing to pull up, with apachectl configtest showing the line with libphp5.so as causing the error. When trying to run php on the command line, I received exactly the error you detailed above. Now all’s fixed thanks to your symlink :) I’m so glad Google picked up your article so quickly (I think it said 32 minutes published!)

    • Kennon Bickhart says:

      You mention using this on El Capitan. Did you disable the “system integrity protection”? Without disabling that, I can’t run this command. I disabled it and got this working, but just curious.

  2. baiyuxiong says:

    Good job!! This solved my problem

  3. cool8jay says:

    wow! I met exactly the same issue like you!
    Thanks for posting this!

  4. Mads says:

    Thank you, Great job!

  5. Fred says:

    The latest version of Yosemite has this problem, too. Thank u for ur solution!

  6. Indrek says:

    Upgraded to 10.10.5 beta in hopes it would fix at least some of the bugs in the latest Safari (such as cmd-1/2/3/n not working anymore for bookmark shortcuts). Instead, ended up with a broken Apache.

    Your post saved me from a bunch of head-shaped dents in the wall. Thanks!

Leave a Reply to Kennon Bickhart Cancel reply