@platforma-sdk/r-builder 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@platforma-sdk/r-builder",
3
3
  "description": "Build R run environment for Platforma",
4
4
  "type": "module",
5
- "version": "1.1.2",
5
+ "version": "1.1.4",
6
6
  "files": [
7
7
  "assets/",
8
8
  "scripts/"
@@ -146,11 +146,14 @@ async function buildRDist(logger, buildDir, installRoot, rRoot) {
146
146
 
147
147
  const systemLibs = [
148
148
  /ld-linux-x86-64\.so(\.[0-9.]+)?$/,
149
- /libc\.so(\.[0-9.]+)?$/,
150
149
  /libm\.so(\.[0-9.]+)?$/,
151
150
  /libcom_err\.so(\.[0-9.]+)?$/,
151
+ /libc\.so(\.[0-9.]+)?$/,
152
152
  /libstdc\+\+\.so(\.[0-9.]+)?$/,
153
- /libresolv\.so(\.[0-9.]+)?$/
153
+ /libresolv\.so(\.[0-9.]+)?$/,
154
+ /libdl\.so(\.[0-9.]+)?$/,
155
+ /librt\.so(\.[0-9.]+)?$/,
156
+ /libpthread\.so(\.[0-9.]+)?$/
154
157
  ];
155
158
 
156
159
  function collectDependencies(logger, installDir, patchElf = false) {
@@ -397,29 +397,37 @@ export function buildRDependencies(
397
397
 
398
398
  const lockPath = path.join(depsDir, lockFile)
399
399
 
400
- if (fs.existsSync(lockPath)) {
401
- runInRenv(logger, rRoot, [
402
- '--no-echo',
403
- '-e', ...quote(`renv::restore( clean = TRUE )`),
404
- ], {
400
+ const lockExists = fs.existsSync(lockPath)
401
+ const initExists = fs.existsSync(path.join(depsDir, initFile))
402
+
403
+ if (initExists && lockExists) {
404
+ throw new Error(
405
+ `directory ${depsDir} cannot have '${lockFile}' and '${initFile}' simultaneously.\n`+
406
+ `Choose either frozen dependencies state (${lockFile}) either dynamic dependencies initialization (${initFile}).\n`+
407
+ `Create empty '${initFile}' file if you really need empty R run environment without any preinstalled dependencies.`
408
+ )
409
+ } else if (initExists) {
410
+ runInRenv(logger, rRoot, ['--no-echo', `--file=${initFile}`], {
405
411
  wd: depsDir,
406
412
  paths: additionalPaths,
407
413
  })
408
414
 
409
- } else if (fs.existsSync(path.join(depsDir, initFile))) {
410
- runInRenv(logger, rRoot, ['--no-echo', `--file=${initFile}`], {
415
+ // Force snapshot regeneration to put all installed packages into the lock file.
416
+ runInRenv(logger, rRoot, ['--no-echo', '-e', ...quote(`renv::settings$snapshot.type("all"); renv::snapshot()`)])
417
+
418
+ } else if (lockExists) {
419
+ runInRenv(logger, rRoot, [
420
+ '--no-echo',
421
+ '-e', ...quote(`renv::restore( clean = TRUE )`),
422
+ ], {
411
423
  wd: depsDir,
412
424
  paths: additionalPaths,
413
425
  })
414
426
 
415
- if (!fs.existsSync(path.join(depsDir, lockFile))) {
416
- runInRenv(logger, rRoot, ['--no-echo', '-e', ...quote(`renv::snapshot()`)])
417
- }
418
-
419
427
  } else {
420
428
  throw new Error(
421
- `directory ${depsDir} has no ${lockFile} or ${initFile}. No dependencies detected.\n`+
422
- `Create empty init.R file if you really need empty R run environment without any preinstalled dependencies`
429
+ `directory ${depsDir} has no '${lockFile}' or '${initFile}'. No dependencies detected.\n`+
430
+ `Create empty '${initFile}' file if you really need empty R run environment without any preinstalled dependencies`
423
431
  )
424
432
  }
425
433