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

Permission issues using a theme that uses composer #269

Closed
lajennylove opened this issue Jun 18, 2024 · 8 comments · Fixed by #555
Closed

Permission issues using a theme that uses composer #269

lajennylove opened this issue Jun 18, 2024 · 8 comments · Fixed by #555

Comments

@lajennylove
Copy link

lajennylove commented Jun 18, 2024

Quick summary

I don't know if this is related to the new implementation regarding the PHP selector, but as soon as I tried to use it I found permission issues.

Here's the screenshot:
Screenshot 2024-06-17 at 8 26 10 p m

I tried to do the following to fix the issue:

# check the permissions
ls -l ../../cache/acorn/framework/cache/
total 0
drwxr-xr-x  2 lajennylove  staff  64 Jun 17 20:26 data
----------  1 lajennylove  staff   0 Jun 17 20:26 packages.php

# change change them
chmod -R 755 ../../cache/acorn/framework/cache/

# Then I tried to change the owner but then that wouldn't have access my self, I guess
chown -R www-data:www-data ../../cache/acorn/framework/cache/

Then I though it wouldn't work and I stopped trying.

Steps to reproduce

  1. Create a new site on Studio
  2. Switch to PHP 8.2
  3. Clone this Sage/Vite theme https://github.com/DevArge/sage-vite
  4. Before activating it, to do the following:
# Install vendor
composer install
# Install Vite
yarn 
# Build the assets
yarn build
  1. Then activate the theme, or even better... Just try to live previewing it to avoid having issues with a broken theme.

What you expected to happen

The theme gets activated with no issues like if you were using any other LAMP environment.

What actually happened

I get the following error and I think it could affect to all the users that require composer's cache packages or related:

Warning: require(/var/www/html/wp-content/cache/acorn/framework/cache/packages.php): Failed to open stream: Permission denied in /var/www/html/wp-content/themes/sage-vite/vendor/illuminate/filesystem/Filesystem.php on line 123

Fatal error: Uncaught Error: Failed opening required '/var/www/html/wp-content/cache/acorn/framework/cache/packages.php' (include_path='.:') in /var/www/html/wp-content/themes/sage-vite/vendor/illuminate/filesystem/Filesystem.php:123 Stack trace: #0 /var/www/html/wp-content/themes/sage-vite/vendor/illuminate/filesystem/Filesystem.php(124): Illuminate\Filesystem\Filesystem::Illuminate\Filesystem\{closure}() #1 /var/www/html/wp-content/themes/sage-vite/vendor/roots/acorn/src/Illuminate/Foundation/PackageManifest.php(111): Illuminate\Filesystem\Filesystem->getRequire('/var/www/html/w...') #2 /var/www/html/wp-content/themes/sage-vite/vendor/roots/acorn/src/Illuminate/Foundation/PackageManifest.php(90): Illuminate\Foundation\PackageManifest->getManifest() #3 /var/www/html/wp-content/themes/sage-vite/vendor/roots/acorn/src/Illuminate/Foundation/PackageManifest.php(79): Illuminate\Foundation\PackageManifest->config('aliases') #4 /var/www/html/wp-content/themes/sage-vite/vendor/roots/acorn/src/Roots/Acorn/Bootstrap/RegisterFacades.php(25): Illuminate\Foundation\PackageManifest->aliases() #5 /var/www/html/wp-content/themes/sage-vite/vendor/roots/acorn/src/Illuminate/Foundation/Application.php(263): Roots\Acorn\Bootstrap\RegisterFacades->bootstrap(Object(Roots\Acorn\Application)) #6 /var/www/html/wp-content/themes/sage-vite/vendor/roots/acorn/src/Illuminate/Foundation/Http/Kernel.php(186): Illuminate\Foundation\Application->bootstrapWith(Array) #7 /var/www/html/wp-content/themes/sage-vite/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(187): Illuminate\Foundation\Http\Kernel->bootstrap(Object(Illuminate\Http\Request)) #8 /var/www/html/wp-content/themes/sage-vite/vendor/roots/acorn/src/Roots/Acorn/Bootloader.php(103): Roots\Acorn\Bootloader->bootHttp() #9 /var/www/html/wp-content/themes/sage-vite/functions.php(43): Roots\Acorn\Bootloader->boot() #10 /var/www/html/wp-settings.php(663): include('/var/www/html/w...') #11 /var/www/html/wp-config.php(96): require_once('/var/www/html/w...') #12 /var/www/html/wp-load.php(50): require_once('/var/www/html/w...') #13 /var/www/html/wp-admin/admin.php(34): require_once('/var/www/html/w...') #14 /var/www/html/wp-admin/customize.php(13): require_once('/var/www/html/w...') #15 {main} thrown in /var/www/html/wp-content/themes/sage-vite/vendor/illuminate/filesystem/Filesystem.php on line 123

