Running 'cd ". ."' causes shell to crash
Minecraft Version
1.20.1
Version
1.115.1
Details
My assumtion of what causes the error is a difference in interpretation of what ". ." means. Calling 'cd ". ."' will move to a non-existing directory '. .' as that is how it gets interpreted by the shell, which is what will cause fs to throw an error that the current path does not exist. The reason that 'cd' allows you to go to this non-existing path is that the fs.isDir function returns true for ". .". This is because Java probably interprets '. .' equal to just '.' (calling 'cd ". ."' in cmd causes the directory to stay the same without any errors) and since the current directory exists, it returns true, but as the CraftOS filesystem interprets it as the name of a folder rather than the current directory, it will allow you to enter this non-existing folder, which then causes issues as soon as the shell tries to autocomplete, as the current working directory does not exist.
I'm afraid I can't reproduce this. fs.isDir("..") returns false, and cd .. prints "Not a directory". Would you be able to upload your logs — these will contain some useful info like what operating system you're running, etc...
~~shell interprets ". ." as two arguments: "." and ".", and cd program just silently ignores the second ".". This is WAI I think as all Lua functions will silently ignores excess arguments.~~
I'm afraid I can't reproduce this.
fs.isDir("..")returns false, andcd ..prints "Not a directory". Would you be able to upload your logs — these will contain some useful info like what operating system you're running, etc...
Yes, that is the expected result if you enter ".." as the argument, but what the issuse is with entering ". ." (with a space in between the dots). If you enter it correctly with quotation marks and a space, the issue will occur.
I see what you mean, I think that's because you created a dir with the name ". ."
maybe we are using different version I'll try with 1.20.1 cc
Or this also could be windows specific issue since CC is using native filesystem
Or this also could be windows specific issue since CC is using native filesystem
Probably is.
Weirdly enough, fs.exists works as it should.
This also works for all sorts and kinds of other variations. All of them are interpreted as . by windows
The esiest way to rectify this issue is probably to just adjust the code to check whether the path exists before checking if it is a directory, as that works properly, and if a path does not exist, it cannot be a directory.
Yeah, I'm afraid this appears to be a Windows-specific issue, at least I cannot reproduce on Linux. I've no longer got easy access to a Windows machine, so this is going to require someone else to look at.
Maybe we should just look at doing #2101, at least on Windows. We have a lot of special-handling for Windows's file paths already, and at this point maybe it's no longer worth trying to maintain it.
How practical would it be to get CC to use WSL? All modern Windows have it, though it will make CC more difficult to install.
All modern Windows have it
Sadly it's not installed/enabled by default, and IIRC requires admin permissions to enable.
maybe you can try virtualbox or wmvare to acess windows and them try it if possible
I use Windows 11, so I can do stuff
Hello! I'm new here and found this fun to examine.
This is just Windows being Windows. The "directory" both exists and don't exist.
PS D:\> rmdir ". ."
rmdir : An object at the specified path D:\. . does not exist.
At line:1 char:1
+ rmdir ". ."
+ ~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Remove-Item], PSArgumentException
+ FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.RemoveItemCommand
PS D:\> mkdir ". ."
mkdir : An item with the specified name D:\. . already exists.
At line:1 char:1
+ mkdir ". ."
+ ~~~~~~~~~~~
+ CategoryInfo : ResourceExists: (D:\. .:String) [New-Item], IOException
+ FullyQualifiedErrorId : DirectoryExist,Microsoft.PowerShell.Commands.NewItemCommand
So you don't even need to create that directory, which you can't. It silently fails since fs.makeDir('. .') thinks it already exists. Just make sure the filesystem has been created for the computer:
Got a stack trace too for clarity (the line numbers are offset since I put in logging):
[13:11:09] [ComputerCraft-Computer-Worker-0/WARN] [da.co.co.fi.FileMount/COMPUTER_ERROR.JAVA]: Catching Schrödingers directory
java.nio.file.NoSuchFileException: .\saves\New World\computercraft\computer\0\. .
at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:85) ~[?:?] {}
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103) ~[?:?] {}
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108) ~[?:?] {}
at java.base/sun.nio.fs.WindowsDirectoryStream.<init>(WindowsDirectoryStream.java:86) ~[?:?] {}
at java.base/sun.nio.fs.WindowsFileSystemProvider.newDirectoryStream(WindowsFileSystemProvider.java:541) ~[?:?] {}
at java.base/java.nio.file.Files.newDirectoryStream(Files.java:482) ~[?:?] {}
at TRANSFORMER/[email protected]/dan200.computercraft.core.filesystem.FileMount.list(FileMount.java:66) ~[%23195!/:?] {re:classloading}
at TRANSFORMER/[email protected]/dan200.computercraft.core.filesystem.MountWrapper.list(MountWrapper.java:104) ~[%23195!/:?] {re:classloading}
at TRANSFORMER/[email protected]/dan200.computercraft.core.filesystem.FileSystem.list(FileSystem.java:165) ~[%23195!/:?] {re:classloading}
at TRANSFORMER/[email protected]/dan200.computercraft.core.apis.FSAPI.list(FSAPI.java:106) ~[%23195!/:?] {re:classloading}
at TRANSFORMER/[email protected]/dan200.computercraft.core.asm.LuaMethodSupplier.lambda$static$0(LuaMethodSupplier.java:27) ~[%23195!/:?] {re:classloading}
at TRANSFORMER/[email protected]/dan200.computercraft.core.lua.ResultInterpreterFunction.invoke(ResultInterpreterFunction.java:56) ~[%23195!/:?] {re:classloading}
at MC-BOOTSTRAP/cc.tweaked.cobalt/org.squiddev.cobalt.function.ResumableVarArgFunction.invoke(ResumableVarArgFunction.java:34) ~[cobalt-0.9.6.jar%23104!/:?] {}
at MC-BOOTSTRAP/cc.tweaked.cobalt/org.squiddev.cobalt.function.VarArgFunction.call(VarArgFunction.java:60) ~[cobalt-0.9.6.jar%23104!/:?] {}
at MC-BOOTSTRAP/cc.tweaked.cobalt/org.squiddev.cobalt.function.Dispatch.callImpl(Dispatch.java:106) ~[cobalt-0.9.6.jar%23104!/:?] {}
at MC-BOOTSTRAP/cc.tweaked.cobalt/org.squiddev.cobalt.function.Dispatch.call(Dispatch.java:32) ~[cobalt-0.9.6.jar%23104!/:?] {}
at MC-BOOTSTRAP/cc.tweaked.cobalt/org.squiddev.cobalt.function.LuaInterpreter.nativeCall(LuaInterpreter.java:606) ~[cobalt-0.9.6.jar%23104!/:?] {}
at MC-BOOTSTRAP/cc.tweaked.cobalt/org.squiddev.cobalt.function.LuaInterpreter.execute(LuaInterpreter.java:412) ~[cobalt-0.9.6.jar%23104!/:?] {}
at MC-BOOTSTRAP/cc.tweaked.cobalt/org.squiddev.cobalt.function.LuaInterpretedFunction.resume(LuaInterpretedFunction.java:155) ~[cobalt-0.9.6.jar%23104!/:?] {}
at MC-BOOTSTRAP/cc.tweaked.cobalt/org.squiddev.cobalt.debug.DebugState.resume(DebugState.java:452) ~[cobalt-0.9.6.jar%23104!/:?] {}
at MC-BOOTSTRAP/cc.tweaked.cobalt/org.squiddev.cobalt.LuaThread.loop(LuaThread.java:353) ~[cobalt-0.9.6.jar%23104!/:?] {}
at MC-BOOTSTRAP/cc.tweaked.cobalt/org.squiddev.cobalt.LuaThread.run(LuaThread.java:301) ~[cobalt-0.9.6.jar%23104!/:?] {}
at MC-BOOTSTRAP/cc.tweaked.cobalt/org.squiddev.cobalt.LuaThread.run(LuaThread.java:297) ~[cobalt-0.9.6.jar%23104!/:?] {}
at TRANSFORMER/[email protected]/dan200.computercraft.core.lua.CobaltLuaMachine.handleEvent(CobaltLuaMachine.java:131) ~[%23195!/:?] {re:classloading}
at TRANSFORMER/[email protected]/dan200.computercraft.core.computer.ComputerExecutor.resumeMachine(ComputerExecutor.java:556) ~[%23195!/:?] {re:classloading}
at TRANSFORMER/[email protected]/dan200.computercraft.core.computer.ComputerExecutor.workImpl(ComputerExecutor.java:520) ~[%23195!/:?] {re:classloading}
at TRANSFORMER/[email protected]/dan200.computercraft.core.computer.ComputerExecutor.work(ComputerExecutor.java:460) ~[%23195!/:?] {re:classloading}
at TRANSFORMER/[email protected]/dan200.computercraft.core.computer.computerthread.ComputerThread$WorkerThread.runImpl(ComputerThread.java:639) ~[%23195!/:?] {re:classloading}
at TRANSFORMER/[email protected]/dan200.computercraft.core.computer.computerthread.ComputerThread$WorkerThread.run(ComputerThread.java:593) ~[%23195!/:?] {re:classloading}
at java.base/java.lang.Thread.run(Thread.java:1583) [?:?] {}
I am willing to assist further if it is wanted, but I don't see this as a big deal.