Can't open PHP, dyld: Library not loaded - php

I am aware there are many other questions related to this error, but I have tried all the answers and nothing worked.
Full error
dyld: Library not loaded: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
Referenced from: /usr/local/opt/php#7.1/bin/php
Reason: image not found
Abort trap: 6
When did the error occur?
Right after updating Ruby to 2.6.3 via RVM.
Whenever I enter "php" into the terminal the error appears.
Steps taken
Basic steps: Restart Macbook, opened new terminal window.
Uninstall/Reinstall: Node, Openssl, libpng, Ruby
Update/Upgrade: brew
Unlinked/Linked: libidn, autoconf
Given myself all rights via chown -R /usr/local
OpenSSL: $ sudo rm /usr/bin/openssl, brew reinstall openssl#1.1
Brew cleanup
Reinstalled PHP
Versions
Mac OS Mojave 10.14.6
PHP 7.4
Ruby 2.6.3p62
RVM 1.29.9
When running Brew Doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
/opt/local/bin/python2.7-config
/opt/local/bin/curl-config
/opt/local/bin/ncursesw6-config
/opt/local/bin/pcre-config
/opt/local/bin/ncurses6-config
/opt/local/bin/pcap-config
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected header files:
(here it posts all the /usr/local/include/node files, but the list exceeds character limitations)
Any ideas on how to solve this error?

I had similar issue which I fixed this way:
brew reinstall php

I will answer my own question for others who might run into a similar issue
After having uninstalled and reinstalled every single keg of brew I found the following solution:
Uninstall PHP
Run brew cleanup
Check your /usr/local/opt folder for any folders named php
Delete the folder (in my case it was called 'php#7.1')
Open a new terminal window
Run 'brew search php' in the terminal and make sure no php keg is installed.
Simply type 'php -v' in the terminal. For me this showed a version number, indicating that php was (at one point) installed without brew. You can choose to uninstall this version or update it to the newest version.
Conclusion
In my case I believe it was simply that PHP 7.1 was already installed and I installed a 2nd version (7.4) via brew.
The error 'Referenced from: /usr/local/opt/php#7.1/bin/php' was obviously searching for something in this folder and after deleted it, the error stopped.

In my case, i had multiple version of php installed on my macOs, which was later remedies with laradock.
Primary problem:
❯ php -v
dyld[62395]: Library not loaded: /opt/homebrew/opt/icu4c/lib/libicuio.70.dylib
Referenced from: <31116583-6CB3-3C7B-AD46-52FF1431267E> /opt/homebrew/Cellar/php#7.4/7.4.30/bin/php
Reason: tried: '/opt/homebrew/opt/icu4c/lib/libicuio.70.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/icu4c/lib/libicuio.70.dylib' (no such file), '/opt/homebrew/opt/icu4c/lib/libicuio.70.dylib' (no such file), '/usr/local/lib/libicuio.70.dylib' (no such file), '/usr/lib/libicuio.70.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/icu4c/72.1/lib/libicuio.70.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/icu4c/72.1/lib/libicuio.70.dylib' (no such file), '/opt/homebrew/Cellar/icu4c/72.1/lib/libicuio.70.dylib' (no such file), '/usr/local/lib/libicuio.70.dylib' (no such file), '/usr/lib/libicuio.70.dylib' (no such file, not in dyld cache)
Also tried
❯ brew uninstall php
Warning: Calling plist_options is deprecated! Use service.require_root instead.
Please report this issue to the mongodb/brew tap (not Homebrew/brew or Homebrew/core), or even better, submit a PR to fix it:
/opt/homebrew/Library/Taps/mongodb/homebrew-brew/Formula/mongodb-community.rb:55
As indicated "Referenced from" a php version was still installed after mutliple attempts of brew uninstall php
Solution:
rm -rf /opt/homebrew/etc/php
After above brew install php without a problem.
Hope this helps.

Related

Running PHP-server here with Atom on mac

Since updating my mac to Montery my php-server 0.8.0 in atom no longer works and I'm given this error
Listening on http://localhost:8000
Document root is /Applications/MAMP/htdocs
PHP Server could not launch
Have you defined the right path to PHP in your settings? Using PHP
Can anybody help me set this back up? Here are my settings.
v
macOS 12 (”Monterey”) is the first version that no longer ships with PHP included. That said, you will need to install PHP yourself. The PHP documentation lists several ways to install it, the most common way is to use Homebrew:
Enter the following in a terminal window to install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Now you can install the latest PHP version
brew install php
The last couple of PHP 7.x versions are still maintained by the Homebrew team, for even older releases there's a ”tap” (third party repository.)

How to install and use PHP on macOS via brew

