Run the bundled runtime inside WSL2 on Windows

Windows has no native ROOT + musrfit, so the same Linux runtime tree built
for the AppImage is reused inside a bundled WSL2 distribution. The renderer
detects the win32 host plus the bundled runtime and routes every bundled
tool through 'wsl.exe -d muSRFlow-runtime -- /opt/musrfit-runtime/bin/...',
translating Windows path arguments (C:\dir\file) to their /mnt/<drive>/
form so inputs and outputs stay on the Windows side. Host and Windows-native
tools (including a user-configured musrfit binaries directory) launch
directly, and the translation is inert on Linux.

The preload bridge now exposes process.platform so the host can be detected.

Add packaging/wsl2/build-wsl2.sh, which installs the runtime's distro-level
libraries, copies runtime/ to /opt/musrfit-runtime, and exports a rootfs
tarball for the one-time 'wsl --import'. Note that dump_header ships with
the musrfit package and both build recipes now verify the full tool set
(musrfit, musrt0, musrview, msr2data, dump_header).

Extend electron-bundled-runtime tests with WSL path/launch translation and
dump_header resolution; update CHANGELOG, platforms.rst, and the READMEs
(Sphinx HTML/PDF rebuilt).
This commit is contained in:
salman committed 2026-10-11 17:03:05 +02:00
1 parent 9aeaa35838
commit 2ece146e19
16 files changed
+368 -19

No files matched your search

