ganache-ui icon indicating copy to clipboard operation
ganache-ui copied to clipboard

Investigate truffle integrations over wsl$ paths (like Windows Ubuntu)

Open davidmurdoch opened this issue 4 years ago • 5 comments

Ganache loads "forever" when a truffle project created via WSL Ubuntu is selected.

Expected: we handle this just like anything else. If that isn't really feasible, an error message should be shown.

davidmurdoch avatar Apr 13 '20 20:04 davidmurdoch

Exploring this a bit more found an error gets emitted in src\integrations\ethereum\common\services\TruffleIntegrationService.js:42

{
  errno: -4068,
  syscall: "watch",
  code: "EISDIR",
  path: "\\\\wsl$\\Ubuntu\\home\\{...}\\truffle-config.js",
  filename: "\\\\wsl$\\Ubuntu\\home\\{...}\\truffle-config.js",
  message: "EISDIR: illegal operation on a directory, watch '\\\\wsl$\\Ubuntu\\home\\{...}\\truffle-config.js'",
  stack: "Error: EISDIR: illegal operation on a directory, watch '\\\\wsl$\\Ubuntu\\home\\{...}\\truffle-config.js'\n    at FSWatcher.start (internal/fs/watchers.js:165:26)\n    at Object.watch (fs.js:1329:11)\n    at ProjectFsWatcher.start (C:\\Users\\{...}\\ganache\\static\\node\\truffle-integration\\projectFsWatcher.js:40:29)\n    at new ProjectFsWatcher (C:\\Users\\{...}\\ganache\\static\\node\\truffle-integration\\projectFsWatcher.js:25:10)\n    at ProjectsWatcher.add (C:\\Users\\{...}\\ganache\\static\\node\\truffle-integration\\projectsWatcher.js:130:23)\n    at process.<anonymous> (C:\\Users\\{...}\\ganache\\static\\node\\truffle-integration\\index.js:59:34)\n    at processTicksAndRejections (internal/process/task_queues.js:93:5)",
  name: "Error",
}

Note: I removed some directory structure, and replaced it with {...}

NateAGeek avatar Mar 28 '21 04:03 NateAGeek

I was able to resolve the issue. The error event emitted was not passed as an "error" event, causing a Promise to never be resolved(hence an infinite loop). However, the root of the error was due to the need to watch the truffle-config.js file via the project-details-request event. For some reason on windows attempting to watch the file causes issues. The following code snippet in static\node\truffle-integration\index.js required a watch on the truffle-config.js(and I assume syscall on WSL UPC paths is not supported?)

    case "project-details-request": {
      let response = await getProjectDetails(message.data.file);

      if (typeof response.error === "undefined") {
        response = await watcher.add(response, message.data.networkId);
      }

      process.send({
        type: "project-details-response",
        data: response,
      });

      break;
    }

commenting out

      if (typeof response.error === "undefined") {
        response = await watcher.add(response, message.data.networkId);
      }

allowed for the truffle-config.js to load and got ganache out of it's infinite loop from the event thread.

I'll see what is the issue with the watcher, however, this for now allows me to load WSL projects.

NateAGeek avatar Mar 28 '21 04:03 NateAGeek

I believe this is an issue with Node.js. Ideally we would a) not support wsl until bug is resolved and display an error b) remove the requirement to watch the truffle-config.js https://github.com/nodejs/node/issues/37960

NateAGeek avatar Mar 30 '21 04:03 NateAGeek

Any news on this?

delaaxe avatar Jun 16 '21 08:06 delaaxe

I was able to resolve the issue. The error event emitted was not passed as an "error" event, causing a Promise to never be resolved(hence an infinite loop). However, the root of the error was due to the need to watch the truffle-config.js file via the project-details-request event. For some reason on windows attempting to watch the file causes issues. The following code snippet in static\node\truffle-integration\index.js required a watch on the truffle-config.js(and I assume syscall on WSL UPC paths is not supported?)

    case "project-details-request": {
      let response = await getProjectDetails(message.data.file);

      if (typeof response.error === "undefined") {
        response = await watcher.add(response, message.data.networkId);
      }

      process.send({
        type: "project-details-response",
        data: response,
      });

      break;
    }

commenting out

      if (typeof response.error === "undefined") {
        response = await watcher.add(response, message.data.networkId);
      }

allowed for the truffle-config.js to load and got ganache out of it's infinite loop from the event thread.

I'll see what is the issue with the watcher, however, this for now allows me to load WSL projects.

This solved my issue, thank you!

Full path on Windows 10: C:\Program Files\WindowsApps\GanacheUI\app\resources\static\node\truffle-integration\index.js It is mandatory to take ownership of the hidden folder 'WindowsApp' before proceeding though.

edxeth avatar Sep 17 '22 08:09 edxeth