OpenNBS / OpenNoteBlockStudio

An open-source Minecraft music maker.
https://opennbs.org/
MIT License
728 stars 50 forks source link

Opening a song from a terminal crashes Note Block Studio #443

Open CreeperPookie opened 3 months ago

CreeperPookie commented 3 months ago

Describe the bug If you try and open an NBS song using a terminal, NBS instantly crashes. It does accept command-line arguments as if I click the file or open it from the taskbar recently opened view, it opens the file fine and shows the same syntax that I tried from a terminal ("<installation location>\Minecraft Note Block Studio.exe" "C:\path\to\nbs\file.nbs") I've confirmed this with CMD, Powershell, and Bash via WSL, so terminal type doesn't seem to matter.

To Reproduce Steps to reproduce the behavior:

  1. Locate the NBS executable from where you installed it or in the default (iirc it's C:\Users\$<username>\AppData\Local\Minecraft Note Block Studio\)
  2. Locate the path of any NBS file saved on your system
  3. Attempt to start it in any terminal with the format "<Note Block Studio install location>\Minecraft Note Block Studio.exe" "C:\path\to\nbs\file.nbs"
  4. See error

Screenshots image

CreeperPookie commented 3 months ago

I've also noticed this when double-clicking an NBS file too, (exact same stacktrace too), which probably passes the file argument in the same way (as if using a terminal)

Bentroen commented 2 months ago

Hi! Just so it's easier for us to reproduce the issue, do you mind attaching the affected .nbs file here? Does this happen with this specific file when you open it from inside the program?

CreeperPookie commented 2 months ago

I just tested opening a bunch of different NBS files, when feeding through command line it still always crashes on load; I even tested some original ones dated from 2011 (probably bundled in a very old version) and it still crashes.

One thing that's odd is that it also crashes when given no arguments whatsoever, as well as when passed a folder instead of a file (pressed enter too early :p); maybe this isn't related to file at all, but something about how it's instantiated; this still doesn't explain why the command line arguments are the exact same when viewed in task manager though

Either way though I'll upload a couple NBS files here that you're welcome to test with :D (legacy, midi imported, and custom NBS v5 songs that I remade) NBS Files.zip

IoeCmcomc commented 2 months ago

I can reproduce the issue on my computer. However, if I run the command from the folder containing the .exe file, it works normally. Also, double-clicking a .nbs file open the file normally in my computer.

CreeperPookie commented 2 months ago

I can reproduce the issue on my computer. However, if I run the command from the folder containing the .exe file, it works normally. Also, double-clicking a .nbs file open the file normally in my computer.

I can also confirm this, and when in the same folder as the executable it does open songs as expected too :O I think I know what it is! NBS probably requires several DLLs or libraries at runtime, and it tries to load them from the current directory instead of its installation location, which causes the crash. This also explains why it's the same arguments in task manager; it starts from its own installation directory and that allows it to start normally.