Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Env: Issues with composer global require #51419

Open
motherthestate opened this issue Jun 12, 2023 · 19 comments
Open

Env: Issues with composer global require #51419

motherthestate opened this issue Jun 12, 2023 · 19 comments
Labels
[Tool] Env /packages/env [Type] Bug An existing feature does not function as intended

Comments

@motherthestate
Copy link

motherthestate commented Jun 12, 2023

Description

Hey, wp-env start worked on 6.0.0 just fine, but not on 7.0.0 and latest.

Maybe caused by whatever changed in: #50814

System:
Docker 3.5.2 (3.5.2.18)
macOS 13.0

Step-by-step reproduction instructions

wp-env start worked on 6.0.0 just fine:

➜  wp-env start                 
WordPress development site started at http://localhost:8888
WordPress test site started at http://localhost:8889
MySQL is listening on port 59568
MySQL for automated testing is listening on port 59567

 ✔ Done! (in 113s 218ms)

but not on 7.0.0 and latest

➜  wp-env start                 
...
#17 ERROR: executor failed running [/bin/sh -c composer global require --dev yoast/phpunit-polyfills:"^1.0"]: exit code: 1
------
 > [14/14] RUN composer global require --dev yoast/phpunit-polyfills:"^1.0":
------
executor failed running [/bin/sh -c composer global require --dev yoast/phpunit-polyfills:"^1.0"]: exit code: 1
Service 'cli' failed to build : Build failed

Screenshots, screen recording, code snippet

No response

Environment info

Docker 3.5.2 (3.5.2.18)
macOS 13.0

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@t-hamano t-hamano added Needs Testing Needs further testing to be confirmed. [Tool] Env /packages/env labels Jun 12, 2023
@t-hamano
Copy link
Contributor

Hi @weltmx,

Thanks for the report.

I'm a Windows user and have confirmed that I can successfully launch it with the latest version (8.1.0) of env. If anyone is willing to test this on MacOS, please comment on the test results.

@torounit
Copy link
Member

Hi @weltmx,

Tested on Mac 13.4. Both wp-env 7 and 8 launched.

Docker 3.5.2 (3.5.2.18)

Is it possibly the version number of "Docker Desktop"? If so, it is an older version and updating to the latest version may help.

@talldan
Copy link
Contributor

talldan commented Jun 13, 2023

I had some issues (not sure they were the same ones) and updating the docker desktop version helped. I was only a number of minor versions behind.

@motherthestate
Copy link
Author

@talldan @torounit I have completely reinstalled docker desktop and the issue persists for me sadly.

Docker engine: 24.0.2
Desktop: 4.20.1

@torounit
Copy link
Member

@weltmx

What happens if run wp-env start --update ?

@Mamaduka Mamaduka added [Status] Needs More Info Follow-up required in order to be actionable. and removed Needs Testing Needs further testing to be confirmed. labels Jun 20, 2023
@swissspidy
Copy link
Member

Same issue here on macOS with M1 Pro, wp-env 8.2.0, Docker Desktop 4.20.1 (current latest), Docker engine 24.0.2.

Unfortunately wp-env start --update (preceded by wp-env clean just to be safe) does not help. Not even removing Docker images and containers helps.

Interestingly Composer gets installed correctly, but running the command after that still breaks.

#43 [tests-cli 12/14] RUN php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
#43 0.187 All settings correct for using Composer
#43 0.188 Downloading...
#43 0.748 
#43 0.748 Composer (version 2.5.8) successfully installed to: /usr/local/bin/composer
#43 0.748 Use it: php /usr/local/bin/composer
#43 0.748 
#43 DONE 0.8s

#44 [cli 13/14] RUN rm /tmp/composer-setup.php
#44 DONE 0.3s

#45 [cli 14/14] RUN composer global require --dev yoast/phpunit-polyfills:"^1.0"
#45 0.317 
#45 0.319 In Filesystem.php line 254:
#45 0.319                                                        
#45 0.319   /.composer does not exist and could not be created.  
#45 0.319                                                        
#45 0.319 
#45 0.319 global <command-name> [<args>...]
#45 0.319 
#45 ERROR: process "/bin/sh -c composer global require --dev yoast/phpunit-polyfills:\"^1.0\"" did not complete successfully: exit code: 1

@ZachWatkins
Copy link

Same issue here on macOS with M1 Pro, wp-env 8.2.0, Docker Desktop 4.20.1 (current latest), Docker engine 24.0.2.

Unfortunately wp-env start --update (preceded by wp-env clean just to be safe) does not help. Not even removing Docker images and containers helps.

Interestingly Composer gets installed correctly, but running the command after that still breaks.

#43 [tests-cli 12/14] RUN php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
#43 0.187 All settings correct for using Composer
#43 0.188 Downloading...
#43 0.748 
#43 0.748 Composer (version 2.5.8) successfully installed to: /usr/local/bin/composer
#43 0.748 Use it: php /usr/local/bin/composer
#43 0.748 
#43 DONE 0.8s

#44 [cli 13/14] RUN rm /tmp/composer-setup.php
#44 DONE 0.3s

#45 [cli 14/14] RUN composer global require --dev yoast/phpunit-polyfills:"^1.0"
#45 0.317 
#45 0.319 In Filesystem.php line 254:
#45 0.319                                                        
#45 0.319   /.composer does not exist and could not be created.  
#45 0.319                                                        
#45 0.319 
#45 0.319 global <command-name> [<args>...]
#45 0.319 
#45 ERROR: process "/bin/sh -c composer global require --dev yoast/phpunit-polyfills:\"^1.0\"" did not complete successfully: exit code: 1

I am experiencing this issue as well with wp-env 8.2.0, Docker Desktop 4.21.1, and Docker Engine 24.0.2. This did not occur on my Windows 11 instance.

@ZachWatkins
Copy link

ZachWatkins commented Jul 6, 2023

@weltmx

What happens if run wp-env start --update ?

This is my output from that command (below) and I forgot to mention I'm on a M1 Mac.
I also encounter this error output when cloning the wordpress/gutenberg repo fresh, switching to the node and npm versions declared in the package, and then doing wp-env start.

✖ Error while running docker-compose command.
#1 [wordpress internal] load .dockerignore
#1 transferring context: 2B done
#1 DONE 0.0s

#2 [wordpress internal] load build definition from WordPress.Dockerfile
#2 transferring dockerfile: 1.97kB done
#2 DONE 0.0s

#3 [wordpress internal] load metadata for docker.io/library/wordpress:php8.1
#3 DONE 0.0s

#4 [wordpress  1/19] FROM docker.io/library/wordpress:php8.1
#4 DONE 0.0s

#5 [wordpress 15/19] RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
#5 CACHED

#6 [wordpress  4/19] RUN sed -i 's|security.debian.org/debian-security stretch|archive.debian.org/debian-security stretch|g' /etc/apt/sources.list
#6 CACHED

#7 [wordpress 11/19] RUN apt-get -qy install sudo
#7 CACHED

#8 [wordpress  9/19] RUN apt-get -qy install autoconf           dpkg-dev                file                g++             gcc             libc-dev            make            pkg-config          re2c && touch /usr/local/etc/php/php.ini
#8 CACHED

#9 [wordpress 13/19] RUN echo 'upload_max_filesize = 1G' >> /usr/local/etc/php/php.ini
#9 CACHED

#10 [wordpress  7/19] RUN useradd -mlo -u 1642390085 -g 20 z-watkins || true
#10 CACHED

#11 [wordpress 14/19] RUN echo 'post_max_size = 1G' >> /usr/local/etc/php/php.ini
#11 CACHED

#12 [wordpress  2/19] RUN touch /etc/apt/sources.list
#12 CACHED

#13 [wordpress  5/19] RUN sed -i '/stretch-updates/d' /etc/apt/sources.list
#13 CACHED

#14 [wordpress 12/19] RUN echo "#1642390085 ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
#14 CACHED

#15 [wordpress  3/19] RUN sed -i 's|deb.debian.org/debian stretch|archive.debian.org/debian stretch|g' /etc/apt/sources.list
#15 CACHED

#16 [wordpress 17/19] RUN php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
#16 CACHED

#17 [wordpress  8/19] RUN apt-get -qy update
#17 CACHED

#18 [wordpress 18/19] RUN rm /tmp/composer-setup.php
#18 CACHED

#19 [wordpress  6/19] RUN groupadd -o -g 20 z-watkins || true
#19 CACHED

