trufflesuite / ganache-ui

Personal blockchain for Ethereum development
https://www.trufflesuite.com/ganache
MIT License
4.66k stars 802 forks source link

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

Open davidmurdoch opened 4 years ago

davidmurdoch commented 4 years ago

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.

NateAGeek commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

delaaxe commented 3 years ago

Any news on this?

edxeth commented 2 years ago

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.