How to make MSYS (MSYS2) portable

msys

On Windows, I have a C:\msys32 folder (containing what I believe to be a MSYS2 install) created for/by an ESP32 development environment (located in ~/esp). The MSYS home folder includes my Windows username.

Now when I copy that install to another computer, suddenly that folder changes names which I find disturbing by itself, as this isn't "my folder", it is just a name to get around a Linux requirement, it could be some fixed (canonical) name such as 'user'.

More significantly this behaviour means my install isn't portable. Whe I copy the msys32 folder to another computer everything either breaks, or doesn't make any sense. For me it would be best if that username was simply removed from the path, but I'll take second best, which is to give it a fixed name. How can I do that?

PS I understand the goal of msys is to recreate a Linux environment, but please consider that "multi-user" is a dinosaur in todays world where most people are "multi-computer".

Best Answer

I'm not quite sure what to make of "everything either breaks, or doesn't make any sense" and if I can help your with that.

Regarding the different userprofiles, home paths, usernames, and how they relate to each other. Keep in mind that every local user account on Windows is always unique anyway, you may log into two Windows machines with the same account name and same password but their SIDs are always different. This usually does not matter for you, only because the default file permmissions are set up for "Authenticated Users" and similar abstract groups.

Similarly on unix, you usually care about the contents of your home folder and file access rights, aside from that the username or underlying UID are of no great concern, it's just the name you have to provide upon login.

Unless "ESP32" did something freaky with the /etc configuration files, things should just work no matter what username is shown on the prompt, setting %HOME% via the Windows system properties is my preferred approach to specify my custom home directory, since programs like the windows build of emacs also respect this setting. If you want a fully self-contained portable solution for exactly one user, then /etc/nsswitch.conf should do the job.

Detailed Information:

PS: Msys is a cygwin derived build environment to help the Windows port of gcc and friends (collectively called mingw) build software on Windows that is in theory cross platform but mostly built on Unix and came to rely on the unix tools for building. That's it. Cygwin aims much higher than that and if you want to, for example, run a ssh server with privilege separation then cygwin de-facto stops being portable due to stuff like file permission problems and missing accounts.

Related Question