-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
wp-env: override generated file directory with environment variable #20253
Conversation
In the code for edit: Actually, looking through it again, maybe it makes sense to call |
Thanks Noah! This allows me to run ~/src/gutenberg$ WP_ENV_SOURCE=~/wpenv npx wp-env start
> ✔ WordPress started. (in 296s 268ms)
~/src/gutenberg$ WP_ENV_SOURCE=~/wpenv npx wp-env stop
✔ Stopped WordPress. (in 4s 979ms)
> ~/src/gutenberg$ WP_ENV_SOURCE=~/wpenv npx wp-env start
✖ EACCES: permission denied, open '~/wpenv/6ac6b03bd54e5e922f0d180f6d7ff25d/tests-WordPress/wp-config.php'
[Error: EACCES: permission denied, open '~/wpenv/6ac6b03bd54e5e922f0d180f6d7ff25d/tests-WordPress/wp-config.php'] {
errno: -13,
code: 'EACCES',
syscall: 'open',
path: '~/wpenv/6ac6b03bd54e5e922f0d180f6d7ff25d/tests-WordPress/wp-config.php'
} FWIW: -rw-r--r-- 1 www-data www-data 3187 Feb 17 14:19 ~/wpenv/6ac6b03bd54e5e922f0d180f6d7ff25d/tests-WordPress/wp-config.php whereas the other files in that directory have my user and group as their owner. |
I guess we need to set the owner and permissions of the file explicitly for Linux. |
b4d8fd1
to
66aa627
Compare
Per the permissions issue, it looks as if the basic stuff is working well. So I'm not sure it's a node filesystem issue since we use nodegit to download the sourcecode which has this permissions issue. (Here's where we use it.) Do we need to run chmod and/or chown on every downloaded file? |
Co-Authored-By: Enrique Piqueras <epiqueras@users.noreply.github.com>
66aa627
to
7d4f948
Compare
Actually, scratch that last comment.
I think the install command, which is run by docker-compose, is just generating the file under that web server user. So, should we chmod/chown on the wp-config file for any WordPress source? |
Hm, maybe it's something else entirely. On this branch: ~/source/gutenberg(add/wp-env-support-for-source-override) » packages/env/bin/wp-env start
✖ Error while running docker-compose command.
Starting 31911d623e75f345e9ed328b9f48cff6_mysql_1 ... done
Starting 31911d623e75f345e9ed328b9f48cff6_wordpress_1 ... done
Error: 'wp-config.php' not found.
Either create one manually or use `wp config create`. I get this on a fresh install (after deleting the wp-env directory for the project) on this branch even on macOS. lol. I've been testing in a separate plugin, which does not specify a GitHub source for WordPress, so it may just be that using a GitHub source for WordPress (like Gutenberg does) has been broken for a while... 🤔 |
I don't get that error. |
The old command relied on this script to properly initialize the config file. I'm a bit out of my depth here; @noisysocks do you have opinions about how to handle this? |
Doesn't |
Co-Authored-By: Enrique Piqueras <epiqueras@users.noreply.github.com>
6388c07
to
bb183bf
Compare
That's what I expected to happen as well, but if I run these commands on this branch, I consistently get this issue. ~/source/gutenberg(add/wp-env-support-for-source-override) » rm -rf ~/.wp-env
~/source/gutenberg(add/wp-env-support-for-source-override) » packages/env/bin/wp-env start
✖ Error while running docker-compose command.
Starting 31911d623e75f345e9ed328b9f48cff6_mysql_1 ... done
Starting 31911d623e75f345e9ed328b9f48cff6_wordpress_1 ... done
Error: 'wp-config.php' not found.
Either create one manually or use `wp config create`. |
For that matter, I also get the error on master, so we could resolve this in a follow up. |
Add logs to figure out on what line that throws. It's probably related to the new order of commands. |
Ah, apparently this condition happens when:
It looks like it can be fixed by stopping the docker instance before running wp-env start. I think we should handle this case gracefully, but it definitely does not appear to be the reported issue. So we're back at #20253 (comment), which I think means we just need to set the correct permissions on the wp-config file. |
Any ideas @ockham? |
Just retested this (after deleting my previous $ npx wp-env start
✖ EPERM: operation not permitted, chown '/home/me/wp-env/6ac6b03bd54e5e922f0d180f6d7ff25d/WordPress/wp-config.php'
[Error: EPERM: operation not permitted, chown '/home/me/wp-env/6ac6b03bd54e5e922f0d180f6d7ff25d/WordPress/wp-config.php'] {
errno: -1,
code: 'EPERM',
syscall: 'chown',
path: '/home/me/wp-env/6ac6b03bd54e5e922f0d180f6d7ff25d/WordPress/wp-config.php'
} Looks like the Let's go back to the state of this PR before the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking merge b/c of #20253 (comment)
As a follow-up to this PR, we might consider generating the
(Maybe this stands a better chance of success since it's called from within the container. Bit of a hand-waving argument here 😅 ) Suggesting to do this as a follow-up, since all of this is a massive can of worms, and I think it makes sense to divide and conquer: Make this PR only about the env variable (and its Linux default), and tackle |
Agreed, unless we can fix |
My gut says that the chown issue is actually the same as the previous one with accessing the |
It makes sense, you need permissions to change permissions. We would need to |
Sad to hear that it did not work. I've removed chown from this branch now; I agree that it makes sense to split this up and continue trying to fix that issue after merging the other stuff here :) |
@sainthkh Thanks for the test! Interestingly, I also saw a similar error yesterday when running |
cc @ockham and @noisysocks for ✅ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
I changed to snap docker. But there was no difference.
I either get |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Noah! We're back to this behavior -- which, as discussed, is an improvement over the previous state of things!
@ockham & @sainthkh Thanks for the continued testing. I can keep working towards #20180, but it is a bit tough since I don't have a way to test that the changes work. :) The two things I'm thinking of for next steps are:
|
Has anyone reproduced the connection issue? It might be a third party problem. |
I did see a similar error locally when I was playing around with generating the config file, so I'll keep an eye out for it |
Starting 8dd17dfdf919942794ccb8bf7b39ce80_mysql_1 ... done
Starting 8dd17dfdf919942794ccb8bf7b39ce80_wordpress_1 ... done
mysqlcheck: Got error: 1049: Unknown database 'wordpress' when selecting the database
Starting 8dd17dfdf919942794ccb8bf7b39ce80_mysql_1 ... done
Starting 8dd17dfdf919942794ccb8bf7b39ce80_wordpress_1 ... done
mysqlcheck: Got error: 1049: Unknown database 'wordpress' when selecting the database I've got the same problem. Tried it with |
Hi @noahtallen should this PR be backported into WordPress 5.4? If yes, feel free to add the label backport to wp core. |
If the other PRs for wp-env are being backported, I don't see why not :) |
- Uses a non-hidden default directory for Linux (~/wp-env) - Allows a user to override the directory in which wp-env creates generated files with the WP_ENV_HOME environment variable. Work towards #20180, but will need to continue in a follow-up.
- Uses a non-hidden default directory for Linux (~/wp-env) - Allows a user to override the directory in which wp-env creates generated files with the WP_ENV_HOME environment variable. Work towards #20180, but will need to continue in a follow-up.
Description
~/wp-env
)WP_ENV_HOME
environment variable.Work towards #20180, but will need to continue solving it in a follow-up.
How has this been tested?
I used the environment variable locally and verified generated files were placed there. I also checked that the default location is still used if the environment variable is not specified.
I also tested that, if the container is running, the start command works successfully after deleting the wp-env home directory.
Types of changes
New Feature
Checklist: