You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(I got the same error with npm -g i @wordpress/env && wp-env start.)
Desktop (please complete the following information):
OS: Linux (Ubuntu 18.04.3 LTS)
Additional context
This might correlate with #20002 being merged, but I'm not sure it's caused by that PR. /cc @noisysocks
Can we harden Gutenberg against issues like this? For the past ten days, of the time I spent working on Gutenberg, an estimated 50% went into trying to get it to run, figuring out that docs were outdated, updating them, and, just as I thought that things were running smoothely, getting stuck again with this new issue. That doesn't feel like a good use of my time 🙁
This might correlate with #20002 being merged, but I'm not sure it's caused by that PR.
It does sound as if that PR caused the issue. Instead of downloading the required files to cwd /wordpress and then putting a docker-compose override there, the new setup creates the docker-compose file and other dependencies at ~/.wp-env/. It sounds like the Linux issues mostly stem from filesystem permissions.
Can we harden Gutenberg against issues like this
I think yes. :) The wp-env tool is new enough that use cases like your own are still being uncovered. Indeed, your first issue dealing with the @wordpress/scripts env command was essentially the first point that @wordpress/env was really mentioned as the best way to start a local environment, so you're really on the bleeding edge of things here! 😁 I've been fixing other issues I'm finding along the way (#20158, #20157, #20113), and hopefully we can make this a robust tool for local wordpress environment. (It is already working much faster than the old @wordpress/scripts based solution when it works :))
If you like, you could try to fix the issue. I could see it being hard to replicate it since I don't have a linux box. I think the problem happens at these lines:
Sorry you're running into issues @ockham! Like @noahtallen says, wp-env has just undergone a major rewrite and so there will definitely be some kinks to work out! I intend to continue work on it over the next month or two and make it hard enough for us to migrate completely to wp-env.
I suspect that your user doesn't have write permission for the new environment temporary directory (~/.wp-env). Does running this fix the problem?
sudo chown -R username ~/.wp-env
Replace username with your username. You can find this out by running the whoami command.
We may need to look at using a different directory for wp-env's temporary folder on Linux systems, or allowing the user to specify a different directory using e.g. an environment variable.
Sorry you're running into issues @ockham! Like @noahtallen says, wp-env has just undergone a major rewrite and so there will definitely be some kinks to work out! I intend to continue work on it over the next month or two and make it hard enough for us to migrate completely to wp-env.
I suspect that your user doesn't have write permission for the new environment temporary directory (~/.wp-env). Does running this fix the problem?
sudo chown -R username ~/.wp-env
Replace username with your username. You can find this out by running the whoami command.
I'm afraid that doesn't fix the issue. ~ is my user's home folder -- it's basically the one folder that's guaranteed to have all the necessary permissions for my user 🙃 I've deleted the ~/.wp-env folder in between runs, so it's newly created by the wp-env tool each time. It must be indeed the tool itself that assigns weird permissions to some subdirectory or file.
Since docker-compose works fine for me with other projects, my hunch is that the reason for my issue might be somewhere in the docker-compose npm that this tool uses.
Specifically, I think that prior to #20002, dockerCompose.oneUp wasn't used (only dockerCompose.run), so I'm going to look into that command's implementation.
Nah, nothing to do with the docker-compose npm implementation. It's really just about the docker-compose.yml location. The following patch fixes the issue for me:
I think this is a rather widespread and recommended way to install Docker on Ubuntu (and other Linux distributions), plus it seems to be overall well-maintained and provides up-to-date versions. I think it's also the simplest way to install Docker on a number of Linux distributions; compare e.g. with these instructions.
In conclusion, it'd be good to make wp-env work with those Snaps 🙂
Interesting, so docker cannot run a docker-compose.yml from ~/.wp-env/whateverhash/docker-compose.yml, but it can from your source code 🤔
As I mentioned in #20002, what do you think about having an environment variable to change ~/.wp-env/ to something else? Along with that, I wonder if there is a general directory on linux that could work for this location.
The docker snap cannot access directories that start with a "." in the home folder. This is a generic security mechanism for all snaps. I'd recommend moving the directory out of ~/.wp-env to somewhere like ~/wp-env or allow configuring this somehow.
So @noahtallen I guess it'll be good to proceed with #20253. Is there any chance we can make the default a non-hidden directory, so wp-env works OOTB on Ubuntu? /cc @noisysocks@epiqueras
On WSL 2 (Ubuntu 20.04), and ran into this recently.
The sudo chown -R username ~/.wp-env command didn't quite do it, because the folder was actually ~/wp-env. Corrected that and it worked perfectly. Finally I can restart wp-env without destroying and rebuilding.
@ockham - Was this patched and just not released yet? I'm on the latest release and this is still happening for me. I'm having to do the chown pretty much every time I restart my computer or the VM or stop & start the wp-env again.
@danieliser there was another (similar) issue I fixed in #23797. Can you paste the output of the error you see when running wp-env a second time so that we can see if the error is the same?
Was this patched and just not released yet
This specific issue should have been released, but the one I mentioned above has not yet been released :/
If you're running wp-env from Gutenberg, though, you should be referencing the local source code (e.g. npx wp-env or npm run wp-env), and shouldn't see issues developing the gutenberg project specifically.
@noahtallen - Not using it for Gutenberg, just in general plugin development and testing. Hasn't happened today yet, but I will post the error.
It was this same one though:
✖ EACCES: permission denied, open '/home/me/wp-env/6ac6b03bd54e5e922f0d180f6d7ff25d/tests-WordPress/wp-config.php'
[Error: EACCES: permission denied, open '/home/me/wp-env/6ac6b03bd54e5e922f0d180f6d7ff25d/tests-WordPress/wp-config.php'] {
errno: -13,
code: 'EACCES',
syscall: 'open',
path: '/home/me/wp-env/6ac6b03bd54e5e922f0d180f6d7ff25d/tests-WordPress/wp-config.php'
}
Error: Could not process the 'wp-config.php' transformation.
Reason: wp-config.php is not writable.
Does it happen every time you run wp-env start if it is already running?
Btw, this issue should fix this altogether and make filesystem permissions in wp-env work a lot better: #22515. But it needs some eyes and work to make progress
After running the command to fix it I still got this:
✖ Error while running docker-compose command.
Starting a539d783750b32e7f42cbafde69608aa_mysql_1 ... done
Starting a539d783750b32e7f42cbafde69608aa_tests-wordpress_1 ... done
Error: Could not process the 'wp-config.php' transformation.
Reason: wp-config.php is not writable.
@danieliser I guess you have made special post setup docker group setup because in fact @noahtallen is correct that you can not run any docker command without sudo with a normal basic installation. I am just thinking about what to do because I end up with Could not connect to Docker. Is it running? even though I can run sudo docker run hello-world and it works, just not without sudo.
Enabling it without sudo opens a security hole, running docker without root seems to have many restrictions and requires complicated extra setup. But running npm script with sudo is a total nogo, that it probably the biggest security risk. I guess I will go with the docker group thing. I have not tried it, but I guess it would work with sudo just like direct docker commands.
I set up Gutenberg development on a new Linux box recently, and doing the postinstall steps to add my user to the docker group was a requirement to get wp-env working.
I agree with you that requiring sudo to use wp-env would probably be even worse.
I'm running into this issue with a Raspberry Pi. I've run all post install steps in the Docker docs. Everything works fine the first time I start wp-env, but any subsequent times I restart it, I run into either the EACCES issue or wp-config.php is not writable issue.
It seems the files it's complaining about are attached to the root user, instead of your current user that has been added to the docker group.
Activity
simison commentedon Feb 12, 2020
Sorry to hear about the trouble.
Note that build scripts use
wp-scriptsso that's what gets run in CI.Would a good first step be to add simple dummy
wp-envrun into CI and then start working on migratingpackage.jsonscripts to it?noahtallen commentedon Feb 12, 2020
It does sound as if that PR caused the issue. Instead of downloading the required files to cwd /wordpress and then putting a docker-compose override there, the new setup creates the docker-compose file and other dependencies at
~/.wp-env/. It sounds like the Linux issues mostly stem from filesystem permissions.I think yes. :) The wp-env tool is new enough that use cases like your own are still being uncovered. Indeed, your first issue dealing with the @wordpress/scripts env command was essentially the first point that @wordpress/env was really mentioned as the best way to start a local environment, so you're really on the bleeding edge of things here! 😁 I've been fixing other issues I'm finding along the way (#20158, #20157, #20113), and hopefully we can make this a robust tool for local wordpress environment. (It is already working much faster than the old @wordpress/scripts based solution when it works :))
If you like, you could try to fix the issue. I could see it being hard to replicate it since I don't have a linux box. I think the problem happens at these lines:
gutenberg/packages/env/lib/env.js
Lines 215 to 227 in a59a5d9
You can run the source code directly while developing (no need to build anything)
In the short term (and I hate suggesting this), I wonder if
sudo npx wp-env startwould work?ramonjd commentedon Feb 12, 2020
I run Ubuntu on Virtual box. It's like wading through slag in a treacle body suit, but it's good enough for testing.
noisysocks commentedon Feb 13, 2020
Sorry you're running into issues @ockham! Like @noahtallen says,
wp-envhas just undergone a major rewrite and so there will definitely be some kinks to work out! I intend to continue work on it over the next month or two and make it hard enough for us to migrate completely towp-env.I suspect that your user doesn't have write permission for the new environment temporary directory (
~/.wp-env). Does running this fix the problem?Replace
usernamewith your username. You can find this out by running thewhoamicommand.We may need to look at using a different directory for
wp-env's temporary folder on Linux systems, or allowing the user to specify a different directory using e.g. an environment variable.ockham commentedon Feb 13, 2020
I'm afraid that doesn't fix the issue.
~is my user's home folder -- it's basically the one folder that's guaranteed to have all the necessary permissions for my user 🙃 I've deleted the~/.wp-envfolder in between runs, so it's newly created by thewp-envtool each time. It must be indeed the tool itself that assigns weird permissions to some subdirectory or file.ockham commentedon Feb 13, 2020
Possibly related: https://stackoverflow.com/questions/53344380/errno-13-while-running-docker-compose-up
(I'm doing this inside of my home directory tho, so the answer about adding it to some AppArmor config don't seem to apply 🤔 )
ockham commentedon Feb 13, 2020
AFAICT, the error is happening on this line:
gutenberg/packages/env/lib/env.js
Line 57 in 9d67638
Since
docker-composeworks fine for me with other projects, my hunch is that the reason for my issue might be somewhere in thedocker-composenpm that this tool uses.Specifically, I think that prior to #20002,
dockerCompose.oneUpwasn't used (onlydockerCompose.run), so I'm going to look into that command's implementation.ockham commentedon Feb 13, 2020
Nah, nothing to do with the
docker-composenpm implementation. It's really just about thedocker-compose.ymllocation. The following patch fixes the issue for me:ockham commentedon Feb 13, 2020
There's a chance that the issue I'm seeing is related to the
dockerSnap package for Ubuntu that I'm using, which might have an impact on how binaries from a given Snap can access files. (The solutions described at https://stackoverflow.com/questions/53344380/errno-13-while-running-docker-compose-up didn't work for me.)I think this is a rather widespread and recommended way to install Docker on Ubuntu (and other Linux distributions), plus it seems to be overall well-maintained and provides up-to-date versions. I think it's also the simplest way to install Docker on a number of Linux distributions; compare e.g. with these instructions.
In conclusion, it'd be good to make
wp-envwork with those Snaps 🙂noahtallen commentedon Feb 13, 2020
Interesting, so docker cannot run a
docker-compose.ymlfrom~/.wp-env/whateverhash/docker-compose.yml, but it can from your source code 🤔As I mentioned in #20002, what do you think about having an environment variable to change
~/.wp-env/to something else? Along with that, I wonder if there is a general directory on linux that could work for this location.ockham commentedon Feb 17, 2020
FWIW, I reported the problem (Docker snap being unable to access file in a hidden directory) here: https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1863604
anonymouse64 commentedon Feb 17, 2020
The docker snap cannot access directories that start with a "." in the home folder. This is a generic security mechanism for all snaps. I'd recommend moving the directory out of
~/.wp-envto somewhere like~/wp-envor allow configuring this somehow.ockham commentedon Feb 17, 2020
Thanks @anonymouse64!
So @noahtallen I guess it'll be good to proceed with #20253. Is there any chance we can make the default a non-hidden directory, so wp-env works OOTB on Ubuntu? /cc @noisysocks @epiqueras
44 remaining items
noahtallen commentedon May 29, 2020
That's too bad. Could you open a new issue with that specific error message?
sainthkh commentedon May 29, 2020
@noahtallen Opened an issue at #22731.
noahtallen commentedon May 29, 2020
Thank you! didn't want to clutter this one up too much more, since it has already covered two or three different issues 😅
danieliser commentedon Aug 11, 2020
On WSL 2 (Ubuntu 20.04), and ran into this recently.
The
sudo chown -R username ~/.wp-envcommand didn't quite do it, because the folder was actually~/wp-env. Corrected that and it worked perfectly. Finally I can restart wp-env without destroying and rebuilding.danieliser commentedon Aug 19, 2020
@ockham - Was this patched and just not released yet? I'm on the latest release and this is still happening for me. I'm having to do the
chownpretty much every time I restart my computer or the VM or stop & start the wp-env again.noahtallen commentedon Aug 19, 2020
@danieliser there was another (similar) issue I fixed in #23797. Can you paste the output of the error you see when running wp-env a second time so that we can see if the error is the same?
This specific issue should have been released, but the one I mentioned above has not yet been released :/
noahtallen commentedon Aug 19, 2020
If you're running wp-env from Gutenberg, though, you should be referencing the local source code (e.g. npx wp-env or npm run wp-env), and shouldn't see issues developing the gutenberg project specifically.
danieliser commentedon Aug 19, 2020
@noahtallen - Not using it for Gutenberg, just in general plugin development and testing. Hasn't happened today yet, but I will post the error.
It was this same one though:
noahtallen commentedon Aug 20, 2020
Does it happen every time you run
wp-env startif it is already running?Btw, this issue should fix this altogether and make filesystem permissions in wp-env work a lot better: #22515. But it needs some eyes and work to make progress
danieliser commentedon Aug 25, 2020
@noahtallen No it seems to be related to either restarting the host OS (Windows 10) or the rebooting of the WSL vm.
This one came up today after a reboot:
After running the command to fix it I still got this:
noahtallen commentedon Aug 25, 2020
🙃 By the way, do you use
sudoto run docker & wp-env commands? I've had to do that myself on ubuntu, and I hear that is normal for docker on linuxdanieliser commentedon Aug 28, 2020
No, I haven't had to do that.
nextgenthemes commentedon May 10, 2022
@danieliser I guess you have made special post setup docker group setup because in fact @noahtallen is correct that you can not run any
dockercommand without sudo with a normal basic installation. I am just thinking about what to do because I end up withCould not connect to Docker. Is it running?even though I can runsudo docker run hello-worldand it works, just not without sudo.https://docs.docker.com/engine/install/linux-postinstall/
Enabling it without sudo opens a security hole, running docker without root seems to have many restrictions and requires complicated extra setup. But running npm script with sudo is a total nogo, that it probably the biggest security risk. I guess I will go with the docker group thing. I have not tried it, but I guess it would work with sudo just like direct docker commands.
noahtallen commentedon May 14, 2022
I set up Gutenberg development on a new Linux box recently, and doing the postinstall steps to add my user to the docker group was a requirement to get wp-env working.
I agree with you that requiring
sudoto use wp-env would probably be even worse.apeatling commentedon Jun 28, 2022
I'm running into this issue with a Raspberry Pi. I've run all post install steps in the Docker docs. Everything works fine the first time I start wp-env, but any subsequent times I restart it, I run into either the
EACCESissue orwp-config.php is not writableissue.It seems the files it's complaining about are attached to the root user, instead of your current user that has been added to the docker group.