#20 [wordpress 10/19] RUN apt-get -qy install git
#20 CACHED

#21 [wordpress 16/19] RUN export COMPOSER_HASH=`curl -sS https://composer.github.io/installer.sig` && php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$COMPOSER_HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('/tmp/composer-setup.php'); } echo PHP_EOL;"
#21 CACHED

#22 [wordpress 19/19] RUN composer global require --dev yoast/phpunit-polyfills:"^1.0"
#22 CACHED

#23 [wordpress] exporting to image
#23 exporting layers done
#23 writing image sha256:b8f43500846e2776cd5b183ca69aa5ca47e4b4d79a89487ee9051af35bc1b4a3 done
#23 naming to docker.io/library/b0862e38e2d51cc075328697c5cdca95-wordpress done
#23 DONE 0.0s

#24 [tests-wordpress internal] load .dockerignore
#24 transferring context: 2B done
#24 DONE 0.0s

#25 [tests-wordpress internal] load build definition from Tests-WordPress.Dockerfile
#25 transferring dockerfile: 1.98kB 0.0s done
#25 DONE 0.0s

#3 [tests-wordpress internal] load metadata for docker.io/library/wordpress:php8.1
#3 DONE 0.0s

#4 [tests-wordpress  1/19] FROM docker.io/library/wordpress:php8.1
#4 DONE 0.0s

#6 [tests-wordpress  4/19] RUN sed -i 's|security.debian.org/debian-security stretch|archive.debian.org/debian-security stretch|g' /etc/apt/sources.list
#6 CACHED

#8 [tests-wordpress  9/19] RUN apt-get -qy install autoconf             dpkg-dev           file             g++             gcc             libc-dev            make            pkg-config          re2c && touch /usr/local/etc/php/php.ini
#8 CACHED

#14 [tests-wordpress 12/19] RUN echo "#1642390085 ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
#14 CACHED

#10 [tests-wordpress  7/19] RUN useradd -mlo -u 1642390085 -g 20 z-watkins || true
#10 CACHED

#9 [tests-wordpress 13/19] RUN echo 'upload_max_filesize = 1G' >> /usr/local/etc/php/php.ini
#9 CACHED

#16 [tests-wordpress 17/19] RUN php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
#16 CACHED

#7 [tests-wordpress 11/19] RUN apt-get -qy install sudo
#7 CACHED

#21 [tests-wordpress 16/19] RUN export COMPOSER_HASH=`curl -sS https://composer.github.io/installer.sig` && php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$COMPOSER_HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('/tmp/composer-setup.php'); } echo PHP_EOL;"
#21 CACHED

#17 [tests-wordpress  8/19] RUN apt-get -qy update
#17 CACHED

#20 [tests-wordpress 10/19] RUN apt-get -qy install git
#20 CACHED

#13 [tests-wordpress  5/19] RUN sed -i '/stretch-updates/d' /etc/apt/sources.list
#13 CACHED

#18 [tests-wordpress 18/19] RUN rm /tmp/composer-setup.php
#18 CACHED

#19 [tests-wordpress  6/19] RUN groupadd -o -g 20 z-watkins || true
#19 CACHED

#12 [tests-wordpress  2/19] RUN touch /etc/apt/sources.list
#12 CACHED

#15 [tests-wordpress  3/19] RUN sed -i 's|deb.debian.org/debian stretch|archive.debian.org/debian stretch|g' /etc/apt/sources.list
#15 CACHED

#11 [tests-wordpress 14/19] RUN echo 'post_max_size = 1G' >> /usr/local/etc/php/php.ini
#11 CACHED

#5 [tests-wordpress 15/19] RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
#5 CACHED

#22 [tests-wordpress 19/19] RUN composer global require --dev yoast/phpunit-polyfills:"^1.0"
#22 CACHED

#26 [tests-wordpress] exporting to image
#26 exporting layers done
#26 writing image sha256:7ad05a215c30208d97d5c366d258f8a4fcffb3916952634208e64ff0a2a817c4 done
#26 naming to docker.io/library/b0862e38e2d51cc075328697c5cdca95-tests-wordpress done
#26 DONE 0.0s

#27 [cli internal] load .dockerignore
#27 transferring context: 2B done
#27 DONE 0.0s