+3
View File
@@ -55,6 +55,9 @@ package-lock.json
runtime/*
!runtime/.gitkeep
# WSL2 rootfs build output (built by packaging/wsl2)
packaging/wsl2/out/
# Generated local fit artifacts
/*_asy.msr
/*_asy.out
+7
View File
@@ -84,6 +84,13 @@ release path documented in [`TODO.md`](TODO.md).
`$ORIGIN`-relative paths, and bundles the non-system shared-library closure.
The tree is git-ignored and shipped through the `extraResources` entry in
`package.json`.
- On Windows the same Linux runtime is reused inside a bundled WSL2
distribution: the renderer runs the bundled tools through
`wsl.exe -d muSRFlow-runtime -- /opt/musrfit-runtime/bin/...` and translates
Windows path arguments to their `/mnt/<drive>/...` form, while host and
Windows-native tools (such as a user-configured **musrfit binaries**
directory) launch directly. `packaging/wsl2/build-wsl2.sh` exports the
matching rootfs tarball for the one-time `wsl --import`.
## 1.0.0-rc.4 (2026-09-23)
+6
View File
@@ -47,6 +47,12 @@ precedence, and on builds without the bundle the system installation is used
exactly as before. The runtime is built with ``packaging/runtime/build.sh``
(see ``packaging/runtime/README.md``).
On Windows the bundled runtime runs inside a WSL2 distribution that muSRFlow
ships: the tools are invoked through ``wsl.exe`` and file paths are translated
between the Windows and WSL forms, so inputs and outputs stay on the Windows
side. The rootfs is built with ``packaging/wsl2/build-wsl2.sh`` and imported
once per user (see ``packaging/wsl2/README.md``).
The workflow chapters of this manual apply to both editions. Where a step is
specific to one edition (handling files, Preferences), the text says so
explicitly.
+5
View File
@@ -146,6 +146,11 @@ tree; a directory set in <strong>Preferences / musrfit binaries</strong> still t
precedence, and on builds without the bundle the system installation is used
exactly as before. The runtime is built with <code class="docutils literal notranslate"><span class="pre">packaging/runtime/build.sh</span></code>
(see <code class="docutils literal notranslate"><span class="pre">packaging/runtime/README.md</span></code>).</p>
<p>On Windows the bundled runtime runs inside a WSL2 distribution that muSRFlow
ships: the tools are invoked through <code class="docutils literal notranslate"><span class="pre">wsl.exe</span></code> and file paths are translated
between the Windows and WSL forms, so inputs and outputs stay on the Windows
side. The rootfs is built with <code class="docutils literal notranslate"><span class="pre">packaging/wsl2/build-wsl2.sh</span></code> and imported
once per user (see <code class="docutils literal notranslate"><span class="pre">packaging/wsl2/README.md</span></code>).</p>
<p>The workflow chapters of this manual apply to both editions. Where a step is
specific to one edition (handling files, Preferences), the text says so
explicitly.</p>
+1 -1
View File
@@ -1 +1 @@
Search.setIndex({"alltitles":{"A first fit":[[7,"a-first-fit"]],"Bundled ROOT and musrfit":[[9,"bundled-root-and-musrfit"]],"Command log":[[11,"command-log"]],"Configuration sharing":[[0,null]],"Constraints":[[1,null],[1,"id1"]],"Contents":[[4,null]],"Custom parameters":[[1,"custom-parameters"]],"Desktop installation":[[2,"desktop-installation"]],"Editing trace styles":[[8,"editing-trace-styles"]],"Example: couple the magnetic field to the Larmor frequency":[[1,"example-couple-the-magnetic-field-to-the-larmor-frequency"]],"Execution details":[[11,"execution-details"]],"File handling":[[6,"file-handling"]],"Fit and Plot":[[12,"fit-and-plot"]],"Fit model":[[12,"fit-model"]],"Fit options":[[12,"fit-options"]],"Fit or plot will not start":[[14,"fit-or-plot-will-not-start"]],"Fit range":[[12,"fit-range"]],"Fitted parameters look wrong or unchanged":[[14,"fitted-parameters-look-wrong-or-unchanged"]],"General notes":[[5,"general-notes"]],"Getting started":[[2,null]],"Glossary":[[3,null]],"Keyboard shortcuts":[[5,null],[8,"keyboard-shortcuts"]],"MSR editor":[[5,"msr-editor"],[6,null]],"Multi-group asymmetry fits":[[13,"multi-group-asymmetry-fits"]],"Notes":[[0,"notes"]],"On the desktop":[[0,"on-the-desktop"]],"On the web":[[0,"on-the-web"]],"Opening the web edition":[[2,"opening-the-web-edition"]],"Outcome dialog":[[11,"outcome-dialog"]],"Overlay data sets (multiple files in one panel)":[[8,"overlay-data-sets-multiple-files-in-one-panel"]],"Overview":[[7,null]],"Ownership: GUI or editor":[[6,"ownership-gui-or-editor"]],"Parameter plot hangs on \u201cPreparing plot files\u201d":[[14,"parameter-plot-hangs-on-preparing-plot-files"]],"Parameter plot is empty or missing data":[[14,"parameter-plot-is-empty-or-missing-data"]],"Parameter selection (Parameters tab)":[[5,"parameter-selection-parameters-tab"]],"Parameter-plot window":[[5,"parameter-plot-window"]],"Parameters and parameter plots":[[8,null]],"Per-run statistics":[[12,"per-run-statistics"]],"Plot options":[[8,"plot-options"]],"Preferences":[[10,null]],"Prerequisites":[[2,"prerequisites"]],"Preview":[[1,"preview"]],"Remembered plot configurations":[[8,"remembered-plot-configurations"]],"Reporting problems":[[14,"reporting-problems"]],"Restored configuration differs from the original machine":[[14,"restored-configuration-differs-from-the-original-machine"]],"Result files":[[11,"result-files"]],"Results and diagnostics":[[11,null]],"Run log window":[[11,"run-log-window"]],"Run selection":[[12,"run-selection"]],"Running the desktop app":[[2,"running-the-desktop-app"]],"Runs and fitting":[[12,null]],"Selecting parameters for plotting":[[8,"selecting-parameters-for-plotting"]],"Series fit actions":[[12,"series-fit-actions"]],"Some links start with a different prefix":[[14,"some-links-start-with-a-different-prefix"]],"Support":[[2,"support"]],"Template and series presets":[[8,"template-and-series-presets"]],"The Choose X axis dialog":[[8,"the-choose-x-axis-dialog"]],"The Quick Start guide":[[2,"the-quick-start-guide"]],"The Shared column":[[8,"the-shared-column"]],"The parameter table":[[8,"the-parameter-table"]],"The parameter-plot window":[[8,"the-parameter-plot-window"]],"The status bar":[[11,"the-status-bar"]],"Troubleshooting":[[14,null]],"Two editions":[[7,"two-editions"]],"Under the hood":[[7,"under-the-hood"]],"View settings":[[12,"view-settings"]],"Web and desktop editions":[[9,null]],"Web page cannot load data":[[14,"web-page-cannot-load-data"]],"What is shared":[[0,"what-is-shared"]],"What you get":[[7,"what-you-get"]],"Workflow":[[6,"workflow"]],"muSRFlow User Manual":[[4,null]],"t0 / background":[[13,null]],"\u201cNothing to fit\u201d":[[14,"nothing-to-fit"]]},"docnames":["configuration-sharing","constraints","getting-started","glossary","index","keyboard-shortcuts","msr-editor","overview","parameters-plots","platforms","preferences","results-diagnostics","runs-fitting","t0-background","troubleshooting"],"envversion":{"sphinx":65,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2},"filenames":["configuration-sharing.rst","constraints.rst","getting-started.rst","glossary.rst","index.rst","keyboard-shortcuts.rst","msr-editor.rst","overview.rst","parameters-plots.rst","platforms.rst","preferences.rst","results-diagnostics.rst","runs-fitting.rst","t0-background.rst","troubleshooting.rst"],"indexentries":{"addrun":[[3,"term-ADDRUN",true]],"configuration link":[[3,"term-configuration-link",true]],"dump_header":[[3,"term-dump_header",true]],"fft":[[3,"term-FFT",true]],"fit document":[[3,"term-fit-document",true]],"global parameter":[[3,"term-global-parameter",true]],"independent-series fit":[[3,"term-independent-series-fit",true]],"msr":[[3,"term-MSR",true]],"msr2data":[[3,"term-msr2data",true]],"musrfit":[[3,"term-musrfit",true]],"musrview":[[3,"term-musrview",truLine truncated
Search.setIndex({"alltitles":{"A first fit":[[7,"a-first-fit"]],"Bundled ROOT and musrfit":[[9,"bundled-root-and-musrfit"]],"Command log":[[11,"command-log"]],"Configuration sharing":[[0,null]],"Constraints":[[1,null],[1,"id1"]],"Contents":[[4,null]],"Custom parameters":[[1,"custom-parameters"]],"Desktop installation":[[2,"desktop-installation"]],"Editing trace styles":[[8,"editing-trace-styles"]],"Example: couple the magnetic field to the Larmor frequency":[[1,"example-couple-the-magnetic-field-to-the-larmor-frequency"]],"Execution details":[[11,"execution-details"]],"File handling":[[6,"file-handling"]],"Fit and Plot":[[12,"fit-and-plot"]],"Fit model":[[12,"fit-model"]],"Fit options":[[12,"fit-options"]],"Fit or plot will not start":[[14,"fit-or-plot-will-not-start"]],"Fit range":[[12,"fit-range"]],"Fitted parameters look wrong or unchanged":[[14,"fitted-parameters-look-wrong-or-unchanged"]],"General notes":[[5,"general-notes"]],"Getting started":[[2,null]],"Glossary":[[3,null]],"Keyboard shortcuts":[[5,null],[8,"keyboard-shortcuts"]],"MSR editor":[[5,"msr-editor"],[6,null]],"Multi-group asymmetry fits":[[13,"multi-group-asymmetry-fits"]],"Notes":[[0,"notes"]],"On the desktop":[[0,"on-the-desktop"]],"On the web":[[0,"on-the-web"]],"Opening the web edition":[[2,"opening-the-web-edition"]],"Outcome dialog":[[11,"outcome-dialog"]],"Overlay data sets (multiple files in one panel)":[[8,"overlay-data-sets-multiple-files-in-one-panel"]],"Overview":[[7,null]],"Ownership: GUI or editor":[[6,"ownership-gui-or-editor"]],"Parameter plot hangs on \u201cPreparing plot files\u201d":[[14,"parameter-plot-hangs-on-preparing-plot-files"]],"Parameter plot is empty or missing data":[[14,"parameter-plot-is-empty-or-missing-data"]],"Parameter selection (Parameters tab)":[[5,"parameter-selection-parameters-tab"]],"Parameter-plot window":[[5,"parameter-plot-window"]],"Parameters and parameter plots":[[8,null]],"Per-run statistics":[[12,"per-run-statistics"]],"Plot options":[[8,"plot-options"]],"Preferences":[[10,null]],"Prerequisites":[[2,"prerequisites"]],"Preview":[[1,"preview"]],"Remembered plot configurations":[[8,"remembered-plot-configurations"]],"Reporting problems":[[14,"reporting-problems"]],"Restored configuration differs from the original machine":[[14,"restored-configuration-differs-from-the-original-machine"]],"Result files":[[11,"result-files"]],"Results and diagnostics":[[11,null]],"Run log window":[[11,"run-log-window"]],"Run selection":[[12,"run-selection"]],"Running the desktop app":[[2,"running-the-desktop-app"]],"Runs and fitting":[[12,null]],"Selecting parameters for plotting":[[8,"selecting-parameters-for-plotting"]],"Series fit actions":[[12,"series-fit-actions"]],"Some links start with a different prefix":[[14,"some-links-start-with-a-different-prefix"]],"Support":[[2,"support"]],"Template and series presets":[[8,"template-and-series-presets"]],"The Choose X axis dialog":[[8,"the-choose-x-axis-dialog"]],"The Quick Start guide":[[2,"the-quick-start-guide"]],"The Shared column":[[8,"the-shared-column"]],"The parameter table":[[8,"the-parameter-table"]],"The parameter-plot window":[[8,"the-parameter-plot-window"]],"The status bar":[[11,"the-status-bar"]],"Troubleshooting":[[14,null]],"Two editions":[[7,"two-editions"]],"Under the hood":[[7,"under-the-hood"]],"View settings":[[12,"view-settings"]],"Web and desktop editions":[[9,null]],"Web page cannot load data":[[14,"web-page-cannot-load-data"]],"What is shared":[[0,"what-is-shared"]],"What you get":[[7,"what-you-get"]],"Workflow":[[6,"workflow"]],"muSRFlow User Manual":[[4,null]],"t0 / background":[[13,null]],"\u201cNothing to fit\u201d":[[14,"nothing-to-fit"]]},"docnames":["configuration-sharing","constraints","getting-started","glossary","index","keyboard-shortcuts","msr-editor","overview","parameters-plots","platforms","preferences","results-diagnostics","runs-fitting","t0-background","troubleshooting"],"envversion":{"sphinx":65,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2},"filenames":["configuration-sharing.rst","constraints.rst","getting-started.rst","glossary.rst","index.rst","keyboard-shortcuts.rst","msr-editor.rst","overview.rst","parameters-plots.rst","platforms.rst","preferences.rst","results-diagnostics.rst","runs-fitting.rst","t0-background.rst","troubleshooting.rst"],"indexentries":{"addrun":[[3,"term-ADDRUN",true]],"configuration link":[[3,"term-configuration-link",true]],"dump_header":[[3,"term-dump_header",true]],"fft":[[3,"term-FFT",true]],"fit document":[[3,"term-fit-document",true]],"global parameter":[[3,"term-global-parameter",true]],"independent-series fit":[[3,"term-independent-series-fit",true]],"msr":[[3,"term-MSR",true]],"msr2data":[[3,"term-msr2data",true]],"musrfit":[[3,"term-musrfit",true]],"musrview":[[3,"term-musrview",truLine truncated
+9 -9
View File
@@ -1,11 +1,11 @@
# Fdb version 4
["makeindex muSRFlow.idx"] 1791621490.17959 "muSRFlow.idx" "muSRFlow.ind" "muSRFlow" 1791730106.16275 0
"muSRFlow.idx" 1791730106.04479 1189 cca9fe93ffba026d593c5ed228d742a4 "pdflatex"
["makeindex muSRFlow.idx"] 1791621490.17959 "muSRFlow.idx" "muSRFlow.ind" "muSRFlow" 1791730964.04474 0
"muSRFlow.idx" 1791730963.91562 1189 cca9fe93ffba026d593c5ed228d742a4 "pdflatex"
(generated)
"muSRFlow.ilg"
"muSRFlow.ind"
(rewritten before read)
["pdflatex"] 1791730103.78886 "muSRFlow.tex" "muSRFlow.pdf" "muSRFlow" 1791730106.16288 0
["pdflatex"] 1791730961.5942 "muSRFlow.tex" "muSRFlow.pdf" "muSRFlow" 1791730964.04489 0
"/usr/share/texmf-dist/fonts/map/fontname/texfonts.map" 1577235249 3524 cb3e574dea2d1052e39280babc910dc8 ""
"/usr/share/texmf-dist/fonts/tfm/adobe/zapfding/pzdr.tfm" 1136768653 1528 f853c4d1b4e0550255e02831fdc8496f ""
"/usr/share/texmf-dist/fonts/tfm/public/amsfonts/cmextra/cmex7.tfm" 1246382020 1004 54797486969f23fa377b128694d548df ""
@@ -119,13 +119,13 @@
"/usr/share/texmf-dist/tex/latex/xcolor/xcolor.sty" 1727642399 55384 b454dec21c2d9f45ec0b793f0995b992 ""
"/usr/share/texmf-dist/web2c/texmf.cnf" 1772498184 43617 0f84662189cad3132fecd51f17dd9276 ""
"/var/lib/texmf/web2c/xetex/xelatex.fmt" 1783332064 6760887 1c6d1ad838ac2a3dddf7a0433c780710 ""
"muSRFlow.aux" 1791730106.04279 24322 9176e2a8d1447fe1bc48c56f4059a194 "pdflatex"
"muSRFlow.aux" 1791730963.91362 24322 9176e2a8d1447fe1bc48c56f4059a194 "pdflatex"
"muSRFlow.ind" 1791621490.25033 1435 1ea9e98c4c43945295d6873d01cf2032 "makeindex muSRFlow.idx"
"muSRFlow.out" 1791730106.04479 11879 c29038db42596b165f0732dea8edf516 "pdflatex"
"muSRFlow.tex" 1791730092.72346 82633 31a973eb060f51d752bbd1915b2056e9 ""
"muSRFlow.toc" 1791730106.04479 6233 a8f6b0c136864b1af14f888e6e6bff3e "pdflatex"
"muSRFlow.out" 1791730963.91562 11879 c29038db42596b165f0732dea8edf516 "pdflatex"
"muSRFlow.tex" 1791730954.26937 83101 d0ee1391468e6d7db61b50f4fb6e409e ""
"muSRFlow.toc" 1791730963.91562 6233 a8f6b0c136864b1af14f888e6e6bff3e "pdflatex"
"sphinx.sty" 1789374174.58095 54203 ee7fe875437470f5328ee20661bb9f1d ""
"sphinxhighlight.sty" 1791730092.60905 7553 83fb52292c17957d9f4aadcb28c57a87 ""
"sphinxhighlight.sty" 1791730954.16922 7553 83fb52292c17957d9f4aadcb28c57a87 ""
"sphinxlatexadmonitions.sty" 1789374174.58095 19111 5e67a0f91439018bceb7cadf319345e6 ""
"sphinxlatexcontainers.sty" 1789374174.58295 900 d61f923db071a7b54d3cee8a1e6935d3 ""
"sphinxlatexgraphics.sty" 1789374174.58295 4918 c9266041d02bc615d54b890e96e3acd3 ""
@@ -140,7 +140,7 @@
"sphinxlatexstyletext.sty" 1789374174.58495 6759 9e932c65374cfb62686485d331bc975c ""
"sphinxlatextables.sty" 1789374174.58495 57643 7f1013c2fa11942370d867527bdda568 ""
"sphinxmanual.cls" 1789374174.58495 4241 7b0d7a37df7b5715fb0dbd585c52ecdb ""
"sphinxmessages.sty" 1791730092.72877 745 3f5fcd6cdd7964ed608767954a8ced6f ""
"sphinxmessages.sty" 1791730954.27339 745 3f5fcd6cdd7964ed608767954a8ced6f ""
"sphinxoptionsgeometry.sty" 1789374174.58695 2060 6c27b3eba37bde592ae8908ab2c1ac0f ""
"sphinxoptionshyperref.sty" 1789374174.58695 1093 e468489bae7631a7f387b4b0f7bc15d4 ""
"sphinxpackageboxes.sty" 1789374174.58695 36106 1be2053eb1cb9b083b3a75e3657bcb24 ""
BIN
View File
Binary file not shown.
+7
View File
@@ -1775,6 +1775,13 @@ precedence, and on builds without the bundle the system installation is used
exactly as before. The runtime is built with \sphinxcode{\sphinxupquote{packaging/runtime/build.sh}}
(see \sphinxcode{\sphinxupquote{packaging/runtime/README.md}}).
\sphinxAtStartPar
On Windows the bundled runtime runs inside a WSL2 distribution that muSRFlow
ships: the tools are invoked through \sphinxcode{\sphinxupquote{wsl.exe}} and file paths are translated
between the Windows and WSL forms, so inputs and outputs stay on the Windows
side. The rootfs is built with \sphinxcode{\sphinxupquote{packaging/wsl2/build\sphinxhyphen{}wsl2.sh}} and imported
once per user (see \sphinxcode{\sphinxupquote{packaging/wsl2/README.md}}).
\sphinxAtStartPar
The workflow chapters of this manual apply to both editions. Where a step is
specific to one edition (handling files, Preferences), the text says so
+6
View File
@@ -47,6 +47,12 @@ precedence, and on builds without the bundle the system installation is used
exactly as before. The runtime is built with ``packaging/runtime/build.sh``
(see ``packaging/runtime/README.md``).
On Windows the bundled runtime runs inside a WSL2 distribution that muSRFlow
ships: the tools are invoked through ``wsl.exe`` and file paths are translated
between the Windows and WSL forms, so inputs and outputs stay on the Windows
side. The rootfs is built with ``packaging/wsl2/build-wsl2.sh`` and imported
once per user (see ``packaging/wsl2/README.md``).
The workflow chapters of this manual apply to both editions. Where a step is
specific to one edition (handling files, Preferences), the text says so
explicitly.
+70 -7
View File
@@ -754,7 +754,8 @@ function loadRunHeaderText(filePath, fileFormat) {
let env = buildToolEnvironment();
let args = ["-fn", filePath];
if (fileFormat) args.push("-ff", fileFormat);
let result = nodeChildProcess.spawnSync(dumpHeader, args, {
let launch = prepareLocalLaunch(dumpHeader, args);
let result = nodeChildProcess.spawnSync(launch.command, launch.args, {
env: env,
encoding: "utf8",
shell: false
@@ -893,6 +894,7 @@ function cancelElectronPreferences() {
// msr2data template generation. Long-running fit/view execution uses spawn()
// below so the Electron renderer is not blocked.
function executeCapture(command, cwd = undefined, envOverrides = {}) {
command = prepareWslCommandString(command);
try {
const stdout = nodeChildProcess.execSync(command, {
cwd: cwd,
@@ -1062,6 +1064,64 @@ function buildToolEnvironment() {
return env;
}
// --- Windows / WSL2 execution -------------------------------------------
// A packaged Windows build has no native ROOT + musrfit. Instead the same Linux
// runtime tree is imported into a bundled WSL2 distribution and the bundled
// tools run through wsl.exe. Host utilities (and a user-configured Windows tool
// directory) still launch directly.
var MUSRFLOW_WSL_DISTRO = "muSRFlow-runtime";
var MUSRFLOW_WSL_PREFIX = "/opt/musrfit-runtime";
function isWslRuntimeHost() {
return nodeProcess && nodeProcess.platform === "win32" && bundledRuntimeRoot() !== "";
}
// Translate an absolute Windows path (C:\dir\file or C:/dir/file) to the path
// its WSL mount exposes. Non-path arguments (flags, run lists) pass through.
function windowsPathToWsl(input) {
if (typeof input !== "string" || input === "") return input;
let match = /^([A-Za-z]):[\\/](.*)$/.exec(input);
if (!match) return input;
return "/mnt/" + match[1].toLowerCase() + "/" + match[2].replace(/\\/g, "/");
}
// Wrap a bundled Linux tool as a wsl.exe invocation, translating path
// arguments. Commands outside the runtime bin directory are unchanged so host
// tools and Windows-native binaries keep working.
function prepareLocalLaunch(command, args) {
args = args || [];
if (!isWslRuntimeHost()) return { command: command, args: args, viaWsl: false };
let binDir = bundledRuntimeBinDir();
if (!binDir || command.indexOf(binDir) !== 0) {
return { command: command, args: args, viaWsl: false };
}
let relative = command.slice(binDir.length).replace(/^[\\/]+/, "").replace(/\\/g, "/");
let inner = MUSRFLOW_WSL_PREFIX + "/bin/" + relative;
let wslArgs = ["-d", MUSRFLOW_WSL_DISTRO, "--", inner]
.concat(args.map(windowsPathToWsl));
return { command: "wsl.exe", args: wslArgs, viaWsl: true };
}
// Same translation for the one shell-string capture path (msr2data template
// generation), which builds a command such as
// "<binDir>/msr2data \"[1 2]\" _tmpl msr-1 global". Only the leading bundled
// executable is rewritten and Windows paths inside the quoted arguments are
// converted so msr2data sees /mnt/... paths.
function prepareWslCommandString(command) {
if (!isWslRuntimeHost() || typeof command !== "string") return command;
let binDir = bundledRuntimeBinDir();
if (!binDir || command.indexOf(binDir) !== 0) return command;
let remainder = command.slice(binDir.length).replace(/^[\\/]+/, "");
let spaceIndex = remainder.search(/\s/);
let exe = spaceIndex === -1 ? remainder : remainder.slice(0, spaceIndex);
let rest = spaceIndex === -1 ? "" : remainder.slice(spaceIndex);
rest = rest.replace(/[A-Za-z]:[\\/][^\s"']*/g, function(match) {
return windowsPathToWsl(match);
});
return "wsl.exe -d " + MUSRFLOW_WSL_DISTRO + " -- "
+ MUSRFLOW_WSL_PREFIX + "/bin/" + exe + rest;
}
function resolveLocalCommand(commandName) {
let candidates = [];
let configuredBinDir = typeof getConfiguredBinDir === "function"
@@ -1146,7 +1206,8 @@ function appendProcessOutput(label, chunk, logFile) {
// Promise-based rather than callback-only so runMSRFileLocal() can express the
// required sequence clearly and lets both executables share output classification.
function runLocalProcess(label, command, args, cwd, logFile, options = {}) {
let commandLine = displayCommand(command, args);
let launch = prepareLocalLaunch(command, args);
let commandLine = displayCommand(launch.command, launch.args);
let reportStatus = options.reportStatus !== false;
if (reportStatus && typeof updateJobStatus === "function") {
updateJobStatus({
@@ -1179,7 +1240,7 @@ function runLocalProcess(label, command, args, cwd, logFile, options = {}) {
electronRunJobLogFile = logFile;
electronRunJobAborted = false;
}
return nodeChildProcess.spawnCapture(command, args, {
return nodeChildProcess.spawnCapture(launch.command, launch.args, {
cwd: cwd,
env: env,
jobToken: jobToken
@@ -1492,12 +1553,13 @@ async function collectIndependentSeriesArtifactsLocal(spec) {
let msr2data = resolveLocalCommand("msr2data");
let env = buildToolEnvironment();
let runMsr2data = function(label, args) {
let commandLine = displayCommand(msr2data, args);
let launch = prepareLocalLaunch(msr2data, args);
let commandLine = displayCommand(launch.command, launch.args);
appendFitLog(logPath, "\n$ " + commandLine + "\n");
if (typeof appendJobLog === "function") {
appendJobLog("Starting independent series " + label + ": " + commandLine);
}
let commandResult = nodeChildProcess.spawnSync(msr2data, args, {
let commandResult = nodeChildProcess.spawnSync(launch.command, launch.args, {
cwd: workPath,
env: env,
encoding: "utf8",
@@ -1618,14 +1680,15 @@ function exportLocalMusrfitParameterData(resolvedPath, options, logFile) {
nodeFs.rmSync(parameterPath, { force: true });
nodeFs.writeFileSync(sourcePath, nodeFs.readFileSync(resolvedPath, "utf8"), "utf8");
let commandLine = displayCommand(msr2data, args);
let launch = prepareLocalLaunch(msr2data, args);
let commandLine = displayCommand(launch.command, launch.args);
appendFitLog(logFile, "\n$ " + commandLine + "\n");
if (typeof appendJobLog === "function") {
appendJobLog("Starting msr2data parameter export: " + commandLine);
}
let env = buildToolEnvironment();
let result = nodeChildProcess.spawnSync(msr2data, args, {
let result = nodeChildProcess.spawnSync(launch.command, launch.args, {
cwd: fitDir,
env: env,
encoding: "utf8",
+1 -1
View File
@@ -11,7 +11,7 @@ The runtime is a single install prefix that doubles as `ROOTSYS`:
```
runtime/
bin/ # root-config, musrfit, musrt0, musrview, msr2data, ...
bin/ # root-config, musrfit, musrt0, musrview, msr2data, dump_header, ...
lib/ # libCore.so…, libPMusr.so…, bundled third-party .so
include/
etc/ # ROOT/system config
+17
View File
@@ -119,6 +119,23 @@ bundle_deps() {
}
bundle_deps
log "Verifying required tools"
# dump_header is part of the musrfit package (installed alongside musrfit) and
# is used by muSRFlow to read run headers; make sure every tool muSRFlow
# resolves from the bundle is actually present.
missing=0
for tool in musrfit musrt0 musrview msr2data dump_header; do
if [ -x "$PREFIX/bin/$tool" ]; then
echo " ok $tool"
else
echo " MISSING $tool" >&2
missing=1
fi
done
if [ "$missing" -ne 0 ]; then
echo "WARNING: some tools muSRFlow needs are missing from $PREFIX/bin" >&2
fi
log "Result"
du -sh "$PREFIX"
ls "$PREFIX/bin" | head -40
+73
View File
@@ -0,0 +1,73 @@
# Windows (WSL2) runtime
Windows has no native ROOT + musrfit; the Linux tools cannot be run directly.
Instead muSRFlow reuses the **same Linux runtime tree** built for the AppImage
and runs it inside a bundled WSL2 distribution.
## How it works
`muSRFitelec.js` detects the Windows host and the bundled runtime
(`process.platform === "win32"` and `<resources>/runtime/bin/musrfit` present)
and routes every bundled tool through `wsl.exe`:
```
wsl.exe -d muSRFlow-runtime -- /opt/musrfit-runtime/bin/musrfit <args...>
```
Path arguments (`C:\dir\file`) are translated to their WSL mount form
(`/mnt/c/dir/file`) so the tools read and write the user's Windows files. Input
and output files therefore stay on the Windows side; musrfit writes into the
working directory, which WSL maps back through `/mnt/<drive>`.
A user-configured **musrfit binaries** directory with Windows-native
executables is launched directly, and on non-Windows hosts the translation is
inert, so the Linux AppImage and development checkouts are unaffected.
Constants (in `muSRFitelec.js`): the distribution name `muSRFlow-runtime` and
the in-distro prefix `/opt/musrfit-runtime`.
## Building the rootfs
Requires Docker or Podman and a built Linux runtime.
```sh
packaging/wsl2/build-wsl2.sh
```
This installs the distro-level libraries the runtime needs (GSL, FFTW, libxml2,
Boost, OpenSSL, X11/GL, FreeType, Fontconfig, ...), copies `runtime/` to
`/opt/musrfit-runtime`, writes `/etc/wsl.conf`, and exports the container
filesystem to `packaging/wsl2/out/muSRFlow-runtime-rootfs.tar.gz`.
## Importing on Windows
One-time, per user (PowerShell):
```powershell
wsl --import muSRFlow-runtime "$env:LOCALAPPDATA\muSRFlow\runtime" muSRFlow-runtime-rootfs.tar.gz
```
Verify:
```powershell
wsl -d muSRFlow-runtime -- /opt/musrfit-runtime/bin/musrt0 --version
```
WSLg (Windows 11, or a recent Windows 10) supplies the X server that `musrview`
needs for the spectra window.
## Packaging
Ship the rootfs tarball alongside the Windows build (for example as an
electron-builder `extraResources` entry or a separate download), then arrange
the one-time `wsl --import`. Automating the import/upgrade from the app
(`main.js`) is a follow-up.
## Open items
- The rootfs is built from `manylinux_2_28` (AlmaLinux 8). Adjust `BASE_IMAGE`
if the runtime is rebuilt against a different baseline.
- Import is currently a documented manual step; wiring it into the app's first
run (detect, import, surface failures) is not yet implemented.
- `wsl.exe` availability is assumed; older Windows builds without WSL2 must
install it (`wsl --install`) first.
+103
View File
@@ -0,0 +1,103 @@
#!/usr/bin/env bash
# Copyright (C) 2026 Zaher Salman
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Build a WSL2 rootfs tarball that carries the bundled ROOT + musrfit runtime
# for the Windows edition of muSRFlow. The renderer runs the bundled Linux
# tools through wsl.exe (see muSRFitelec.js::prepareLocalLaunch), so the same
# runtime tree used by the Linux AppImage is installed at
# /opt/musrfit-runtime inside the distribution.
#
# Requires Docker or Podman and a built runtime (packaging/runtime/build.sh,
# invoked automatically when runtime/bin/musrfit is missing).
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO="$(cd "$HERE/../.." && pwd)"
RUNTIME_DIR="$REPO/runtime"
OUT_DIR="$HERE/out"
BASE_IMAGE="${BASE_IMAGE:-quay.io/pypa/manylinux_2_28_x86_64}"
DISTRO_NAME="${DISTRO_NAME:-muSRFlow-runtime}"
PREFIX="${PREFIX:-/opt/musrfit-runtime}"
OUTPUT="${OUTPUT:-$OUT_DIR/muSRFlow-runtime-rootfs.tar.gz}"
if command -v docker >/dev/null 2>&1; then
ENGINE=docker
elif command -v podman >/dev/null 2>&1; then
ENGINE=podman
else
echo "ERROR: docker or podman is required" >&2
exit 1
fi
if [ ! -x "$RUNTIME_DIR/bin/musrfit" ]; then
echo "runtime/ not built yet; running packaging/runtime/build.sh"
"$REPO/packaging/runtime/build.sh"
fi
mkdir -p "$OUT_DIR"
CONTAINER="musrflow-wsl2-build"
"$ENGINE" rm -f "$CONTAINER" >/dev/null 2>&1 || true
trap '"$ENGINE" rm -f "$CONTAINER" >/dev/null 2>&1 || true' EXIT
echo "Staging WSL2 rootfs in $BASE_IMAGE"
"$ENGINE" run --name "$CONTAINER" \
-v "$RUNTIME_DIR:/tmp/runtime:ro" \
-e "PREFIX=$PREFIX" \
-e "DISTRO_NAME=$DISTRO_NAME" \
"$BASE_IMAGE" \
bash -c '
set -euo pipefail
# The runtime binaries need the same distro-level libraries the Linux
# build links against; install them here so the WSL distribution is
# self-contained.
dnf -y install \
gsl fftw libxml2 boost openssl-libs \
mesa-libGL mesa-libGLU \
libX11 libXext libXft libXpm libXcursor libXrandr libXi \
freetype fontconfig libpng libjpeg-turbo libtiff \
zlib xz-libs pcre2 \
bash coreutils which \
>/dev/null
dnf clean all >/dev/null
mkdir -p "$(dirname "$PREFIX")"
cp -a /tmp/runtime "$PREFIX"
# WSL defaults: no systemd in these tarballs, run as root, and keep the
# Windows PATH interop so wsl.exe can be launched with translated paths.
printf "[user]\ndefault=root\n[interop]\nappendWindowsPath=true\n" > /etc/wsl.conf
printf "muSRFlow bundled ROOT + musrfit runtime\n" > /opt/musrfit-runtime/README.txt
# Every tool muSRFlow resolves from the bundle, including dump_header,
# must be present for the Windows edition to work.
for tool in musrfit musrt0 musrview msr2data dump_header; do
if [ -x "$PREFIX/bin/$tool" ]; then
echo " ok $tool"
else
echo " MISSING $tool" >&2
fi
done
"$PREFIX/bin/musrt0" --version >/dev/null 2>&1 \
&& echo "runtime self-check OK" \
|| echo "WARNING: runtime self-check failed"
'
echo "Exporting rootfs to $OUTPUT"
"$ENGINE" export "$CONTAINER" | gzip -c > "$OUTPUT"
cat <<EOF
Done: $OUTPUT
Import once on Windows (per user):
wsl --import $DISTRO_NAME %LOCALAPPDATA%\\muSRFlow\\runtime "$(basename "$OUTPUT")"
Then muSRFlow launches bundled tools as:
wsl.exe -d $DISTRO_NAME -- $PREFIX/bin/musrfit ...
WSLg (Windows 11 / recent Windows 10) provides the X server musrview needs.
EOF
+1
View File
@@ -171,6 +171,7 @@ readFile: function (p, encoding, callback) {
process: {
cwd: function () { return process.cwd(); },
platform: process.platform,
resourcesPath: process.resourcesPath || "",
plotlyURL: pathToFileURL(BUNDLED_PLOTLY_PATH).href,
env: Object.assign({}, process.env)
+59 -1
View File
@@ -25,6 +25,7 @@ fs.mkdirSync(path.join(runtimeRoot, "bin"), { recursive: true });
fs.mkdirSync(path.join(runtimeRoot, "lib"), { recursive: true });
fs.writeFileSync(path.join(runtimeRoot, "bin", "musrfit"), "#!/bin/sh\n");
fs.writeFileSync(path.join(runtimeRoot, "bin", "musrt0"), "#!/bin/sh\n");
fs.writeFileSync(path.join(runtimeRoot, "bin", "dump_header"), "#!/bin/sh\n");
fs.writeFileSync(path.join(runtimeRoot, "lib", "libPMusr.so"), "");
fs.writeFileSync(path.join(runtimeRoot, "musrfit_startup.xml"),
"<musrfit>\n<data_path>" + emptyCwd + "</data_path>\n</musrfit>\n");
@@ -40,12 +41,13 @@ function localStoreFactory() {
};
}
function buildSandbox(resourcesPath, envOverrides) {
function buildSandbox(resourcesPath, envOverrides, platform) {
const sandbox = {
console: { log: function() {}, error: console.error, warn: console.warn },
document: { getElementById: function() { return null; } },
process: {
cwd: function() { return emptyCwd; },
platform: platform || "linux",
env: Object.assign({ HOME: emptyHome }, envOverrides || {}),
resourcesPath: resourcesPath
},
@@ -86,6 +88,11 @@ const resourcesPath = path.join(testRoot, "resources");
assert.strictEqual(
sandbox.resolveLocalCommand("musrt0"),
path.join(runtimeRoot, "bin", "musrt0"));
// dump_header ships with the musrfit package and must come from the bundle
// too, since the host may have no musrfit installation at all.
assert.strictEqual(
sandbox.resolveLocalCommand("dump_header"),
path.join(runtimeRoot, "bin", "dump_header"));
assert.strictEqual(
sandbox.localCommandPathBias().indexOf(path.join(runtimeRoot, "bin") + ":") === 0,
true);
@@ -146,4 +153,55 @@ const resourcesPath = path.join(testRoot, "resources");
path.join(runtimeRoot, "musrfit_startup.xml"));
})();
// Windows: the bundled Linux tools run through wsl.exe, with Windows path
// arguments translated to their /mnt/<drive>/... form. Host and
// Windows-native commands are left untouched.
(function testWslLaunchTranslationOnWindows() {
const sandbox = buildSandbox(resourcesPath, {}, "win32");
loadLibraries(sandbox);
assert.strictEqual(sandbox.isWslRuntimeHost(), true);
assert.strictEqual(sandbox.windowsPathToWsl("C:\\data\\run.msr"), "/mnt/c/data/run.msr");
assert.strictEqual(sandbox.windowsPathToWsl("D:/work/x"), "/mnt/d/work/x");
assert.strictEqual(sandbox.windowsPathToWsl("/already/posix"), "/already/posix");
assert.strictEqual(sandbox.windowsPathToWsl("-g"), "-g");
const bundleTool = path.join(runtimeRoot, "bin", "musrt0");
const launch = sandbox.prepareLocalLaunch(bundleTool, ["-g", "C:\\work\\job.msr"]);
assert.strictEqual(launch.command, "wsl.exe");
assert.strictEqual(launch.viaWsl, true);
assert.deepStrictEqual(Array.from(launch.args), [
"-d", "muSRFlow-runtime", "--",
"/opt/musrfit-runtime/bin/musrt0",
"-g", "/mnt/c/work/job.msr"
]);
// A Windows-native tool (user-configured directory) is launched directly.
const nativeLaunch = sandbox.prepareLocalLaunch("C:\\tools\\musrfit.exe", ["-u", "4"]);
assert.strictEqual(nativeLaunch.command, "C:\\tools\\musrfit.exe");
assert.strictEqual(nativeLaunch.viaWsl, false);
assert.deepStrictEqual(Array.from(nativeLaunch.args), ["-u", "4"]);
// The msr2data shell-string path is rewritten too.
const commandString = bundleTool + " \"[1 2 3]\" _tmpl msr-1 global";
assert.strictEqual(
sandbox.prepareWslCommandString(commandString),
"wsl.exe -d muSRFlow-runtime -- /opt/musrfit-runtime/bin/musrt0 \"[1 2 3]\" _tmpl msr-1 global");
assert.strictEqual(
sandbox.prepareWslCommandString("C:\\tools\\msr2data.exe x"),
"C:\\tools\\msr2data.exe x");
})();
// On a Linux host the WSL translation is inert even when the bundle is present.
(function testWslTranslationInertOnLinux() {
const sandbox = buildSandbox(resourcesPath, {}, "linux");
loadLibraries(sandbox);
assert.strictEqual(sandbox.isWslRuntimeHost(), false);
const bundleTool = path.join(runtimeRoot, "bin", "musrfit");
const launch = sandbox.prepareLocalLaunch(bundleTool, ["-u", "2"]);
assert.strictEqual(launch.command, bundleTool);
assert.strictEqual(launch.viaWsl, false);
})();
console.log("Bundled runtime resolution tests passed");