Fix WSL runtime library paths and plotting dependencies
Pass ROOTSYS, MUSRFITPATH, LD_LIBRARY_PATH and the Linux executable path inside WSL for direct and shell-based launches. Preserve Windows-native tool environments and downloaded-data paths. Include boost-devel in the WSL runtime and verify ROOT can parse the plotting header during packaging. Document the non-destructive dependency update for already imported runtimes. Validated the Electron suite, all five bundled executables, shell-based msr2data, a real fit, and PNG generation inside the bundled filesystem.
This commit is contained in:
1 parent
f248cb515b
commit
a6981c494d
6 files changed
+81
-20
No files matched your search
@@ -86,6 +86,13 @@ release path documented in [`TODO.md`](TODO.md).
|
||||
selection and actual RUN/ADDRUN entries in the MSR.
|
||||
|
||||
### Bundled ROOT + musrfit runtime
|
||||
- The WSL runtime now includes Boost headers required by ROOT when loading
|
||||
musrview plotting classes. Packaging checks ROOT header loading as well as
|
||||
executable versions; existing imported runtimes can add `boost-devel` without
|
||||
replacing their distribution.
|
||||
- Windows bundled commands now set ROOT and musrfit paths inside WSL, fixing
|
||||
missing `libCore.so` at startup. Both direct Fit/Plot launches and shell-based
|
||||
msr2data calls use the same Linux environment, including the data search paths.
|
||||
- Windows Fit/Plot preserves the host executable search path, including the
|
||||
usual mixed-case `Path` key and semicolon separators. This fixes
|
||||
`spawn wsl.exe ENOENT` after successful runtime setup. Linux runtime paths
|
||||
|
||||
+19
-7
@@ -1360,7 +1360,8 @@ function activeRuntimeRoot() {
|
||||
function buildToolEnvironment() {
|
||||
let env = Object.assign({}, nodeProcess.env);
|
||||
let root = activeRuntimeRoot();
|
||||
if (root !== "") {
|
||||
// Windows runtime paths are supplied inside WSL by prepareLocalLaunch.
|
||||
if (root !== "" && nodeProcess.platform !== "win32") {
|
||||
let libDir = nodePath.join(root, "lib");
|
||||
env.ROOTSYS = root;
|
||||
env.MUSRFITPATH = root;
|
||||
@@ -1516,9 +1517,16 @@ function prepareLocalLaunch(command, args) {
|
||||
}
|
||||
let relative = command.slice(binDir.length).replace(/^[\\/]+/, "").replace(/\\/g, "/");
|
||||
let inner = MUSRFLOW_WSL_PREFIX + "/bin/" + relative;
|
||||
let wslArgs = ["-d", MUSRFLOW_WSL_DISTRO, "--"];
|
||||
// Windows process.env is not the Linux tool environment. Set the runtime
|
||||
// paths after `wsl -- env` so every bundled executable finds ROOT inside
|
||||
// the imported distribution, without relying on shell startup files.
|
||||
let wslArgs = ["-d", MUSRFLOW_WSL_DISTRO, "--", "env",
|
||||
"ROOTSYS=" + MUSRFLOW_WSL_PREFIX,
|
||||
"MUSRFITPATH=" + MUSRFLOW_WSL_PREFIX,
|
||||
"LD_LIBRARY_PATH=" + MUSRFLOW_WSL_PREFIX + "/lib",
|
||||
"PATH=" + MUSRFLOW_WSL_PREFIX + "/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"];
|
||||
let dataSearchPath = localRunDataSearchPath(true);
|
||||
if (dataSearchPath) wslArgs.push('env', 'MUSRFULLDATAPATH=' + dataSearchPath);
|
||||
if (dataSearchPath) wslArgs.push('MUSRFULLDATAPATH=' + dataSearchPath);
|
||||
wslArgs.push(inner);
|
||||
wslArgs = wslArgs
|
||||
.concat(args.map(windowsPathToWsl));
|
||||
@@ -1541,10 +1549,14 @@ function prepareWslCommandString(command) {
|
||||
rest = rest.replace(/[A-Za-z]:[\\/][^\s"']*/g, function(match) {
|
||||
return windowsPathToWsl(match);
|
||||
});
|
||||
let dataSearchPath = localRunDataSearchPath(true);
|
||||
let environment = dataSearchPath ? 'env "MUSRFULLDATAPATH=' + dataSearchPath.replace(/"/g, '\\"') + '" ' : '';
|
||||
return "wsl.exe -d " + MUSRFLOW_WSL_DISTRO + " -- " + environment
|
||||
+ MUSRFLOW_WSL_PREFIX + "/bin/" + exe + rest;
|
||||
// Reuse the argv launcher so msr2data's shell capture receives exactly the
|
||||
// same runtime and data paths as Fit/Plot. Double quotes work in cmd.exe
|
||||
// and keep a downloaded-data path with spaces together as one argument.
|
||||
let launch = prepareLocalLaunch(nodePath.join(binDir, exe), []);
|
||||
let launchArguments = launch.args.map(function(argument) {
|
||||
return '"' + argument.replace(/"/g, '\\"') + '"';
|
||||
}).join(" ");
|
||||
return launch.command + " " + launchArguments + rest;
|
||||
}
|
||||
|
||||
function resolveLocalCommand(commandName) {
|
||||
|
||||
@@ -16,9 +16,14 @@ building and debugging the runtime.
|
||||
and routes every bundled tool through `wsl.exe`:
|
||||
|
||||
```
|
||||
wsl.exe -d muSRFlow-runtime -- /opt/musrfit-runtime/bin/musrfit <args...>
|
||||
wsl.exe -d muSRFlow-runtime -- env ROOTSYS=/opt/musrfit-runtime MUSRFITPATH=/opt/musrfit-runtime LD_LIBRARY_PATH=/opt/musrfit-runtime/lib PATH=/opt/musrfit-runtime/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin /opt/musrfit-runtime/bin/musrfit <args...>
|
||||
```
|
||||
|
||||
ROOT and library paths are supplied explicitly inside WSL: setting them in the
|
||||
Windows host environment does not configure the Linux loader. The launcher also
|
||||
passes the selected data search roots as `MUSRFULLDATAPATH`. This applies to
|
||||
both direct tool launches and shell-based msr2data calls.
|
||||
|
||||
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
|
||||
@@ -40,7 +45,7 @@ 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
|
||||
Boost including its headers, 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`.
|
||||
|
||||
@@ -67,13 +72,31 @@ wsl --import muSRFlow-runtime "$env:LOCALAPPDATA\muSRFlow\muSRFlow-runtime" muSR
|
||||
Verify:
|
||||
|
||||
```powershell
|
||||
wsl -d muSRFlow-runtime -- /opt/musrfit-runtime/bin/musrt0 --version
|
||||
wsl -d muSRFlow-runtime -- env ROOTSYS=/opt/musrfit-runtime MUSRFITPATH=/opt/musrfit-runtime LD_LIBRARY_PATH=/opt/musrfit-runtime/lib /opt/musrfit-runtime/bin/musrt0 --version
|
||||
```
|
||||
|
||||
WSLg supplies the X server that `musrview` needs for the spectra window.
|
||||
It requires Windows 11 or Windows 10 build 19044 or newer; see
|
||||
[Microsoft's requirements](https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps).
|
||||
|
||||
## Updating an existing imported runtime
|
||||
|
||||
Installing a newer application does not replace an already registered
|
||||
`muSRFlow-runtime` distribution. Older runtime archives omitted Boost headers,
|
||||
which ROOT needs when loading musrview plotting classes. After installing the
|
||||
application with the WSL library-path fix, update an existing runtime from
|
||||
PowerShell with:
|
||||
|
||||
```powershell
|
||||
wsl -d muSRFlow-runtime -- dnf -y install boost-devel
|
||||
```
|
||||
|
||||
This requires access to the distribution's package repositories. It adds the
|
||||
missing headers without removing the WSL distribution or your work files.
|
||||
Fresh runtimes built with the updated script already include them. The build
|
||||
also checks that ROOT can parse `PMusrCanvas.h`, because `--version` alone
|
||||
does not exercise the plotting dependencies.
|
||||
|
||||
## Packaging
|
||||
|
||||
The Windows build ships the rootfs through electron-builder. ``win.extraResources``
|
||||
|
||||
@@ -59,9 +59,10 @@ echo "Staging WSL2 rootfs in $BASE_IMAGE"
|
||||
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.
|
||||
# self-contained. ROOT parses musrfit headers when opening plots, so
|
||||
# Boost headers are required at runtime as well as during compilation.
|
||||
dnf -y install \
|
||||
gsl fftw libxml2 boost openssl-libs \
|
||||
gsl fftw libxml2 boost-devel openssl-libs \
|
||||
mesa-libGL mesa-libGLU \
|
||||
libX11 libXext libXft libXpm libXcursor libXrandr libXi \
|
||||
freetype fontconfig libpng libjpeg-turbo libtiff \
|
||||
@@ -81,6 +82,13 @@ echo "Staging WSL2 rootfs in $BASE_IMAGE"
|
||||
# Validate at the installed prefix; a failed check stops the container
|
||||
# and prevents exporting a rootfs that cannot run the required tools.
|
||||
bash /tmp/validate-runtime.sh "$PREFIX"
|
||||
|
||||
# Version checks do not exercise ROOT dictionary/header loading. Test
|
||||
# the plotting header too, before publishing a runtime that cannot plot.
|
||||
timeout --kill-after=2s 30s env ROOTSYS="$PREFIX" MUSRFITPATH="$PREFIX" \
|
||||
LD_LIBRARY_PATH="$PREFIX/lib" PATH="$PREFIX/bin:/usr/bin:/bin" \
|
||||
"$PREFIX/bin/root" -l -b -q -e \
|
||||
"if (!gInterpreter->Declare(\"#include <PMusrCanvas.h>\")) gSystem->Exit(1);"
|
||||
'
|
||||
|
||||
echo "Exporting rootfs to $OUTPUT"
|
||||
@@ -96,7 +104,7 @@ Import once on Windows (per user):
|
||||
|
||||
Then muSRFlow launches bundled tools as:
|
||||
|
||||
wsl.exe -d $DISTRO_NAME -- $PREFIX/bin/musrfit ...
|
||||
wsl.exe -d $DISTRO_NAME -- env ROOTSYS=$PREFIX MUSRFITPATH=$PREFIX LD_LIBRARY_PATH=$PREFIX/lib $PREFIX/bin/musrfit ...
|
||||
|
||||
WSLg (Windows 11 / recent Windows 10) provides the X server musrview needs.
|
||||
EOF
|
||||
@@ -202,11 +202,16 @@ fs.writeFileSync(path.join(separateRuntimeRoot, "musrfit_startup.xml"), "<musrfi
|
||||
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", "--",
|
||||
const expectedWslArgs = [
|
||||
"-d", "muSRFlow-runtime", "--", "env",
|
||||
"ROOTSYS=/opt/musrfit-runtime",
|
||||
"MUSRFITPATH=/opt/musrfit-runtime",
|
||||
"LD_LIBRARY_PATH=/opt/musrfit-runtime/lib",
|
||||
"PATH=/opt/musrfit-runtime/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||
"/opt/musrfit-runtime/bin/musrt0",
|
||||
"-g", "/mnt/c/work/job.msr"
|
||||
]);
|
||||
];
|
||||
assert.deepStrictEqual(Array.from(launch.args), expectedWslArgs);
|
||||
|
||||
// A Windows-native tool (user-configured directory) is launched directly.
|
||||
const nativeLaunch = sandbox.prepareLocalLaunch("C:\\tools\\musrfit.exe", ["-u", "4"]);
|
||||
@@ -218,7 +223,8 @@ fs.writeFileSync(path.join(separateRuntimeRoot, "musrfit_startup.xml"), "<musrfi
|
||||
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");
|
||||
'wsl.exe ' + expectedWslArgs.slice(0, -2).map(arg => '"' + arg + '"').join(' ')
|
||||
+ ' "[1 2 3]" _tmpl msr-1 global');
|
||||
assert.strictEqual(
|
||||
sandbox.prepareWslCommandString("C:\\tools\\msr2data.exe x"),
|
||||
"C:\\tools\\msr2data.exe x");
|
||||
@@ -235,6 +241,9 @@ fs.writeFileSync(path.join(separateRuntimeRoot, "musrfit_startup.xml"), "<musrfi
|
||||
const originalEnvironment = Object.assign({}, sandbox.process.env);
|
||||
const env = sandbox.buildToolEnvironment();
|
||||
|
||||
assert.strictEqual(env.ROOTSYS, undefined, 'Do not export Windows bundle paths as Linux ROOTSYS');
|
||||
assert.strictEqual(env.MUSRFITPATH, undefined);
|
||||
assert.strictEqual(env.LD_LIBRARY_PATH, undefined);
|
||||
assert.strictEqual(env.PATH, windowsPath,
|
||||
'Fit/Plot must keep Windows directories intact for wsl.exe lookup (' + pathKey + ')');
|
||||
assert.deepStrictEqual(Object.keys(env).filter(key => key.toUpperCase() === 'PATH'), ['PATH']);
|
||||
|
||||
@@ -231,10 +231,12 @@ async function run() {
|
||||
const launch = desktop.prepareLocalLaunch('C:\\resources\\runtime\\bin\\musrfit', ['514_asy.msr']);
|
||||
assert.strictEqual(launch.command, 'wsl.exe');
|
||||
assert.strictEqual(launch.args[3], 'env');
|
||||
assert.ok(launch.args[4].includes('/mnt/c/Users/Test User/data'));
|
||||
assert.ok(!launch.args[4].includes('C:'));
|
||||
const dataEnvironment = launch.args.find(arg => arg.startsWith('MUSRFULLDATAPATH='));
|
||||
assert.ok(dataEnvironment.includes('/mnt/c/Users/Test User/data'));
|
||||
assert.ok(!dataEnvironment.includes('C:'));
|
||||
assert.ok(launch.args.includes('LD_LIBRARY_PATH=/opt/musrfit-runtime/lib'));
|
||||
assert.ok(desktop.prepareWslCommandString('C:\\resources\\runtime\\bin\\msr2data [514] _asy')
|
||||
.includes('env "MUSRFULLDATAPATH=/mnt/c/Users/Test User/data'));
|
||||
.includes('"MUSRFULLDATAPATH=/mnt/c/Users/Test User/data'));
|
||||
console.log('Electron run download, fallback, offline reuse, and workflow tests passed');
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user