Skip to content

Inconsistent tilde (~) path expansion across file-handling commands #2152

Open

Description

@vdom-1

The bug

We have identified an inconsistency in how the cart insert and debug symbols load console commands handle tilde (~) path expansion. While wrapping paths in [file normalize ...] works because Tcl expands the tilde before passing the result to the command, passing a tilde path directly will fail.

At this time, we have only verified this behavior for these two commands and cannot assert whether other file-handling commands in openMSX are affected.

Furthermore, the two affected commands fail in distinct ways: debug symbols load fails to locate the file passively, while cart insert attempts to resolve the path in an incorrect relative manner, prepending default directories and treating the ~ as a literal folder name.

Reproduce

Case 1: debug symbols load (Passive Failure)

Passing ~ directly fails to resolve the path outright:

debug symbols load "~/MSX/workspace/msxai-harness/out/bare-metal/bare-metal.sym"

Error output:

Couldn't load symbol file '~/MSX/workspace/msxai-harness/out/bare-metal/bare-metal.sym': File "~/MSX/workspace/msxai-harness/out/bare-metal/bare-metal.sym" not found

Case 2: cart insert (Active/Incorrect Concatenation)

Passing ~ directly to cart insert causes openMSX to treat the tilde as a literal folder name and concatenate it with the default emulator directory (on Windows, typically the user's Documents folder):

cart insert "~/MSX/workspace/msxai-harness/out/bare-metal/bare-metal.rom"

Error output:

Invalid ROM file: C:/Users/vdom-1/Documents/MSX/workspace/msxai-harness/out/bare-metal/bare-metal.rom
(Notice how the emulator has swapped the tilde for C:/Users/vdom-1/Documents)

The Workaround (Both Work)

Explicitly forcing Tcl to normalize the path beforehand resolves the issue perfectly:

debug symbols load [file normalize "~/MSX/workspace/msxai-harness/out/bare-metal/bare-metal.sym"]
cart insert [file normalize "~/MSX/workspace/msxai-harness/out/bare-metal/bare-metal.rom"]

Expected behavior

The cart insert and debug symbols load commands should consistently resolve and expand the tilde (~) shortcut to the user's home directory when passed directly, matching the behavior of Tcl's native resolution.

Ideally, standardizing this path/tilde expansion helper across all openMSX console commands that manipulate or load files would prevent similar issues from occurring elsewhere in the codebase.

Additional Context

This behavior was discussed with @MBilderbeek on msx.org who suggested creating an issue here.

Activity

  1. m9710797 commented on Jul 15, 2026

    @m9710797
    Contributor

    Hi,

    Thanks for this bug report! Let me start with some background info. Afterwards we can discuss possible solutions:

    • Very early versions of openMSX did have a console with commands like diska, carta, ... but no embedded Tcl interpreter yet.
    • This version did already support tilde expansion. This is manually implemented in each command that does something with files (I mean each is responsible for calling the tilde-expansion-helper function).
    • Later we added a Tcl interpreter, and reimplemented the commands as Tcl commands. This required (almost) no changes to the syntax of the existing commands. So for the users the commands just kept working, but now extended with a whole programming language.
    • The commands themselves are still responsible for doing tilde-expansion. This is still the same helper function. We do not use the Tcl file normalize functionality internally.
    • To be honest I didn't even know that file normalize did tilde expansion. And when I do some research now, it seems that this is an incompatible change between Tcl8 and Tcl9: Tcl8 does tilde expansion in many places, Tcl9 doesn't do that anymore but instead offers a new file tildeexpand command. See this article for more info. When reading that article, I agree that in a programming language automatic tilde expansion is not the best idea. OTOH it is very convenient for interactive use in the openMSX console.

    Now back to your bug report:

    • The fact that tilde expansion works for carta, but not for debug symbols load is because we explicitly handle it in the former, but not in the latter. That's an inconsistency that we should fix. (At no point is file normalize involved).
    • The openMSX tilde expansion (I mean the version you get with carta) is something we implemented ourselves. I'm very familiar with Linux, so I made sure it works the same as tilde expansion in most Linux shells. I'm not familiar with Windows. (It's probably +25 years ago at this point) I think I made an attempt to also do something reasonable on Windows, but I have no idea if it's the same as current windows shells (and I also think 25 years ago most windows shells did not do tilde expansion .. I can be wrong).

    Anyway, that's the historical background. Now for the fix. I think there are two separate bugs:

    • Tilde expansion on windows is not correct. We can fix that. But can someone describe to me what exactly the correct behavior should be on windows? We could delegate to Tcl, although the Tcl8 vs Tcl9 stuff makes that more difficult: we still want to support Tcl8 (because Tcl9 is not widely available yet), but Tcl8 does not have a standalone tildeexpansion function yet (and we don't always want to combine it with a full normalization).
    • We should do an audit of all openMSX commands that use filenames, and make them consistent w.r.t. tilde-expansion. Either always do it, or never do it.
  2. vdom-1 commented on Jul 15, 2026

    @vdom-1
    Author

    Hi Wouter,

    Thanks for the historical background! That makes perfect sense of why things behave the way they do.

    Here are my thoughts on how we can tackle this:

    1. Correcting a Small Misunderstanding on carta insert vs debug symbols load

    Just to make sure we are on the exact same page neither commands is actually working right now... they just fail in different ways:

    • carta insert (tries to handle the tilde but gets it wrong): It actually swaps the tilde ~ for C:/Users/vdom-1/Documents/ and not C:/Users/vdom-1/
    • debug symbols load (doesn't try): It doesn't even attempt to resolve the tilde; it just fails immediately because it passes the literal ~ straight through.

    Your explanation of the background completely cleared up why they fail differently, and it makes total sense why debug symbols load isn't attempting any expansion!

    2. The Tcl 8 vs. Tcl 9 Dilemma & file normalize

    I don't have deep prior experience with Tcl, so the "Tilde Substitution" quirks mentioned in the wiki were new to me.

    My take on this is pragmatism: we should focus on fixing this for the version we are actually working with right now (which is Tcl 8) and cross the Tcl 9 bridge when Tcl 9 is widely adopted and ready for openMSX.

    My instincts (and some local tests) tell me that simply passing the input through file normalize on the Tcl side might do exactly what we need, at least within the context of the emulator's scripts.

    Do you think using file normalize would work as a clean wrapper for us on Tcl 8, or does your experience with Tcl’s quirks suggest that it might introduce some hidden edge cases?

    3. Streamlining implementation with a unified helper

    "We should do an audit of all openMSX commands that use filenames, and make them consistent w.r.t. tilde-expansion. Either always do it, or never do it."

    I completely agree with doing an audit of all openMSX commands that use filenames to make them consistent.

    The beauty of introducing a single, unified helper function is that we don't have to wait for Tcl 9 to solve the Tilde Substitution issue.

    We can write a temporary path-normalization/tilde-expansion solution for Tcl 8 right now(perhaps using file normalize). When Tcl 9 is eventually ready for production, we won't have to rewrite a thing across the rest of the codebase, we will only have to update that one single helper function to leverage Tcl 9's native features.

    This gives us a single source of truth to handle tildes, backslashes, or any platform-specific path issue, while keeping the codebase prepared for the future.

  3. m9710797 commented on Jul 15, 2026

    @m9710797
    Contributor

    A few clarifications, and questions:

    Today openMSX can work with either Tcl8 or Tcl9. Some Linux distributions already have Tcl9, other still only offer Tcl8. ATM we make sure openMSX still works with 8, but if you have 9 installed on your system we use that. That's similar to the other libraries we use (zlib, libpng, FreeType, ...) we require some minimal version, but if you have a newer version we'd happily use that.

    Usually that works fine, usually there are no backwards incompatibilities between library versions. This file normalize thing is one of the few exceptions (and before today I wasn't even aware of it).

    But that does mean we cannot use Tcl to do tilde expansion:

    • If the user builds openMSX with Tcl8 we'd have to use file normalize (file tildeexpand doesn't exist yet) but that does much more than only tilde expansion (e.g. convert to absolute path, normalize .. and . components, resolve symlinks, ...).
    • Only if the user builds with Tcl9 we could use file tildeexpand, but we cannot count on this.

    So I think we still have to implement tilde expansion ourselves. And to do that correctly in Windows I need your help:

    • Can you specify exactly how this should behave in windows. What exactly should ~/ be replaced with? (And is that maybe different on different windows versions? Or can it be overridden by environment variables or other settings? Then how to obtain this replacement string? ...)
    • Does windows also support ~<username>/?
    • ... anything else?
  4. m9710797 commented on Jul 15, 2026

    @m9710797
    Contributor

    I did some research:

    • Current we use this to obtain the windows "home dir": SHGetSpecialFolderPathW(nullptr, bufW, CSIDL_PERSONAL, TRUE)
    • Apparently the correct(?) way is: SHGetKnownFolderPath(FOLDERID_Profile, 0, nullptr, &wPath)

    The former is a (now deprecated) old windows call. The later is "new" in Windows Vista, so actually also already quite old, but it didn't exist yet when we originally wrote this code in openMSX.

  5. vdom-1 commented on Jul 16, 2026

    @vdom-1
    Author

    Given that file normalize performs more than just tilde expansion, I think it's probably best to set that approach aside and focus purely on tilde expansion.

    Your research also clarified the Windows behavior for me. Looking back at my original report:

    cart insert "~/MSX/workspace/msxai-harness/out/bare-metal/bare-metal.rom"
    

    Error output:

    Invalid ROM file: C:/Users/vdom-1/Documents/MSX/workspace/msxai-harness/out/bare-metal/bare-metal.rom
    (Notice how the emulator has swapped the tilde for C:/Users/vdom-1/Documents)

    I initially misinterpreted what have happened, but it now makes sense that openMSX was performing tilde expansion. It was just expanding ~ to the Documents folder because it currently uses the legacy SHGetSpecialFolderPathW with CSIDL_PERSONAL:

    std::string getUserHomeDir(std::string_view username)
    {
    #ifdef _WIN32
    	(void)(&username); // ignore parameter, avoid warning
    
    	std::array<wchar_t, MAXPATHLEN + 1> bufW;
    	if (!SHGetSpecialFolderPathW(nullptr, bufW.data(), CSIDL_PERSONAL, TRUE)) {
    		throw FatalError(
    			"SHGetSpecialFolderPathW failed: ", GetLastError());
    	}
    
    	return getConventionalPath(utf16to8(bufW.data()));
    #else
    ...
    #endif
    }

    CSIDL_PERSONAL represents the user's Documents folder, that explains exactly where the extra Documents component came from.

    From what I've been reading, SHGetKnownFolderPath(FOLDERID_Profile, ...) is the modern API (hasn't changed since Windows Vista) for obtaining the user's profile directory (e.g. C:\Users\<username>), which is what I would expect ~ to represent. From a user's perspective, ~ normally refers to the user's home directory.

    The only consideration I can think of is Windows XP compatibility, since FOLDERID_Profile was introduced in Windows Vista. If the openMSX 64 bit binary still intentionally supports Windows XP Professional x64 Edition, then the legacy implementation may need to remain as a fallback. Otherwise, if Vista or newer(up to Windows 11) is already the effective baseline for supported Windows versions, switching to SHGetKnownFolderPath(FOLDERID_Profile, ...) seems like the more appropriate implementation.

    So unless I'm overlooking something, it seems like we could simply update getUserHomeDir() to use the appropriate Windows API for the current user's profile directory.

  6. m9710797 commented on Jul 16, 2026

    @m9710797
    Contributor

    I think we dropped support for Windows XP a few(?) years ago?

    In principle the fix is clear: change SHGetSpecialFolderPathW to SHGetKnownFolderPath. Though I'm a bit concerned about backwards compatibility? Are windows users using tilde expansion (clearly vdom-1 is)? Then after this change it will resolve to a different path. It's more correct (and probably more aligned with how other windows programs do tilde expansion), but nevertheless it's different, so it might break some users existing setup. Any ideas? Opinions?

    Maybe we should just change it and break backwards compatibility? Probably(?) not too many windows users actually use tilde expansion?

  7. vdom-1 commented on Jul 16, 2026

    @vdom-1
    Author

    Hi Wouter,

    I think we are completely safe to make this change.

    If we are strictly talking about the openMSX Win 64-bit binary, the only users who could theoretically be impacted by the API change are those running Windows XP Professional x64 edition (the only 64-bit Windows release prior to Vista). That OS was never widely adopted—it essentially served as a public testbed for Microsoft's 64-bit ecosystem—so that user base is virtually non-existent today.

    Furthermore, there is actually no risk of the path resolving differently for modern Windows users.

    • On Windows Vista and newer, both SHGetSpecialFolderPathW(..., CSIDL_PROFILE) and SHGetKnownFolderPath(..., FOLDERID_Profile) resolve to the exact same folder: C:\Users\<username>.
    • The older "Documents and Settings" path is only returned by the legacy API.

    As for tilde ~ usage on Windows:

    • It has been native to Windows PowerShell since v1.0 (2006).
    • It’s primarily used by developers, power users or users with a Unix background.
  8. m9710797 commented on Jul 20, 2026

    @m9710797
    Contributor

    Sorry for the delay.

    I agree that currently openMSX uses the wrong path. I agree there's no risk of openMSX no longer working on older windows versions.

    I do not agree with your statement "... there is actually no risk of the path resolving differently for modern Windows users ...".
    What I meant was:

    • openMSX has been doing this wrong for +20 years now.
    • Some of our older users (or loyal users if you prefer), may have gotten used to this old tilde expansion (even if it is technically wrong), and have put their files in the corresponding directory.
    • So if we change (=fix) it now, we DO break backwards compatibility. Some scripts written by users might no longer work after this change.

    But maybe this isn't a big deal, and we should just change it. And then possibly some users need to adapt.

    Maybe the more difficult (as in tedious) part of fixing this, is finding all openMSX commands that deal with filenames, and make sure they apply tilde expansion. Do you think you could help with this?

  9. vdom-1 commented on Jul 21, 2026

    @vdom-1
    Author

    You're right—some users may have adapted their setups to account for the legacy Windows API that uses the Documents folder instead of the user profile folder. So yes, there is a risk of this change breaking existing workflows or custom scripts.

    Nevertheless, I believe aligning the Win 64-bit binary with the modern API is a positive step for the future of openMSX on the platform. Furthermore, the impact will be contained to the specific functions utilizing the legacy API, rather than all functions that need file access . As we know, there isn't a single, streamlined implementation for tilde (~) expansion across the codebase, and some functions don't even support it at all.

    Ultimately, it is up to you whether you want to push forward with this change, and it might be worth gathering the community's input as well.

    Count me in for this endeavor! I have already created a preliminary checklist of all the file-access functions I could find, which we can use to track our progress.

  10. vdom-1 commented on Jul 21, 2026

    @vdom-1
    Author

    Legend

    Key Status
    ✔️ OK
    ❌ NOK
    ❔ TO-CHECK

    Installation

    As per issue #2162 the Commit c7c3bc6 broke the installation because the documentation points users to the legacy Documents\ folder.

    Currently:

    Platform User directory
    Windows (e.g. Windows 7) C:\Users\<user name>\Documents\openMSX\share whereby  stands for your Windows login name

    Suggested:

    Platform User directory
    Windows (Vista / 7 / 8 / 10 / 11, 64-bit) %APPDATA%\openMSX\share or C:\Users\<user name>\AppData\Roaming\openMSX\share (whereby stands for your Windows login name)

    Commands

    Check Command Description Test Notes
    [✔️] cart <filename> / carta / cartb Inserts ROM cartridge from file Commit c7c3bc6 fixes it
    [✔️] cart insert <filename> / carta insert / cartb insert Inserts ROM cartridge from file Commit c7c3bc6 fixes it
    [✔️] casload <file> Opens CAS-file for loading
    [✔️] cassave <file> Saves to a CAS-file
    [✔️] casrun <file> [<number>] Automatically runs program from CAS-file
    [❔] cassetteplayer <filename> /cassetteplayer insert/cassetteplayer new Inserts a tape file image Commit c7c3bc6 might've fixed it
    [❌] data_file Resolve data file. First try user directory, if the file doesn't exist there try the system directory Never resolves files in the User(or Document) folder. $::env(OPENMSX_SYSTEM_DATA)
    [❌] debug symbols load <filename> [<type>] Loads a symbol file into the debugger No tilde expansion support
    [❌] debug symbols remove <filename> Removes a previously loaded symbol file No tilde expansion support
    [❌] debug symbols lookup [-filename <filename>] [-name <name>] [-value <value>] Returns a list of symbols in an optionally given file and/or with an optionally given name/value No tilde expansion support
    [❔] diska insert <diskfile> /diska <diskfile> Inserts disk image Commit c7c3bc6 might've fixed it
    [❔] diskmanipulator create <fn> <sz> Creates a formatted dsk file named <fn> Commit c7c3bc6 might've fixed it
    [❔] diskmanipulator savedsk <dn> <fn> Saves disk <dn> as dsk file named <fn> Commit c7c3bc6 might've fixed it
    [❔] diskmanipulator import <disk> <dir/file> Imports files and subdirs from <dir/file> Commit c7c3bc6 might've fixed it
    [❔] diskmanipulator export <disk> <host dir> Exports all files on <disk> to <host dir> Commit c7c3bc6 might've fixed it
    [❌] get_breakpoints_dir Returns breakpoint directory path Uses the Documents folder(e.g., C:/Users/vdom-1/Documents/openMSX/breakpoints)
    [✔️] load_breakpoints <file> Loads breakpoints from file
    [✔️] load_debuggable <file> Loads raw data into a debuggable from file
    [❔] load_machine Loads machine configuration from file I don't know how to test this. "Already loaded a config in this machine"
    [❔] load_settings <file> Loads settings from given file Commit c7c3bc6 might've fixed it
    [❌] loadstate <name> Restores a previously created savestate If file-path not specified loads from Documents folder otherwise no tilde expansion support
    [❌] multi_screenshot <num> [<base>] Takes multiple screenshots (saves files) No tilde expansion support. Defaults to Documents folder
    [✔️] psg_log start <filename> Logs PSG registers to file
    [❔] record start <filename> Records video/audio to .avi file Commit c7c3bc6 might've fixed it
    [✔️] reg_log record <debuggable> [<filename>] Logs debuggable state to file
    [✔️] reg_log play <debuggable> <filename> Replays a log in <filename>
    [✔️] save_breakpoints <file> Saves breakpoints to file
    [✔️] save_debuggable <debuggable> <file> Saves part of a debuggable to file
    [❔] save_msx_screen Saves current screen to binary file Commit c7c3bc6 might've fixed it
    [❔] save_settings Saves the current settings Commit c7c3bc6 might've fixed it
    [✔️] save_to_file <filename> <args> Helper procedure to write command output to a file
    [❌] savestate <name> Creates a snapshot/savestate file If file-path not specified saves to Documents folder otherwise no tilde expansion support
    [✔️] sdcdb open <directories> [<cdbFile>] Opens a project directory and starts debugging session
    [✔️] sdcdb list <file>:<line/functionName> Lists contents of a C source file at specific location
    [❔] screenshot <filename> Writes screenshot to indicated file Commit c7c3bc6 might've fixed it
    [❔] sha1sum <file> Calculates SHA1 value for the given file Commit c7c3bc6 might've fixed it
    [❌] store_machine <id> <file> Saves machine state to file No tilde expansion support
    [❔] store_setup <depth> [file] Saves setup to file Commit c7c3bc6 might've fixed it. Built-in help does not explain <depth> argument. I will create a an separate issue for this.
    [✔️] type_from_file <args> <filename> Types content of the indicated file
    [✔️] type_password_from_file <filename> <index> Types a specific line from file
    [✔️ ] vgm_rec Records VGM file from audio vgm_rec prefix works fine with tilde

    Settings

    Check Setting Description Test Notes
    [❌] set {Debug Device output} <output file> Writes debug output to the specified file No tilde expansion support
    [❔] set audio-inputfilename filename of the file where the sampler reads data from Setting a file-path with tilde does not generate error however I don't know how to use the sample feature in order to test if the file will be found when needed
    [❔] set auto_save_replay_filename Filename of the replay file that will be saved when auto_save_replay is enabled Commit c7c3bc6 might've fixed it
    [❔] set gui_font_default_filename TTF font filename for the default GUI font Commit c7c3bc6 might've fixed it
    [❔] set gui_font_mono_filename TTF font filename for the monospaced GUI font Commit c7c3bc6 might've fixed it
    [❔] set midi-out-logfilename filename of the file where the MIDI output is logged to Couldn't test as I don't have MIDI
    [❔] set printerlogfilename filename of the file where the printer output is logged to Couldn't test
    [❔] set rs232-inputfilename filename of the file where the RS232 input is read from Couldn't test
    [❔] set rs232-outputfilename filename of the file where the RS232 output is written to Couldn't test
  11. added a commit that references this issue on Jul 21, 2026
  12. m9710797 commented on Jul 21, 2026

    @m9710797
    Contributor

    Thanks for this checklist! Now let's fill it in and complete it (make all supported).
    I propose to categorize these in 3 lists, maybe something like this:

    • OK: carta, diska, ...
    • NOT-OK: debug symbols load, ...
    • TO-CHECK: ... all the rest ...

    We could use lists like this, or update your checklist above. Does github allow infinite updates (i mean not limited in time) to comments, and by any user (that would be weird). My main point is: we need a category "to-be-investigated" in addition to just a binary check.

    In the mean time I did push a fix for the actual tilde expansion on windows. Please help test (I can't test myself on windows).

  13. vdom-1 commented on Jul 21, 2026

    @vdom-1
    Author

    I think GitHub allows for infinite edits to a post (we will find out).

    As suggested, I've created a legend (key/status) so we can track our progress more precisely. Let's use the NOTES column to communicate specifics about a certain command or setting's implementation.

    Bear in mind that since I am not testing against commit c7c3bc6 and don't yet know all the functions affected by the getUserHomeDir() change, I might raise some false negatives. However, we can clarify those one by one as we go through the list.

  14. vdom-1 commented on Jul 23, 2026

    @vdom-1
    Author

    Hi Wouter,

    When you see the Test Note—“Commit c7c3bc6 might've fixed it”—it's simply because those commands fail in the exact same way carta did prior to the new API change (appending the Documents folder to the user profile folder), rather than from a deep dive into the code implementation.

    That said, I did take a look at some of the implementations to get a feel for what’s going on under the hood, just in case you need help there too. I guesstimate the API update will fix most of the issues marked as [❔] (TO-CHECK), though certainly not all of them.

    Also, let me know if I should remove the description column (since we already know what the commands do) and perhaps use that space to track something else, like implementation notes?

  15. added a commit that references this issue on Jul 28, 2026
  16. 6 remaining items

  17. MBilderbeek commented on Jul 30, 2026

    @MBilderbeek
    Member
  18. vdom-1 commented on Jul 30, 2026

    @vdom-1
    Author

    A clear distinction must be made between installation and usage. While CSIDL_LOCAL_APPDATA is the correct target for the openMSX installation data, the path expansion (the tilde expansion) for used during runtime should target CSIDL_PERSONAL.

    Furthermore, this migration will need to happen sooner or later and why not tackle it now while we have these many people already involved?

  19. vdom-1 commented on Jul 31, 2026

    @vdom-1
    Author

    As the change is already in master, the documentation already needs an
    update right now... I will approve a PR that does that...

    Op wo 29 jul. 2026 23:07 schreef vdom-1 @.***>:
    …

    My suggestion:

    3.4.1 ROM Locations

    ...

    Platform User directory
    Windows (Vista / 7 / 8 / 10 / 11, 64-bit) %LOCALAPPDATA%\openMSX\share or C:\Users\<user name>\AppData\Local\openMSX\share (whereby stands for your Windows login name)
  20. MBilderbeek commented on Jul 31, 2026

    @MBilderbeek
    Member
  21. vdom-1 commented on Jul 31, 2026

    @vdom-1
    Author

    True, its just the "endgame" suggestion... Currently it just removes Documents from the path: C:\Users\<user name>\openMSX\share. Which is already better but far from ideal.

  22. MBilderbeek commented on Jul 31, 2026

    @MBilderbeek
    Member
  23. vdom-1 commented on Jul 31, 2026

    @vdom-1
    Author

    In a nutshell, ideally we need a strict separation of concerns between the System Domain (Emulator Config/Setup/Setting/Installation) and the User Domain (GUI/Console).

    Currently, both domains share the same expandTilde()/getUserHomeDir() logic, which is the root cause of the regression.

    This is how I thing we can get there:

    • Confine Tilde Expansion to the User Domain: Keep expandTilde()/getUserHomeDir() strictly for the console and GUI.

    • Isolate the System Domain: Create a dedicated function for configuration, setup, settings and installation (e.g., FileOperations::getLocalDataPath()).

      • Use OS-Native Paths: This new system function should completely bypass tilde/home string manipulation. Instead, it must query the OS directly using native APIs—specifically resolving to CSIDL_LOCAL_APPDATA on Windows—to locate user data and machine ROMs reliably.
      • It appears that FileOperations::getUserOpenMSXDir() is the only function affected by this change, but again, someone more familiar with the code should have a look at this.
  24. MBilderbeek commented on Jul 31, 2026

    @MBilderbeek
    Member
  25. vdom-1 commented on Jul 31, 2026

    @vdom-1
    Author

    This is the one million dollar question. I have being digging the code to get a better grip of how openMSX resolve its working directories. What makes it a bit confusing, but not impossible to understand, is the "portability" factor(resolves OPENMSX_SYSTEM_DATA to the executable path) and as I said before how entangled the installation and the console logic is. I think that we should push forward with this commit c7c3bc6 and update the documentation by just removing Documents\ from C:\Users\<user name>\Documents\openMSX\share whereby <user name> stands for your Windows login name for now. This is already going to force people on the right direction by moving stuff out of the Documents folder.
    For the the endgame(..\AppData\Local\openMSX\share), I am still investigating the best solution in any case let's continue this conversation in issue #1246 because it the situation quite well.

  26. m9710797 commented on Aug 1, 2026

    @m9710797
    Contributor

    I've reverted this change. Because it broke windows installations that were working fine for +20 years (using the recommended installation paths). That's unacceptable without some transition period, or backwards compatibility mechanism. We should have reverted sooner, but I was on vacation.

    I do agree that the new paths suggested by vdom-1 are better (as in: more as expected on "modern" windows applications), and we should migrate to those. But again NOT without some clear transition plan and/or backwards compatibility.

    We introduced this problem by changing how tilde-expansion behaves (on windows). I wrongly thought that tilde-expansion would only have an effect on interactive usage (command line, or openMSX console commands). But that's wrong: it seems in 1 location (getUserOpenMSXDir()) in the internal code we also use this. So as a first step I'll change that to be independent from tilde-expansion.

    Maybe after that we can re-apply the tilde-expansion change (which should then only have an effect on interactive use). I did already make the assumption that windows users rarely use tilde-expansion (in interactive commands). And that breaking backwards compatibility there would be acceptable? But maybe we should re-evaluate that now?

  27. added a commit that references this issue on Aug 1, 2026
  28. vdom-1 commented on Aug 3, 2026

    @vdom-1
    Author

    "I did already make the assumption that windows users rarely use tilde-expansion (in interactive commands)"

    Since the advent of WSL(Windows subsystem for Linux) more and more Windows users are offloading parts of their workflows to Linux. Tilde expansion in Windows is now as important as it has always being in Linux especially on these hybrid workflows where path alignment is crucial between OS's.

    "And that breaking backwards compatibility there would be acceptable? But maybe we should re-evaluate that now?"

    As you notice the reason of the regression is not in "tilde expansion" itself but the fact that the interactive console shares the same user path resolution function(getUserOpenMSXDir) with the installer.

    "But again NOT without some clear transition plan and/or backwards compatibility."

    Separation of concerns here is crucial.

    • For tilde expansion alone all we need is a dedicated tilde expansion function that is not used by the installer: SHGetKnownFolderPath/FOLDERID_Profile
    • For the installer modernization no tilde expansion is needed at all as the installer should ideally use modern Windows API: SHGetKnownFolderPath/FOLDERID_LocalAppData and the legacy SHGetSpecialFolderPathW/CSIDL_PERSONAL as a fallback.
  29. MBilderbeek commented on Aug 3, 2026

    @MBilderbeek
    Member

    How is the installer at all related to all of this? I don't think it is, at all.

  30. vdom-1 commented on Aug 3, 2026

    @vdom-1
    Author

    How is the installer at all related to all of this? I don't think it is, at all.

    I am using the term installer loosely here just to represent the expected installation folders where the default installation expects to finds systemroms and software(savestates). The culprit really is std::string getUserHomeDir(std::string_view username) being share by TCL and the rest of the application...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions