Valet-plus: extension="apcu.so" occurs multiple times causing error PHP Warning: Module 'apcu' already loaded in Unknown on line 0

Created on 11 May 2019  Â·  13Comments  Â·  Source: weprovide/valet-plus

Hi

I'm looking at using Valet+ for Magento2 local development - we're currently using docker

On installation, things started throwing errors, in particular

PHP Warning:  Module 'apcu' already loaded in Unknown on line 0

and

PHP Parse error:  syntax error, unexpected 'apcu' (T_STRING), expecting ',' or ')' in Command line code on line 2

Searching through the issues did not yield a fix, and so, looking at my system, in this file:

/usr/local/etc/valet-php/7.1/php.ini

I see this in the beginning of that file

extension_dir = "/usr/local/lib/php/pecl/20160303"
zend_extension="xdebug.so"
extension="apcu.so"
extension="geoip.so"
extension="apcu.so"
extension="apcu.so"
extension="apc.so"
extension="apc.so"

My question is, why is that duplication there, and what is the "valet way" for removing that?

UPDATE:
Manually removing those duplicate entries (the order seems tom change between 7.1 and 7.2) gets rid of the errors

UPDATE:
After enabling xdebug I see the duplication is back - could be the culprit?
valet xdebug on --remote_autostart=1

/usr/local/etc/valet-php/7.1/php.ini

zend_extension="xdebug.so"
extension_dir = "/usr/local/lib/php/pecl/20160303"
zend_extension="xdebug.so"
extension="apcu.so"
extension="apcu.so"
extension="geoip.so"

Most helpful comment

I experienced the same issue after uninstalling and installing Valet+. Error message:

PHP Warning:  Module 'apcu' already loaded in Unknown on line 0
PHP Warning:  Module 'apcu' already loaded in Unknown on line 0
PHP Parse error:  syntax error, unexpected 'apcu' (T_STRING), expecting ',' or ')' in Command line code on line 2
PHP Warning:  Module 'apcu' already loaded in Unknown on line 0
PHP Warning:  Module 'apcu' already loaded in Unknown on line 0
PHP Parse error:  syntax error, unexpected 'apcu' (T_STRING), expecting ',' or ')' in Command line code on line 2
PHP Warning:  Module 'apcu' already loaded in Unknown on line 0

Warning: Module 'apcu' already loaded in Unknown on line 0
Could not open input file:
Warning: Module 'apcu' already loaded in Unknown on line 0

Parse error: syntax error, unexpected 'apcu' (T_STRING), expecting ',' or ')' in Command line code on line 2/cli/valet.php

Failed — adding flags to my shell profile

Tried adding this to my shell profile, but it didn't affect the error:

export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/[email protected]/sbin:$PATH"
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

Succeeded — editing php.ini

I'm guessing the duplicates are leftover from the previous Valet+ install, and the install doesn't de-duplicate them. When I checked the php.ini file for each PHP version that Valet installed this is what I found initially:

File: /usr/local/etc/valet-php/7.1/php.ini

Initially there was a duplicate entry for apcu.so:

extension="apcu.so"
extension="apc.so"
extension="apcu.so"
extension_dir = "/usr/local/lib/php/pecl/20160303"

Which I changed to:

extension="apcu.so"
extension="apc.so"
extension_dir = "/usr/local/lib/php/pecl/20160303"

Then ran valet install which succeeded:

Screen Shot 2019-09-05 at 11 35 18 AM

But failed to setup the MySQL root password properly, so I ran:

brew link --force [email protected]
valet install

Which then fully worked.

And afterward that php.ini file had been rewritten with:

extension="apcu.so"
extension="geoip.so"
extension="yaml.so"
extension="apc.so"
extension_dir = "/usr/local/lib/php/pecl/20160303"

File: /usr/local/etc/valet-php/7.2/php.ini

The 7.2 php.ini didn't have any extensions listed before/after trying to fix and running valet install. After switching I had to make similar changes to its php.ini file.

All 13 comments

I saw this today on my colleague laptop
I had to set

export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

Closing this ticket because it can be fixed

I am running into the same issue, have added the export flags to my ~/.bash_profile file, but after running 'valet install' the issue returns and the double extensions are set.

export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/[email protected]/sbin:$PATH"
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

I experienced the same issue after uninstalling and installing Valet+. Error message:

