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

wp-env: file permissions issues with rewrites and uploads #28201

Closed
swissspidy opened this issue Jan 14, 2021 · 6 comments
Closed

wp-env: file permissions issues with rewrites and uploads #28201

swissspidy opened this issue Jan 14, 2021 · 6 comments
Labels
[Package] Env /packages/env [Type] Bug An existing feature does not function as intended

Comments

@swissspidy
Copy link
Member

Description

It seems like it's not possible to use pretty permalinks with wp-env and/or upload files; at least ffor the tests container.

Step-by-step reproduction instructions

  1. Try to upload file
  2. Receive issues about year-based upload folder not being writeable
  3. Try to enable pretty permalinks on the tests container, for example via npm run wp-env run tests-cli "wp rewrite structure '/%postname%'"
  4. Try to access container via pretty permalinks, get Apache error message instead of seeing WP

Expected behaviour

Actual behaviour

Screenshots or screen recording (optional)

Code snippet (optional)

WordPress information

  • WordPress version:
  • Gutenberg version:
  • Are all plugins except Gutenberg deactivated?
  • Are you using a default theme (e.g. Twenty Twenty-One)?

Device information

  • Device:
  • Operating system:
  • Browser:
@swissspidy swissspidy added [Type] Bug An existing feature does not function as intended [Package] Env /packages/env labels Jan 14, 2021
@imgerson
Copy link

I think there are permission issues when the WordPress version is specified using the core field @swissspidy. I found this working on the e2e tests for the Sucuri WordPress plugin https://github.com/imgerson/sucuri-wordpress-plugin/actions/runs/587185507

@swissspidy
Copy link
Member Author

Interesting finding, thanks for sharing! That will make debugging hopefully a tad easier.

@noahtallen
Copy link
Member

I'm guessing that rewriting the URL format is related to the line in the documentation which says "To regenerate a .htaccess file with WP-CLI, you’ll need to add the mod_rewrite module to your WP-CLI config." it could also be due to the wp-cli being a separate service from the one which serves requests.

Re: image uploads. I'm currently able to upload images to both the dev and tests image in the editor and in the media library using the .wp-env.json in this repo. Could you share yours? I wonder if a difference there is causing the problem.

@noahtallen
Copy link
Member

noahtallen commented Apr 9, 2021

#30053 also fixed some permissions issues, so it'd be worth re-testing file upload. (The URL format is still broken though.)

@andrewmumblebee
Copy link

andrewmumblebee commented Jan 27, 2023

I'm also experiencing this issue

It works fine with v4.0.4 but after updating my global version of @wordpress/env to 5.10.0 none of my API testing is working as .htaccess is not writeable.

When the docker container is spun up, the whole of the WordPress folder has my user as the owner, rather than using www-data as the owner for the folders.

It looks like the chown www-data:www-data wp-content wp-content/plugins wp-content/themes that was removed in #30053 was needed, stuff like the mu-plugins folder is not writeable without this.

I'm not using a custom "core" in wp-env.json, just a couple of mappings. Also tested this out on a seperate folder without a wp-env.json file, so it would use the base setup and it still can't write to .htaccess in the container as the owner is my user rather than www-data.

So even simple APIs such as /wp-json/wp/v2/posts don't work atm with wp-env for me.

@noahtallen
Copy link
Member

This should be solved by #49962. You'll be able to see the change it when developing Gutenberg directly (since npx wp-env or npm run wp-env execute the source code directly in this repo). The fix should be available in about 10 days on npm. You may need to destroy the environment first so that it can be re-created with the correct permissions. Of course, if you still experience issues, drop a comment!

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

No branches or pull requests

4 participants