#28 [cli internal] load build definition from CLI.Dockerfile
#28 transferring dockerfile: 1.80kB done
#28 DONE 0.0s

#29 [cli internal] load metadata for docker.io/library/wordpress:cli-php8.1
#29 DONE 0.0s

#30 [cli  1/14] FROM docker.io/library/wordpress:cli-php8.1
#30 DONE 0.0s

#31 [cli  3/14] RUN adduser -h /home/z-watkins -G $( getent group 20 | cut -d: -f1 ) -u 1642390085 z-watkins || true
#31 CACHED

#32 [cli  4/14] RUN apk update
#32 CACHED

#33 [cli 12/14] RUN php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
#33 CACHED

#34 [cli  6/14] RUN apk --no-cache add sudo linux-headers
#34 CACHED

#35 [cli 11/14] RUN export COMPOSER_HASH=`curl -sS https://composer.github.io/installer.sig` && php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$COMPOSER_HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('/tmp/composer-setup.php'); } echo PHP_EOL;"
#35 CACHED

#36 [cli 10/14] RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
#36 CACHED

#37 [cli  8/14] RUN echo 'upload_max_filesize = 1G' >> /usr/local/etc/php/php.ini
#37 CACHED

#38 [cli  7/14] RUN echo "#1642390085 ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
#38 CACHED

#39 [cli  5/14] RUN apk --no-cache add autoconf                 dpkg-dev dpkg           file                g++             gcc             libc-dev            make            pkgconf             re2c && touch /usr/local/etc/php/php.ini
#39 CACHED

#40 [cli  2/14] RUN addgroup -g 20 z-watkins || true
#40 CACHED

#41 [cli  9/14] RUN echo 'post_max_size = 1G' >> /usr/local/etc/php/php.ini
#41 CACHED

#42 [cli 13/14] RUN rm /tmp/composer-setup.php
#42 CACHED

#43 [cli 14/14] RUN composer global require --dev yoast/phpunit-polyfills:"^1.0"
#43 ...

#30 [tests-cli  1/14] FROM docker.io/library/wordpress:cli-php8.1
#30 DONE 0.0s

#33 [tests-cli 12/14] RUN php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
#33 CACHED

#40 [tests-cli  2/14] RUN addgroup -g 20 z-watkins || true
#40 CACHED

#37 [tests-cli  8/14] RUN echo 'upload_max_filesize = 1G' >> /usr/local/etc/php/php.ini
#37 CACHED

#36 [tests-cli 10/14] RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
#36 CACHED

#39 [tests-cli  5/14] RUN apk --no-cache add autoconf           dpkg-dev dpkg           file                g++             gcc             libc-dev            make            pkgconf             re2c && touch /usr/local/etc/php/php.ini
#39 CACHED

#38 [tests-cli  7/14] RUN echo "#1642390085 ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
#38 CACHED

#32 [tests-cli  4/14] RUN apk update
#32 CACHED

#34 [tests-cli  6/14] RUN apk --no-cache add sudo linux-headers
#34 CACHED

#31 [tests-cli  3/14] RUN adduser -h /home/z-watkins -G $( getent group 20 | cut -d: -f1 ) -u 1642390085 z-watkins || true
#31 CACHED

#35 [tests-cli 11/14] RUN export COMPOSER_HASH=`curl -sS https://composer.github.io/installer.sig` && php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$COMPOSER_HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('/tmp/composer-setup.php'); } echo PHP_EOL;"
#35 CACHED

#41 [tests-cli  9/14] RUN echo 'post_max_size = 1G' >> /usr/local/etc/php/php.ini
#41 CACHED

#42 [tests-cli 13/14] RUN rm /tmp/composer-setup.php
#42 CACHED

#44 [tests-cli internal] load .dockerignore
#44 transferring context: 2B done
#44 DONE 0.0s

#45 [tests-cli internal] load build definition from Tests-CLI.Dockerfile
#45 transferring dockerfile: 1.81kB 0.0s done
#45 DONE 0.0s

#29 [tests-cli internal] load metadata for docker.io/library/wordpress:cli-php8.1
#29 DONE 0.0s

#43 [tests-cli 14/14] RUN composer global require --dev yoast/phpunit-polyfills:"^1.0"
#43 0.569 
#43 0.573 In Filesystem.php line 254:
#43 0.573                                                        
#43 0.574   /.composer does not exist and could not be created.  
#43 0.574                                                        
#43 0.574 
#43 0.575 global <command-name> [<args>...]
#43 0.575 
#43 ERROR: process "/bin/sh -c composer global require --dev yoast/phpunit-polyfills:\"^1.0\"" did not complete successfully: exit code: 1
------
 > [tests-cli 14/14] RUN composer global require --dev yoast/phpunit-polyfills:"^1.0":
0.569 
0.573 In Filesystem.php line 254:
0.573                                                        
0.574   /.composer does not exist and could not be created.  
0.574                                                        
0.574 
0.575 global <command-name> [<args>...]
0.575 
------
failed to solve: process "/bin/sh -c composer global require --dev yoast/phpunit-polyfills:\"^1.0\"" did not complete successfully: exit code: 1

@ZachWatkins
Copy link

ZachWatkins commented Jul 7, 2023

Update: my co-worker was able to install it on an identical M1 Macbook laptop and I think the problem comes down to the environment variable value for HOME.

Edit:

On hers, inside the container, it is HOME=/home/user-name.
The .composer global directory is created at /root/.composer and /home/user-name/.composer.

On mine, inside the container, it is HOME=/.
The .composer global directory is created at /root/.composer only.

If I create the directory by modifying the Docker image generator in node_modules/@wordpress/env/lib/init-config.js then I get a permission error from composer:

#23 [wordpress 18/20] RUN sudo mkdir /home/user-name/.composer/
#23 DONE 0.1s

#24 [tests-wordpress 19/20] RUN rm /tmp/composer-setup.php
#24 DONE 0.1s

#25 [wordpress 20/20] RUN composer global require --dev yoast/phpunit-polyfills:"^1.0"
#25 0.193 Changed current directory to /home/user-name/.composer
#25 0.198 
#25 0.201 In RequireCommand.php line 142:
#25 0.201                                                                                
#25 0.201   file_put_contents(./composer.json): Failed to open stream: Permission denie  
#25 0.201   d                                                    

@swissspidy swissspidy added the [Type] Bug An existing feature does not function as intended label Jul 7, 2023
@ZachWatkins
Copy link

I just posted an edit to my comment above with additional differences between our environments.

@ZachWatkins
Copy link

I was able to get wp-env start to succeed by making these edits to the init-config.js file:

diff --git a/packages/env/lib/init-config.js b/packages/env/lib/init-config.js
--- a/packages/env/lib/init-config.js
+++ b/packages/env/lib/init-config.js
@@ -241,6 +241,9 @@ RUN echo 'post_max_size = 1G' >> /usr/local/etc/php/php.ini`;
        dockerFileContent += `
 RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
 RUN export COMPOSER_HASH=\`curl -sS https://composer.github.io/installer.sig\` && php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$COMPOSER_HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('/tmp/composer-setup.php'); } echo PHP_EOL;"
+ENV HOME=/home/$HOST_USERNAME
+RUN mkdir -p /home/$HOST_USERNAME/.composer/
+RUN chown -R $HOST_UID:$HOST_GID /home/$HOST_USERNAME/.composer/
 RUN php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
 RUN rm /tmp/composer-setup.php`;

@coreymckrill
Copy link
Contributor

I'm hitting this same issue, but with a slightly different error, and only when using the --xdebug switch

[wordpress 24/24] RUN composer global require --dev yoast/phpunit-polyfills:"^1.0":
0.097 /bin/sh: 1: composer: not found

@github-actions
Copy link

github-actions bot commented Aug 4, 2023

Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks.

@github-actions github-actions bot added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Aug 4, 2023
@coreymckrill coreymckrill removed [Status] Needs More Info Follow-up required in order to be actionable. [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. labels Aug 4, 2023
@coreymckrill
Copy link
Contributor

There's been a bunch of additional info added to this since the Needs more info label was added. It seems like it's still a problem for several people, including me. I'm removing that label and the Stale label so this doesn't get auto-closed.

@Bernix01
Copy link

Bernix01 commented Jun 10, 2024

I was able to get wp-env start to succeed by making these edits to the init-config.js file:

diff --git a/packages/env/lib/init-config.js b/packages/env/lib/init-config.js
--- a/packages/env/lib/init-config.js
+++ b/packages/env/lib/init-config.js
@@ -241,6 +241,9 @@ RUN echo 'post_max_size = 1G' >> /usr/local/etc/php/php.ini`;
        dockerFileContent += `
 RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
 RUN export COMPOSER_HASH=\`curl -sS https://composer.github.io/installer.sig\` && php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$COMPOSER_HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('/tmp/composer-setup.php'); } echo PHP_EOL;"
+ENV HOME=/home/$HOST_USERNAME
+RUN mkdir -p /home/$HOST_USERNAME/.composer/
+RUN chown -R $HOST_UID:$HOST_GID /home/$HOST_USERNAME/.composer/
 RUN php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
 RUN rm /tmp/composer-setup.php`;> ```shell
RUN chown -R $HOST_UID:$HOST_GID /home/$HOST_USERNAME/.composer/

This changes actually fix the issue which is still present when you enable --xdebug flag

@andreawetzel
Copy link

I was able to get wp-env start to succeed by making these edits to the init-config.js file:

diff --git a/packages/env/lib/init-config.js b/packages/env/lib/init-config.js
--- a/packages/env/lib/init-config.js
+++ b/packages/env/lib/init-config.js
@@ -241,6 +241,9 @@ RUN echo 'post_max_size = 1G' >> /usr/local/etc/php/php.ini`;
        dockerFileContent += `
 RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
 RUN export COMPOSER_HASH=\`curl -sS https://composer.github.io/installer.sig\` && php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$COMPOSER_HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('/tmp/composer-setup.php'); } echo PHP_EOL;"
+ENV HOME=/home/$HOST_USERNAME
+RUN mkdir -p /home/$HOST_USERNAME/.composer/
+RUN chown -R $HOST_UID:$HOST_GID /home/$HOST_USERNAME/.composer/
 RUN php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
 RUN rm /tmp/composer-setup.php`;

I ran into this issue today too and your workaround helped. A note that I wasn't sure where to find my global init-config.js file so I used npm root -g to find the global packages installed for my current version of node.

@t-hamano
Copy link
Contributor

t-hamano commented Jul 23, 2024

Is this only an issue on M1 Mac? Has anyone else had this issue on a machine other than an M1 Mac?

@jdredman
Copy link

jdredman commented Jul 31, 2024

I'm experiencing this issue on Intel i7. I was able to get it running on 6.0.0:

Uninstall:
npm uninstall -g @wordpress/env

Install older version:
npm install -g @wordpress/env@6

Clean up and re-run
Delete my containers and re-run wp-env start

@davidgalvez
Copy link

I had the same problem on M3 Macbook laptop, I could solve it by making edits on the init-config.jsfile suggested by @Bernix01

diff --git a/packages/env/lib/init-config.js b/packages/env/lib/init-config.js
--- a/packages/env/lib/init-config.js
+++ b/packages/env/lib/init-config.js
@@ -241,6 +241,9 @@ RUN echo 'post_max_size = 1G' >> /usr/local/etc/php/php.ini`;
        dockerFileContent += `
 RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
 RUN export COMPOSER_HASH=\`curl -sS https://composer.github.io/installer.sig\` && php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$COMPOSER_HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('/tmp/composer-setup.php'); } echo PHP_EOL;"
+ENV HOME=/home/$HOST_USERNAME
+RUN mkdir -p /home/$HOST_USERNAME/.composer/
+RUN chown -R $HOST_UID:$HOST_GID /home/$HOST_USERNAME/.composer/
 RUN php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
 RUN rm /tmp/composer-setup.php`;> ```shell
RUN chown -R $HOST_UID:$HOST_GID /home/$HOST_USERNAME/.composer/

And then I had a free space error message:

#26 0.625 The disk hosting /home/user-name/.composer has less than 100MiB of free space, this may be the cause of the following exception
#26 0.625 
#26 0.626 In Filesystem.php line 261:
#26 0.626                                                                                
#26 0.626   /home/user-name/.composer/vendor does not exist and could not be created:  

That was because I had many orphan volumes on my container I solved it with the following:
docker volume rm $(docker volume ls -qf dangling=true)

Clean up and re-run wp-env start and worked!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Tool] Env /packages/env [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests