smogon / pokemon-showdown

Pokémon battle simulator.
https://pokemonshowdown.com
MIT License
4.78k stars 2.79k forks source link

Pokemon Showdown doesn't work with WSL2 #6873

Closed thatCode-Psy closed 4 years ago

thatCode-Psy commented 4 years ago

I switched to WSL2 (Windows Subsystem for Linux) to run Docker Desktop for Windows which caused me to be unable to run the server locally without it erroring. I switched back to WSL1 and it worked. I am running the Ubuntu 18.04 LTS distro. The error file is included.

Error: listen ENOTSUP: operation not supported on socket /mnt/d/Documents/MastersProject/pokemon-showdownActual/logs/repl/app
    at Server.setupListenHandle [as _listen2] (net.js:1297:21)
    at listenInCluster (net.js:1362:12)
    at Server.listen (net.js:1459:5)
    at _class.start (/mnt/d/Documents/MastersProject/pokemon-showdownActual/.lib-dist/repl.js:94:10)
    at Object.<anonymous> (/mnt/d/Documents/MastersProject/pokemon-showdownActual/.server-dist/index.js:184:12)
    at Module._compile (internal/modules/cjs/loader.js:1176:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
    at Module.load (internal/modules/cjs/loader.js:1040:32)
    at Function.Module._load (internal/modules/cjs/loader.js:929:14)
    at Object.<anonymous> (/mnt/d/Documents/MastersProject/pokemon-showdownActual/pokemon-showdown:41:20)

errors.txt

Zarel commented 4 years ago

Hm, it looks like an issue trying to open a Unix socket for the server-side REPL.

Zarel commented 4 years ago

I believe my latest commit fixes your problem. Can you try it and report back?

(Also, master's project? That sounds really cool! Can you send me your results when you're done?)

thatCode-Psy commented 4 years ago

That did not appear to fix the problem. I am still getting identical errors. (Would you rather I email or just use this thread for discussion of my master's project?)

Zarel commented 4 years ago

Could you paste the most recent error? If the error is literally identical (down to the line number), it sounds like you didn't successfully update to the latest version in master.

Zarel commented 4 years ago

(This thread isn't a bad place for discussion of your master's project, I think.)

thatCode-Psy commented 4 years ago

It appears that the locations of the errors errors being spit out by the console are different than the errors in the errors.txt file. I copied a large snippet of the errors as they are coming from different places seemingly at random. The cut errors were put into output.txt. They all seem to be CRASH: Error: listen ENOTSUP: operation not supported on socket coming from the locations repl/verifier, repl/app, repl/team-validator-379, and repl/sim-358. errors.txt output.txt

(My master's project is attempting to make a transfer learning agent in random battle. The idea is that by learning how to perform well in one generation, it should then take less time to train in a different generation. Since Pokemon generations are fairly similar domains, I will also be using this project to test some conclusions made in other transfer learning papers on the best form of transfer between similar domains. The project is still in its early stages so I don't have much in the way of results at the moment. It was only today that I got my first instance of very rudimentary transfer. The transfer was from training in generation 1 to using the model in generation 2 and it seems to work. I still need to figure out exactly what state information I plan on storing, the exact makeup of the dqn, and how to reinitialize specific layers between transfers.)

Zarel commented 4 years ago

It's very very weird to me that the try-block isn't catching the error in the crash report.

I pushed a change which might work; I'll reboot into Windows 10 and try to see the errors in for myself if it continues to fail.

(Your master's project sounds really cool! Please send me the paper when you're done!)

thatCode-Psy commented 4 years ago

I pulled the commit, but it doesn't seem to fix the problem. The errors seem to be pretty much the same besides the changed line numbers from the commit but I'll post them anyway in case I missed something. output.txt

Zarel commented 4 years ago

As a stopgap, you should set the repl setting in config/config.js to false, which I believe will fix this.

thatCode-Psy commented 4 years ago

The stopgap does work. What does setting repl to false disable?

Zarel commented 4 years ago

The repl feature allows you to use Unix sockets to connect to a REPL for directly executing code in a PS process. It was crashing WSL2 because WSL2 apparently doesn't support Unix sockets in whatever virtual filesystem Docker is using (I don't understand how the errors are bypassing the try-block, though). It's documented here:

https://github.com/smogon/pokemon-showdown/tree/master/logs/repl

I've personally only used it once, five years ago. Normally, /eval and /evalbattle are good enough for tinkering with live code, on the rare occasions it's necessary at all.

urkerab commented 4 years ago

I haven't used repl since the streams refactor which made it really difficult to locate the Battle object for a given battle (streams used to be indexed by room id but now they're just autonumbered).

Zarel commented 4 years ago

@urkerab

image

Still simpler for me to use >>> battle directly, though.

monsanto commented 4 years ago

I don't know how WSL factors into the equation, but unix socket issues with Docker can be worked around by writing the socket to /dev/shm

edit: (linux only) can also use the "abstract namespace" to avoid binding the socket to the filesystem at all, an abstract address looks something like "\0arbitrarystringhere"

Zarel commented 4 years ago

image

After three reboots, Windows deigns to tell me that my computer doesn't support version 2004 which is required for WSL2. I had no clue it could possibly be this bad, but unfortunately this means I have no way of testing this for myself.

thatCode-Psy commented 4 years ago

I notably do not have Docker installed on the computer that I am running the showdown server from anymore. I uninstalled when I first was having problems which helped lead to the conclusion that wsl2 is likely the source (also that by switching back to wsl1 fixes it).

0xicl33n commented 1 year ago

Im running arch linux WSL2:

root@MUTHR /m/g/c/pokemon-showdown (master) [SIGINT]# n latest
  installing : node-v20.1.0
       mkdir : /usr/local/n/versions/node/20.1.0
       fetch : https://nodejs.org/dist/v20.1.0/node-v20.1.0-linux-x64.tar.xz
     copying : node/20.1.0
   installed : v20.1.0 (with npm 9.6.4)
root@MUTHR /m/g/c/pokemon-showdown (master)# node pokemon-showdown
^[[B
CRASH: Error: listen ENOTSUP: operation not supported on socket /mnt/g/code/pokemon-showdown/logs/repl/team-validator-12860
    at Server.setupListenHandle [as _listen2] (node:net:1806:21)
    at listenInCluster (node:net:1871:12)
    at Server.listen (node:net:1970:5)
    at Object.start (/mnt/g/code/pokemon-showdown/dist/lib/repl.js:143:14)
    at Object.<anonymous> (/mnt/g/code/pokemon-showdown/dist/server/team-validator-async.js:95:31)
    at Module._compile (node:internal/modules/cjs/loader:1267:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1321:10)
    at Module.load (node:internal/modules/cjs/loader:1125:32)
    at Module._load (node:internal/modules/cjs/loader:965:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)

RESTORE CHATROOM: lobby
RESTORE CHATROOM: staff
Worker 1 now listening on 0.0.0.0:8000
Test your server at http://localhost:8000

i changed exports.repl = false; in config.js and it still wont load. what am i doing wrong?