Impact

Most (> 50%)

Available workarounds?

No and the app is unusable

Platform

Mac Silicon

Logs or notes

No response

@lajennylove lajennylove added [Type] Bug Something isn't working Needs triage Ticket needs to be triaged labels Jun 18, 2024
@mrfoxtalbot
Copy link

Gracias, @lajennylove!

@wojtekn can you take a look? Thanks!

@mrfoxtalbot mrfoxtalbot added Triaged and removed Needs triage Ticket needs to be triaged labels Jun 19, 2024
@wojtekn
Copy link
Contributor

wojtekn commented Jun 20, 2024

Thanks for reporting the issue @lajennylove and for including detailed steps.

I tried to reproduce it in Studio 1.0.3 but couldn't, as it failed earlier in the flow:

  • I couldn't activate the theme in WP Admin as PHP version was not supported
  • I activated the theme using WP CLI and then got the fatal error:
Fatal error: Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.2.0". You are running 8.0.30-dev. in /var/www/html/wp-content/themes/sage-vite/vendor/composer/platform_check.php on line 24

I reproduced it with 8.2 and tracked it to the code from https://github.com/illuminate/filesystem/blob/70487deb0aabbf0ac2f79d4f86e1b2c539f0bbfc/Filesystem.php#L225:

        // Fix permissions of tempPath because `tempnam()` creates it with permissions set to 0600...
        if (! is_null($mode)) {
            chmod($tempPath, $mode);
        } else {
            chmod($tempPath, 0777 - umask());
        }

$mode is null, umask() returns 0777, so the file ends up with permissions set to 0.

As a quick workaround, I propose adding umask(022); in wp-config.php before pulling and installing the theme.

@adamziel any thoughts on that? Should we set default umask for PHP-WASM?

@adamziel
Copy link

adamziel commented Jul 1, 2024

Should we set default umask for PHP-WASM?

I think we should do the same thing as native PHP – is that the default PHP behavior?

@wojtekn
Copy link
Contributor

wojtekn commented Jul 3, 2024

I think we should do the same thing as native PHP – is that the default PHP behavior?

I think it's more related to the operating system, and not PHP itself. It seems that 022 is a common default value on the UNIX system. Reference:

https://web.deu.edu.tr/doc/oreily/networking/puis/ch05_03.htm#:~:text=2%20Common%20umask%20Values,the%20default%20umask%20is%20022.

@adamziel
Copy link

adamziel commented Jul 3, 2024

As a quick workaround, I propose adding umask(022); in wp-config.php before pulling and installing the theme.

The workaround seems good. At the Playground platform level, it seems like an Emscripten-level issue:

We'll need either an Emscripten PR or a Playground-level patch.

@lajennylove
Copy link
Author

Hey there guys, is there any update regarding this issue? I've seen a few updates on the Studio App so I've been updating since then and checking if the issue is solved but I guess you are still working on it.

Screenshot 2024-08-12 at 11 14 46 a m

That's pretty much it, I just wanted to keep track on this issue because this is stopping me from start using this app as my local dev environment.

Best regards.

@wojtekn
Copy link
Contributor

wojtekn commented Aug 19, 2024

@lajennylove we don't have a fix yet, but it's on our radar.

@fluiddot fluiddot self-assigned this Sep 19, 2024
@fluiddot
Copy link
Contributor

Heads up that this issue will be solved via #555.

@fluiddot fluiddot linked a pull request Sep 24, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

5 participants