mcx
mcx copied to clipboard
Windows Output Files Directory
The default installation folder of examples on Windows 10 x86-64 is "C:\Program Files (x86)\MCXStudio\MCXSuite\mcx\example". By the windows security model, only administrators and trusted system installer are allowed to write to "C:\Program Files (x86)" and subfolders. Therefore operations of non-administrators fail, e.g. a benchmark "C:\Program Files (x86)\MCXStudio\MCXSuite\mcxcl\example\benchmark>....\bin\mcxcl.exe -A -f benchmark1.json -b 0" fails with "MCXCL ERROR(-2):can not save data to disk in unit mcx_utils.c:699"
Possible fix: There are more than one possibility for programs to store files in windows. First is %appdata%, that maps to C:\Users[USERNAME]\AppData\Roaming, second there is the user my documents folder C:\Users[USERNAME]\documents. IMHO the best folder would be the program data folder, given by %programdata%, by default "C:\ProgramData". I would move the whole MCXSUITE to C:\ProgramData\MCXSUITE and change the default path for the open command to this folder.
@m-planck, thanks for reporting this. You are meant to use two approaches to run mcx if you have chosen to install it via the installer:
- Approach 1: run simulation using mcxstudio from the Start menu.
mcxstudio
has built-in mechanisms to detect output folder - ifMCXStudio/MCXOuput/
is not writable in the user mode, it redirects user outputs toC:\Users\username\MCXOutput
see https://github.com/fangq/mcx/blob/master/mcxstudio/mcxgui.pas#L1705-L1712
- Approach 2: if you prefer to use mcx in the command line, the installer has already added mcx/mcxcl/mmc paths to the PATH environment var, and you should be able to type
mcx
directly in any writable folder to run simulations in the command window.
you won't be able to run from mcx's examples folder if you don't have write permission, so, you will have to copy those examples to a user folder and run those from there. You can also add --root /path/to/userfolder
if you want to tell mcx to look for input/output in a different folder.
I am currently working on Debian/Linux package for mcx/mcxcl/mmc, and they will also be handled similarly - you won't be able to run examples from the installed system directory, but you can if you copy those to use folder.
let me know if this addresses your concern.
@fangq Thanks for the reply. Ad 1: Well, it was not transparent for me that there is a folder under C:\Users[username]\MCXOutput, as you need to know the location. If you specify any other folder under menu settings, the string is not saved, as any other setting. This is, because "mcxstudio.json" is still in the user write protected C:\Program folder
Ad 2: The path variable is an old windows relic, it should be only changed if absolutely necessary. Entry in the path variable are evaluated for every program starting, with the priority given by the entries order. As you a put your entries in front, every system call scans the folder and after a miss moves on to the next entry, eventually arriving at the default paths C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;.It's common procedure to append path strings only.
However, one of the binaries is named mmc.exe. So this naturally clashes with mmc.exe in System32, the Microsoft Management Console. This is the central part of windows settings management and crucial for a correct functioning operating system. I assume thats why you put your path in front.
So, if the path variable is only needed for a command line, it would be better to install a shortcut in the start menu program group to start a "MCX Command Line", where you specify the environment for this terminal only:
set PATH=C:\Program Files\MCXStudio;C:\Program Files\MCXStudio\MCXSuite\mmc\bin;C:\Program Files\MCXStudio\MCXSuite\mcx\bin;C:\Program Files\MCXStudio\MCXSuite\mcxcl\bin;%PATH%
Ad 1: Well, it was not transparent for me that there is a folder under C:\Users[username]\MCXOutput, as you need to know the location. If you specify any other folder under menu settings, the string is not saved, as any other setting. This is, because "mcxstudio.json" is still in the user write protected C:\Program folder
yes, I agree, mcxstudio.json
should be saved under user folder as well. I will make the change. The Setting dialog was only added last year and did not get much polishing.
However, one of the binaries is named mmc.exe. So this naturally clashes with mmc.exe in System32, the Microsoft Management Console. This is the central part of windows settings management and crucial for a correct functioning operating system. I assume thats why you put your path in front.
yes, you are right. mmc was shadowed by windows' own mmc if I append paths. I am still trying to figure out a solution for this - because mcx/mmc also have a name conflict on Debian/Ubuntu (not on Fedora).
So, if the path variable is only needed for a command line, it would be better to install a shortcut in the start menu program group to start a "MCX Command Line", where you specify the environment for this terminal only:
I agree this is less aggressive and a clean solution. however, some users may prefer to use powershell or cygwin64 terminal, in these cases, I will have to create shortcuts for each terminal app, and that could be a bit annoying.
I haven't been testing/updating mcxstudio for a while. so, sorry for the long delay in finding a solution to this.
when I test the new release v2023, I saw the same issue you reported - I was able to solve this problem by installing mcx to C:\ProgramData folder instead of the "C:\Program Files" root folder. I tested the new installer at https://mcx.space/nightly/win64/MCXStudio-v2023-installer.exe, I believe the permission issue has gone.
let me know if this works for you.