[BUG] Scripts not loading if scripts/ dir is symlink
Senth opened this issue · 6 comments
After updating fabric-carpet I noticed that my scarpet apps weren't loaded anymore.
It seems the following line is the culprit as it tries to create a directory, but it throws an exception as it cannot do that since it's a symbolic link.
Full error message
java.nio.file.FileAlreadyExistsException: ./Blushine/./scripts
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:88) ~[?:1.8.0_252]
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) ~[?:1.8.0_252]
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) ~[?:1.8.0_252]
at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384) ~[?:1.8.0_252]
at java.nio.file.Files.createDirectory(Files.java:674) ~[?:1.8.0_252]
at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781) ~[?:1.8.0_252]
at java.nio.file.Files.createDirectories(Files.java:727) ~[?:1.8.0_252]
at carpet.script.CarpetScriptServer.listAvailableModules(CarpetScriptServer.java:197) ~[fabric-carpet-1.16.5-1.4.28+v210224.jar:?]
at carpet.script.CarpetScriptServer.initializeForWorld(CarpetScriptServer.java:127) ~[fabric-carpet-1.16.5-1.4.28+v210224.jar:?]
at carpet.CarpetServer.onServerLoadedWorlds(CarpetServer.java:109) ~[fabric-carpet-1.16.5-1.4.28+v210224.jar:?]
at net.minecraft.server.MinecraftServer.handler$zml000$serverLoadedWorlds(MinecraftServer.java:3728) ~[intermediary-minecraft_server.jar:?]
at net.minecraft.server.MinecraftServer.method_3735(MinecraftServer.java:339) ~[intermediary-minecraft_server.jar:?]
at net.minecraft.class_3176.method_3823(class_3176.java:179) ~[intermediary-minecraft_server.jar:?]
at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:645) ~[intermediary-minecraft_server.jar:?]
at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:257) ~[intermediary-minecraft_server.jar:?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]
Weird, I changed that (#590) since the contract of Files#createDirectories
is that it will not create the directory if it already exists, without throwing. Checking it again right now, it seems that it throws "if dir exists and is not a directory", which still doesn't really make sense to me with symlinks.
BTW, did you know that in latest Carpet versions there is a folder (config/carpet/scripts
) where you can put global scripts to be available in any world? (in case that's your use case. However, you can't autoload those natively). Also, note that scriptsAutoload
is now true
by default (in case you didn't autoload all your symlinked apps you should disable it, there is also now a global default config file if you need it).
May try to PR a fix for this Soon™. Should be a matter of just checking if directory exists I guess.
I agree, it would've been better not to throw if the directory is a symlink directory.
Does not fully match my use-case, but I can live with it not being a symlink for the moment. It's mostly for syncing files through Dropbox-like service from my main computer to the server. If I need the functionality and this hasn't been fixed I might create a PR myself 🙂
Yeah, feel free to propose a more robust solution here assuming the 'traditional' path is unchanged.
I've made PR #754 in an attempt to fix this, could you test whether it fixes your issue?
You can find built artifacts for it in its "Checks" tab.
Well, it got merged, so it should in theory work in the next version. Please reopen/make a new issue if it doesn't.