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

Can't start wp-now on Windows OS because of file path fatal #11

Closed
t-hamano opened this issue May 24, 2023 · 14 comments
Closed

Can't start wp-now on Windows OS because of file path fatal #11

t-hamano opened this issue May 24, 2023 · 14 comments
Assignees
Labels
Bug Something isn't working wp-now

Comments

@t-hamano
Copy link
Contributor

I have tried wp-now on both Windows host OS and WSL2 and could not start it. Ths may be a problem with my environment, is there anything I should try?

Commands executed

git clone https://github.com/WordPress/twentytwentythree.git
npm install -g @wp-now/wp-now
cd ./twentytwentythree
wp-now start

Occurred Error

ReferenceError: Event is not defined
    at Object.<anonymous> (/home/{username}/.volta/tools/image/packages/@wp-now/wp-now/lib/node_modules/@wp-now/wp-now/node_modules/@php-wasm/node/index.cjs:66566:33)
    at Module._compile (internal/modules/cjs/loader.js:1114:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:979:32)
    at Function.Module._load (internal/modules/cjs/loader.js:819:12)
    at ModuleWrap.<anonymous> (internal/modules/esm/translators.js:203:29)
    at ModuleJob.run (internal/modules/esm/module_job.js:183:25)
    at async Loader.import (internal/modules/esm/loader.js:178:24)
    at async Object.loadESM (internal/process/esm_loader.js:68:5)
    at async handleMainPromise (internal/modules/run_main.js:59:12)

Environment

Note: Both environments use Volta as their version control tool.

Windows Host

  • OS: Windows OS 11
  • Node Version: 14.21.1

WSL2

  • OS: Ubuntu 20.04.4 LTS
  • Node Version: Tested with both 14.21.3 and 16.18.0
@adamziel
Copy link
Collaborator

@t-hamano You'll need Node.js 18+, the error message isn't very clear about that unfortunately – I'd love to clarify it.

@t-hamano
Copy link
Contributor Author

@adamziel
Thanks for the info!

I was able to move beyond the error in Windows OS by changing the Node version to 18, but another error occurred.

Error Log
wp-now start
Starting the server......
directory: D:\Desktop\twentytwentythree
mode: theme
php: 8.0
wp: latest
Downloading WordPress latest...
Downloading SQLite...
Error: Could not mount C:\Users\tetsuaki.hamano\.wp-now\mu-plugins: There is no such file or directory OR the parent directory does not exist.
    at descriptor.value (C:\Users\tetsuaki.hamano\AppData\Local\Volta\tools\image\packages\@wp-now\wp-now\node_modules\@wp-now\wp-now\node_modules\@php-wasm\node\index.cjs:67333:17)
    at mountMuPlugins (file:///C:/Users/tetsuaki.hamano/AppData/Local/Volta/tools/image/packages/@wp-now/wp-now/node_modules/@wp-now/wp-now/main.js:623:7)
    at runPluginOrThemeMode (file:///C:/Users/tetsuaki.hamano/AppData/Local/Volta/tools/image/packages/@wp-now/wp-now/node_modules/@wp-now/wp-now/main.js:589:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///C:/Users/tetsuaki.hamano/AppData/Local/Volta/tools/image/packages/@wp-now/wp-now/node_modules/@wp-now/wp-now/main.js:501:9
    at async applyToInstances (file:///C:/Users/tetsuaki.hamano/AppData/Local/Volta/tools/image/packages/@wp-now/wp-now/node_modules/@wp-now/wp-now/main.js:437:5)
    at async startWPNow (file:///C:/Users/tetsuaki.hamano/AppData/Local/Volta/tools/image/packages/@wp-now/wp-now/node_modules/@wp-now/wp-now/main.js:486:3)
    at async startServer (file:///C:/Users/tetsuaki.hamano/AppData/Local/Volta/tools/image/packages/@wp-now/wp-now/node_modules/@wp-now/wp-now/main.js:707:42)
    at async Object.handler (file:///C:/Users/tetsuaki.hamano/AppData/Local/Volta/tools/image/packages/@wp-now/wp-now/node_modules/@wp-now/wp-now/main.js:864:25) {
  [cause]: ErrnoError
      at Object.ensureErrnoError (C:\Users\tetsuaki.hamano\AppData\Local\Volta\tools\image\packages\@wp-now\wp-now\node_modules\@wp-now\wp-now\node_modules\@php-wasm\node\index.cjs:20233:33)
      at Object.staticInit (C:\Users\tetsuaki.hamano\AppData\Local\Volta\tools\image\packages\@wp-now\wp-now\node_modules\@wp-now\wp-now\node_modules\@php-wasm\node\index.cjs:20241:10)
      at Object.init3 (C:\Users\tetsuaki.hamano\AppData\Local\Volta\tools\image\packages\@wp-now\wp-now\node_modules\@wp-now\wp-now\node_modules\@php-wasm\node\index.cjs:24083:6)
      at loadPHPRuntime (C:\Users\tetsuaki.hamano\AppData\Local\Volta\tools\image\packages\@wp-now\wp-now\node_modules\@wp-now\wp-now\node_modules\@php-wasm\node\index.cjs:67352:38)
      at doLoad (C:\Users\tetsuaki.hamano\AppData\Local\Volta\tools\image\packages\@wp-now\wp-now\node_modules\@wp-now\wp-now\node_modules\@php-wasm\node\index.cjs:68234:31)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async _NodePHP.load (C:\Users\tetsuaki.hamano\AppData\Local\Volta\tools\image\packages\@wp-now\wp-now\node_modules\@wp-now\wp-now\node_modules\@php-wasm\node\index.cjs:68206:12)
      at async startWPNow (file:///C:/Users/tetsuaki.hamano/AppData/Local/Volta/tools/image/packages/@wp-now/wp-now/node_modules/@wp-now/wp-now/main.js:460:7)
      at async startServer (file:///C:/Users/tetsuaki.hamano/AppData/Local/Volta/tools/image/packages/@wp-now/wp-now/node_modules/@wp-now/wp-now/main.js:707:42)
      at async Object.handler (file:///C:/Users/tetsuaki.hamano/AppData/Local/Volta/tools/image/packages/@wp-now/wp-now/node_modules/@wp-now/wp-now/main.js:864:25) {
    node: undefined,
    setErrno: [Function (anonymous)],
    errno: 44,
    message: 'FS error'
  }
}

The mount path (C:\Users\tetsuaki.hamano\.wp-now\mu-plugins) indicated by this error exists on the host OS. However, compared to the results of the WSL2 run, we noticed that the following directories are missing:

  • C:\Users\tetsuaki.hamano\.wp-now\wp-content\twentytwentythree-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\mu-plugin
  • C:\Users\tetsuaki.hamano\.wp-now\wp-content\twentytwentythree-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\database

I still don't understand the project, but if I have time I will try to find the cause.

@jason3by2
Copy link

Can confirm I'm getting the exact same error, using node v18.16.0, will report back if I can get past it.

@adamziel
Copy link
Collaborator

adamziel commented May 24, 2023

Interesting! Thank you so much for surfacing this issue @t-hamano and helping to triage @jason3by2! This helps with making it work for all the Windows users out there.

Solutions-wise, I wonder if this path is even visible/accessible from Node.js. Could it be a permissions issue? Could that be an issue with mixing file:///C:/ notation and C:\ notation?

cc @danielbachhuber @sejas @wojtekn

@adamziel adamziel added Bug Something isn't working wp-now labels May 24, 2023
@t-hamano
Copy link
Contributor Author

Could that be an issue with mixing file:///C:/ notation and C:\ notation?

The URI with the file: protocol shown in the error log seems to be at least accessible from the browser. Therefore, I believe this notation is correct:

file-protcol

at mountMuPlugins (file:///C:/Users/tetsuaki.hamano/AppData/Local/Volta/tools/image/packages/@wp-now/wp-now/node_modules/@wp-now/wp-now/main.js:623:7)

The location indicated by this error is this line:

https://github.com/WordPress/wordpress-playground/blob/043f677f36528e72108d8d6fa8b4d311ec43bf2d/packages/wp-now/src/wp-now.ts#L296

Perhaps vfsDocumentRoot is not the correct path?

@richard-bonk-bf
Copy link

@adamziel Thanks for the info!

I was able to move beyond the error in Windows OS by changing the Node version to 18, but another error occurred.

Error Log
The mount path (C:\Users\tetsuaki.hamano\.wp-now\mu-plugins) indicated by this error exists on the host OS. However, compared to the results of the WSL2 run, we noticed that the following directories are missing:

  • C:\Users\tetsuaki.hamano\.wp-now\wp-content\twentytwentythree-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\mu-plugin
  • C:\Users\tetsuaki.hamano\.wp-now\wp-content\twentytwentythree-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\database

I still don't understand the project, but if I have time I will try to find the cause.

I am getting the same error.

@danielbachhuber danielbachhuber changed the title Can't start wp-now on Windows OS Can't start wp-now on Windows OS because of file path fatal May 25, 2023
@danielbachhuber
Copy link
Member

@t-hamano @richard-bonk-bf @narinder9 I'm unable to reproduce because I don't have a Windows machine, unfortunately. My guess is that it's a path issue. To start on the debugging journey, can you install from Git clone and see if the issue reproduces with nx preview wp-now start ?

@t-hamano
Copy link
Contributor Author

@danielbachhuber

Unfortunately, because that script contains UNIX commands, it cannot be debugged on the Windows host OS. The results of the nx preview wp-now start command are shown in the video below:

6eae1c565760fd778d2d5b898b0bab0c.mp4

If on WSL, that command will work fine, but will instead cause the problems mentioned in this comment. Also, this problem would need to be verified on a Windows host OS, not a WSL.

This is why I submitted WordPress/wordpress-playground#435 😅

@danielbachhuber
Copy link
Member

@t-hamano I guess this shows how thoroughly we tested on Windows 😅

All of this makes sense, thanks! I guess we'll need to figure out a solution for WordPress/wordpress-playground#435 first.

@danielbachhuber danielbachhuber transferred this issue from WordPress/wordpress-playground May 31, 2023
@wojtekn wojtekn self-assigned this Jun 1, 2023
@wojtekn
Copy link
Collaborator

wojtekn commented Jun 5, 2023

I reproduced that issue on Windows 11 with PowerShell:

PS C:\Users\wojtek\playground-tools> wp-now start --path=../wordpress-seo
Starting the server......
directory: ../wordpress-seo
mode: plugin
php: 8.0
wp: latest
Downloading WordPress latest...
Downloading SQLite...
Error: Could not mount C:\Users\wojtek\.wp-now\mu-plugins: There is no such file or directory OR the parent directory does not exist.    at descriptor.value (C:\Users\wojtek\AppData\Roaming\npm\node_modules\@wp-now\wp-now\node_modules\@php-wasm\node\index.cjs:67405:17)
[...]

Then I tried running the development version of the wp-now tool to debug it, but I couldn't run the build on Windows. I reported it under another ticket #66. We must fix the build issue to debug the mounting problem more.

@adamziel
Copy link
Collaborator

adamziel commented Jun 6, 2023

function mountMuPlugins(php: NodePHP, vfsDocumentRoot: string) {
php.mount(
path.join(getWpNowPath(), 'mu-plugins'),
path.join(vfsDocumentRoot, 'wp-content', 'mu-plugins')
);
}

The first path.join() yields C:\Users\adam\.wp-now\mu-plugins which is fine

The second path.join() yields \var\www\html\wp-content\mu-plugins which is not a valid path in the VFS

So – we can’t use path.join for VFS paths because it uses the Windows-style slashes on Windows.

danielbachhuber pushed a commit that referenced this issue Jun 6, 2023
…71)

## Description

Solves #11

`wp-now` mounts mu-plugins like this:

```ts
    php.mount(
        path.join(getWpNowPath(), 'mu-plugins'),
        path.join(vfsDocumentRoot, 'wp-content', 'mu-plugins')
    );
```

The first path is the local HOST path, the second path is a VFS path.

On Mac and linux, they both use forward slashes.

On Windows, the first path can use backslashes, but the VFS path still
needs to use forward slashes.

Problem is: `path.join()` transforms all slashes to backslashes on
Windows, which makes the second path invalid like `\\var\\www\\html`.

This commit corrects that.

## Testing Instructions

Confirm wp-now and the VS code extension can both be started on Windows.
Confirm they didn't break on Mac or linux.

---------

Co-authored-by: sejas <antonio@sejas.es>
@t-hamano
Copy link
Contributor Author

t-hamano commented Jun 7, 2023

I reinstalled the latest wp-now including #71 on my Windows host OS. I was able to boot successfully and would like to close this issue.

Thank you so much!

@t-hamano t-hamano closed this as completed Jun 7, 2023
@danielbachhuber
Copy link
Member

Thanks for your help tracking it down, @t-hamano !

@jason3by2
Copy link

Heyas, just wanted to pop back in here to confirm that the latest version also runs successfully for me on win10.
Nice work all! :)

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

6 participants