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-now: blueprint with installPlugin steps fails on subsequent runs #209

Open
squelchdesign opened this issue Mar 31, 2024 · 3 comments
Open
Labels
Bug Something isn't working wp-now

Comments

@squelchdesign
Copy link

Possibly related to #178?

I'm developing a plugin which will integrate with the font-awesome plugin, so I have a blueprint.json which installs the font-awesome plugin automatically. On the first run it installs perfectly. On a subsequent run, without doing a --reset, it tries to install the plugin again and then dies with an error:

Error: Error when executing the blueprint step #1 ({"step":"installPlugin","pluginZipFile":{"resource":"wordpress.org/plugins","slug":"font-awesome"},"options":{"activate":true}}) : Could not move /var/www/html/wp-content/tXW4-8lh6nrAqCPMULyn1dppMr^E,v>Nm!i]/assets/Font awesome/font-awesome to /var/www/html/wp-content/plugins/font-awesome: Directory not empty.
    at Object.run (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/node_modules/@wp-playground/blueprints/index.js:9215:37)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async runBlueprintSteps (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/node_modules/@wp-playground/blueprints/index.js:9320:3)
    ... 2 lines matching cause stack trace ...
    at async Object.handler (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/main.js:1152:25) {
  [cause]: Error: Could not move /var/www/html/wp-content/tXW4-8lh6nrAqCPMULyn1dppMr^E,v>Nm!i]/assets/Font awesome/font-awesome to /var/www/html/wp-content/plugins/font-awesome: Directory not empty.
      at _NodePHP.mv (/opt/homebrew/lib/node_modules/@wp-now/wp-now/node_modules/@php-wasm/node/index.cjs:73245:13)
      at installAsset (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/node_modules/@wp-playground/blueprints/index.js:1144:20)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async Object.installPlugin (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/node_modules/@wp-playground/blueprints/index.js:1161:34)
      at async o (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/node_modules/@wp-playground/blueprints/index.js:9285:30)
      at async Object.run (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/node_modules/@wp-playground/blueprints/index.js:9212:23)
      at async runBlueprintSteps (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/node_modules/@wp-playground/blueprints/index.js:9320:3)
      at async startWPNow (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/main.js:652:5)
      at async startServer (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/main.js:970:42)
      at async Object.handler (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/main.js:1152:25) {
    [cause]: [<generic error, no stack>] {
      name: 'ErrnoError',
      node: undefined,
      setErrno: [Function (anonymous)],
      errno: 55,
      message: 'FS error'
    }
  }
}
Failed to start the server: Error when executing the blueprint step #1 ({"step":"installPlugin","pluginZipFile":{"resource":"wordpress.org/plugins","slug":"font-awesome"},"options":{"activate":true}}) : Could not move /var/www/html/wp-content/tXW4-8lh6nrAqCPMULyn1dppMr^E,v>Nm!i]/assets/Font awesome/font-awesome to /var/www/html/wp-content/plugins/font-awesome: Directory not empty.

I can't see a way of saying "install this plugin, unless it's already there". Obviously I can work around this by always executing wp-now with the --reset option, but it'd be useful to be able to retain the state of the installation between runs.

wp-now is my new favourite tool though!

@bgrgicak
Copy link
Collaborator

bgrgicak commented Apr 1, 2024

This could be related to WordPress/wordpress-playground#1157
@adamziel suggested a workaround in that issue WordPress/wordpress-playground#1157 (comment)

@squelchdesign
Copy link
Author

This could be related to WordPress/wordpress-playground#1157

Yes, it looks like a different expression of the same issue.

@adamziel suggested a workaround in that issue WordPress/wordpress-playground#1157 (comment)

The problem is the workaround fails on the initial run of wp-now…

Error: Error when executing the blueprint step #1 ({"step":"rmdir","path":"/var/www/html/wp-content/plugins/font-awesome"}) : Could not remove directory "/var/www/html/wp-content/plugins/font-awesome": There is no such file or directory OR the parent directory does not exist.
    at Object.run (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/node_modules/@wp-playground/blueprints/index.js:9215:37)
    at async runBlueprintSteps (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/node_modules/@wp-playground/blueprints/index.js:9320:3)
    ... 2 lines matching cause stack trace ...
    at async Object.handler (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/main.js:1152:25) {
  [cause]: Error: Could not remove directory "/var/www/html/wp-content/plugins/font-awesome": There is no such file or directory OR the parent directory does not exist.
      at descriptor.value (/opt/homebrew/lib/node_modules/@wp-now/wp-now/node_modules/@php-wasm/node/index.cjs:72642:17)
      at Object.rmdir (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/node_modules/@wp-playground/blueprints/index.js:902:11)
      at o (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/node_modules/@wp-playground/blueprints/index.js:9285:61)
      at async Object.run (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/node_modules/@wp-playground/blueprints/index.js:9212:23)
      at async runBlueprintSteps (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/node_modules/@wp-playground/blueprints/index.js:9320:3)
      at async startWPNow (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/main.js:652:5)
      at async startServer (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/main.js:970:42)
      at async Object.handler (file:///opt/homebrew/lib/node_modules/@wp-now/wp-now/main.js:1152:25) {
    [cause]: [<generic error, no stack>] {
      name: 'ErrnoError',
      node: undefined,
      setErrno: [Function (anonymous)],
      errno: 44,
      message: 'FS error'
    }
  }
}
Failed to start the server: Error when executing the blueprint step #1 ({"step":"rmdir","path":"/var/www/html/wp-content/plugins/font-awesome"}) : Could not remove directory "/var/www/html/wp-content/plugins/font-awesome": There is no such file or directory OR the parent directory does not exist.

For now the only workaround seems to be to use --reset.

@adamziel adamziel added this to the Zero Crashes – Tools milestone Apr 2, 2024
@adamziel adamziel added Bug Something isn't working wp-now labels Apr 2, 2024
@adamziel
Copy link
Collaborator

adamziel commented Apr 2, 2024

Thank you for reporting @squelchdesign! I just added this to the project board.

@adamziel adamziel moved this to Future work in Playground Board Jul 1, 2024
johnhooks pushed a commit to johnhooks/playground-tools that referenced this issue Oct 11, 2024
…rdPress#209)

* Export Playground as a full site export

* Introduce jsToPHPTranslator

It solves the problem of escaping arguments when writing PHP code in JavaScript.

Before:
```js
const code = `define('WP_HOME', "${absoluteUrl}");`
// if absoluteUrl contains the '"' character, this code will break
```

After:
```js
const code = t.define('WP_HOME', absoluteUrl).toString();
// absoluteUrl is correctly escaped and can even be an array
// or an object
```

* Import/export support: WXR, WXZ, and full-site

This commit adds multiple ways to move data in and out of Playground.
Specifically, it implements the following client functions:

* zipEntireSite()
* replaceSite()
* exportWXR()
* exportWXZ()
* submitImporterForm()

The WXR format is one natively used by the official WordPress importer plugin.

The WXZ format is supported through the following plugin:

https://github.com/akirk/export-wxz
https://github.com/akirk/wordpress-importer

The full-site export is simply a zip archive containing the entire site.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working wp-now
Projects
None yet
Development

No branches or pull requests

3 participants