it seems like a little bit stupid question, but Google for one hour and cannot find it:
How to install php on macOS via brew and use in in shell.
Install is simple (if you have brew already installed):
brew install php
But after installation, when i use php -v i still see default php on mac os and not the brew's one. Shoud I Add brew php binary into PATH, bash profile, or what?
Thank you!
homebrew creates symbolic links in /usr/local/bin to pretty much every binary it installs. So the answer to your question is to add that to your path in your login profile. That will probably be $HOME/.profile and you can add a line like:
export PATH=/usr/local/bin:$PATH
Then it will be set each time you login or open a new Terminal.
So in my case, the trouble was with some access permissions on specific folders on my Mac OS, so just sharing what I learned: if it's not working, carefully examile log / error feed, there can be a hint for you!
On April 1, 2018 Homebrew discontinued the Homebrew/php tap and went with a core install approach, which means many of the extensions now must be installed with PECL. I have written a two part blog series to help with installing Apache and PHP w/ PECL on later versions of MacOS. You can find it at the link below, I hope it helps!
https://medium.com/#crmcmullen/how-to-install-php-on-macos-10-13-high-sierra-and-10-14-mojave-using-homebrew-and-pecl-ef2276db3d62
Step 1: Install Homebrew
The first step is to install Homebrew and this is a tool (package manager for macOS) that will allow us to install easily PHP and basically any other package/tools.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install PHP
To install PHP we can use the command below. The first command will automatically install the latest version of PHP which is at the current moment of writing this post version 8.
brew install php
If other versions may be preferred we can specify the PHP version and the code will look like the following.
brew install php#7.4
Step 3: The php.ini Config
The default PHP configuration should be sufficient to get started but if there are any other configurations, we can change them through the php.ini located on this path. Do note the PHP version number which in this case is version 8.
/usr/local/etc/php/8.1/php.ini
Step 4: Check if PHP is running
To check if PHP is already running we can make use of the brew services command. First, we can list the services that we have installed.
brew services list
If PHP is not started we can then run the command below to start the service in the background.
brew services start php#8.1
Step 5: Checking PHP Version
Lastly to check the PHP version do run:
php -v
By now you will have PHP running on the background process and every time you logged in to the system it will start by default. Thanks for reading and have a good try.

Install PHP 7.0 Internationalization extension (Intl) on XAMPP on Mac

I followed the instructions outlined here:
Install PHP Internationalization extension (Intl) on XAMPP on Mac
Ran sudo pecl install intl
selected the correct files from the Cellar
then this error happened:
/private/tmp/pear/temp/intl/intl_error.h:24:10: fatal error:
'ext/standard/php_smart_str.h' file not found
include
^ 1 error generated. make: *** [php_intl.lo] Error 1 ERROR: `make' failed
No matter, did some research and found out that PHP 7.0.8 deprecated php.smart_str.h to php.smart_string.h
So given my scant knowledge of C++ I copied smart_string.h to smart_str.h and renamed all the headers from STRING to string.....
re-ran pecl -no luck....more errors......without knowing where the .c files are and remaking php (not really interested in going that far) since anyway I'm using XAMPP so that ended that option.
I have php 5.5 on my mac, deep in the usr/local/bin folder
so next step was to get pecl to use those files and generate an intl.so file....
Did that....I have the intl.so file so put it in the 'extensions' folder in XAMPP (for reference: /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012)
Ran php and came up with this error:
Warning: PHP Startup: Unable to load dynamic library
'/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so'
- dlopen(/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so,
9): Symbol not found: _zval_used_for_init Referenced from:
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so
Expected in: flat namespace in
/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/intl.so
in Unknown on line 0
I imagine it has to do with different versions?
In any case I can't get pecl to install intl without a make error in PHP 7.0.8 on XAMPP. There is no documentation on this and you'd think that if you deprecate a header.h file you'd update all extensions?
Install intl.so in PHP 7 seems impossible?
After a lot of research I was finally able to resolve this. Detailed steps here:
before you begin, check which php path is set. it should be /Applications/XAMPP/xamppfiles/bin/php. If not you can change it by PATH="/Applications/XAMPP/xamppfiles/bin:${PATH}". more detail here
Overall idea is to build the intl-extension from PHP source code on your own. Before you begin make sure you have installed Xcode. Also, install the latest version of autoconf. this might help:
brew install autoconf
Next download the version of PHP you use in XAMPP from php.net. I am using 7.1.18. This version worked for me: php-7.1.31, I’m guessing if you follow the steps it might work for 7.0 or 7.2 as well. Do let me know if it does or doesnt, I’ll update this post. Do not use PHP 7.3 for Magento 2.3.0, it is not supported.
Extract the tar.gz file using (I extracted it inside ~/Downloads/ folder )
tar -xzvf php-7.1.31.tar.gz
cd into the extracted folder
cd php-7.1.31
change to subfolder ext/intl
cd ext/intl/
Run these commands to build the extension
/Applications/XAMPP/bin/phpize
./configure --enable-intl --with-php-config=/Applications/XAMPP/bin/php-config --with-icu-dir=/Applications/XAMPP/xamppfiles/
make
sudo make install
you can now delete all files you downloaded and also the extracted folders.
Open /Applications/XAMPP/xamppfiles/etc/php.ini , and add extension=intl.so
Restart your Apache using XAMPP GUI and it should work.
So far, it seems that extension intl.so for php is bundled with php
and should be compiled with php (intl --enabled). XAMPP does not support this (as of Oct 2016), MAMP does. I do not know about other distros. However, if you're willing to recompile PHP 7, it's worth it just to do that and enable it during compiling.
So....I ran with MAMP. Then I decided that I would simply install apache 2.4 and php 7 and Mysql without the stack and the junk that comes with MAMP or XAMPP and everything works like a charm... so if you need to use CakePHP or intl support etc... just drop XAMPP/MAMP and go with a standard install. I used homebrew (MacOS) and everything is working fine.
Update: As regards Windows, XAMPP does not default it, but you can add the module (dll) in php.ini and works like a charm
The error means that XAMPP doesn't have PHP compiled with intl. You may try:
pecl install intl
but probably it won't work as well.
See: PHP Bug #72879 Pecl install intl make error with PHP 7.0.8.
As for the workaround, try installing memcached extension instead of memcache, e.g.
pecl install memcached
Note: It also requires libmemcached package/library to be installed beforehand. For macOS, install via: brew install libmemcached.
If you wanna try without homebrew, with native apache and php, look at my aswer here: https://stackoverflow.com/a/55131868/3692846

Can't use OSX's php after removing homebrew's php

a few months ago, I installed php55 using homebrew. However, I don't need that anymore and want to use the php version that OS X ships itself.
So I uninstalled php55 using homebrew. When I run php -v now, the following error occurs:
/usr/local/bin/php: No such file or directory
When I run ls /usr/local/bin | grep php I see that no php executable is there anymore (as expected due to uninstalling the package).
When I run echo $PATH, it prints:
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/texbin
As far as I understand the usage of the PATH variable, the terminal should search in /usr/bin for an executable called php when there is no one in /usr/local/bin, but it doesn't. And removing /usr/local/bin from the PATH isn't an option as long as I have other homebrew packages installed on the system.
When running which php the output is as expected: /usr/bin/php, the php executable shipped by OS X.
Any suggestions why the shell doesn't find the php executable?
P.S. The details about the uninstalling of the php55 package:
I uninstalled php55, php55-intl and all of their dependencies that are not needed by any other package. Then I untaped homebrew-php.
My brew doctor output:
Warning: Some directories in /usr/local/share/man aren't writable.
This can happen if you "sudo make install" software that isn't managed
by Homebrew. If a brew tries to add locale information to one of these
directories, then the install will fail during the link step.
You should probably `chown` them:
/usr/local/share/man/de
/usr/local/share/man/de/man1
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
cloog018
gmp4
isl011
libmpc08
mpfr2
zlib
brew prune dit it ... Somewhere must have been a dead symlink that pointed to /usr/local/bin/php (which doesn't exist any more).
Even though the problem is solved now, I am really curious about why homebrew didn't do this during the uninstall process. Any suggestions?

ogr2ogr libcurl error in Mac OS

I am working to run "ogr2ogr" command in terminal.
I got this error message.
dyld: Library not loaded: libcurl.4.dylib Referenced from:
/usr/local/bin/ogr2ogr Reason: Incompatible library version: ogr2ogr
requires version 8.0.0 or later, but libcurl.4.dylib provides version
7.0.0
There is a mismatch between the system requirement and library requirement. As I can tell, the latest curl is version 7 http://curl.haxx.se/download.html,
why is this asking for version 8? I also tried to upgrade curl with brew
but couldn't symlink into /usr/local, because would cause conflicts with
the OS.
In order to figure this problem: I started by figuring out if the Curl is used by different
$$ Which curl
/usr/bin/curl
I installed GDAL on mac by fellowing these instructions (StackOverFlow Post).
To explore where the ogr2ogr is, I run the command.
$$ which ogr2ogr
/usr/local/bin/ogr2ogr
I fellowed these instructions :
Download curl sources: http://curl.haxx.se/download/curl-7.25.0.zip
Unarchive the zip file somewhere
Open a Terminal window and go to the directory containing curl sources
Type: CFLAGS=-m64 ./configure
Type: make
Type: sudo make install
Source :
But it doesn't work out.
Another approach
I downloaded this file, unzip it into the bin/ directory, but when I tried to run it. I got this problem
../../bin/libcurl.4.dylib: cannot execute binary fil
There is one answer I found that seems very helpful, but I couldn't find it very practical.
If you didn't define the --with-curl option when running GDAL
./configure, then
GDAL will link with the curl library indicated by "curl-config --libs"
You likley have several libcurl on your system and the one that got used when
linking GDAL is not the one available at runtime.
The 8.0.0 or 7.0.0 don't necessarily reflect the "human readable" version of
the curl library. It might be some other numbering scheme related to how the
API/ABI of the library evolves, or something linked to packaging.
How can we do that in a practical way.
I read many articles before posting this question here, Anyone have any ideas on how to solve this problem ?
Have you checked this out?
Python Anaconda linking
I did that, then simlinked some stuff:
ln -s libcurl.4.0.0.dylib libcurl.3.dylib
Another error came up, now pertaining to libxml2.
I did:
brew install libxml2 libxslt
brew link --force libxml2 libxslt
And now ogr2ogr is finally working

Categories