PHP Warning:  Module 'apcu' already loaded in Unknown on line 0
PHP Warning:  Module 'apcu' already loaded in Unknown on line 0
PHP Parse error:  syntax error, unexpected 'apcu' (T_STRING), expecting ',' or ')' in Command line code on line 2
PHP Warning:  Module 'apcu' already loaded in Unknown on line 0
PHP Warning:  Module 'apcu' already loaded in Unknown on line 0
PHP Parse error:  syntax error, unexpected 'apcu' (T_STRING), expecting ',' or ')' in Command line code on line 2
PHP Warning:  Module 'apcu' already loaded in Unknown on line 0

Warning: Module 'apcu' already loaded in Unknown on line 0
Could not open input file:
Warning: Module 'apcu' already loaded in Unknown on line 0

Parse error: syntax error, unexpected 'apcu' (T_STRING), expecting ',' or ')' in Command line code on line 2/cli/valet.php

Failed — adding flags to my shell profile

Tried adding this to my shell profile, but it didn't affect the error:

export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/[email protected]/sbin:$PATH"
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

Succeeded — editing php.ini

I'm guessing the duplicates are leftover from the previous Valet+ install, and the install doesn't de-duplicate them. When I checked the php.ini file for each PHP version that Valet installed this is what I found initially:

File: /usr/local/etc/valet-php/7.1/php.ini

Initially there was a duplicate entry for apcu.so:

extension="apcu.so"
extension="apc.so"
extension="apcu.so"
extension_dir = "/usr/local/lib/php/pecl/20160303"

Which I changed to:

extension="apcu.so"
extension="apc.so"
extension_dir = "/usr/local/lib/php/pecl/20160303"

Then ran valet install which succeeded:

Screen Shot 2019-09-05 at 11 35 18 AM

But failed to setup the MySQL root password properly, so I ran:

brew link --force [email protected]
valet install

Which then fully worked.

And afterward that php.ini file had been rewritten with:

extension="apcu.so"
extension="geoip.so"
extension="yaml.so"
extension="apc.so"
extension_dir = "/usr/local/lib/php/pecl/20160303"

File: /usr/local/etc/valet-php/7.2/php.ini

The 7.2 php.ini didn't have any extensions listed before/after trying to fix and running valet install. After switching I had to make similar changes to its php.ini file.

I ran into the same issue with 7.1. I followed the fix provided by @brendanfalkowski to remove the duplicate apcu.so extension, and the installation succeeded.

Could we reopen this? It seems to occur on a fresh install (removing the php.ini files and reinstalling everything).

Issue on duplicate apcu.so and apc.so will occur again when changing php version. I need to remove duplicates every time I change php version. Ticket should be reopen.

This is also occurring on a colleague's laptop on a fresh install.

The install command duplicates the apcu.so extension and then later results in a failure that prevents the install process from completing, making this package completely unusable.

Ended up going with a standard Laravel Valet install and enabled XDebug myself.

Brand new imac, fresh Mojave 10.14.6 install, same issue.

Moving back to Laravel Valet for now.

I am having same issue - brand new iMac, Mojave 10.14.16 install as well. Keep running into issues including this one. Trying to run php7.2 to install magento 2.3.3

Does this have a resolution?

R.I.P valet-plus
3 days trying to make this work
Moving back to Laravel Valet for now too.

What worked for me was removing all the lines at the top of:
usr/local/etc/valet-php/7.1/php.ini

I went from:

extension="apcu.so"
extension="apc.so"
extension="apcu.so"
extension_dir = "/usr/local/lib/php/pecl/20160303"
[PHP]

;;;;;;;;;;;;;;;;;;;
; About php.ini   ;

and changed that to only have

[PHP]

;;;;;;;;;;;;;;;;;;;
; About php.ini   ;

I then run
valet fix
valet install

Which made it install without a problem for me.

Well done. Clever boy.

@squishz that works, but it's only a temporary work-around. There's definitely a bug somewhere that causes these duplications to happen. I keep getting them back.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ezequielalba picture ezequielalba  Â·  15Comments

stanleyyylau picture stanleyyylau  Â·  17Comments

jahvi picture jahvi  Â·  24Comments

eclectic-coding picture eclectic-coding  Â·  31Comments

guarinogabriel picture guarinogabriel  Â·  15Comments