Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R CMD build: Ignore R_FUTURE_PLAN during package build to avoid cyclic loading #541

Open
HenrikBengtsson opened this issue Aug 31, 2021 · 1 comment

Comments

@HenrikBengtsson
Copy link
Owner

Issue

$ R_FUTURE_PLAN=future.callr::callr R CMD build future.apply
* checking for file ‘future.apply/DESCRIPTION’ ... OK
* preparing ‘future.apply’:
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
      -----------------------------------
* installing *source* package ‘future.apply’ ...
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error: package or namespace load failed for ‘future’:
 .onLoad failed in loadNamespace() for 'future', details:
  call: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])
  error: cyclic namespace dependency detected when loading ‘future’, already loading ‘future.callr’, ‘future’
Execution halted
ERROR: lazy loading failed for package ‘future.apply’
* removing ‘/tmp/hb/RtmpuGbp1R/Rinst4a9660c92d74/future.apply’
      -----------------------------------
ERROR: package installation failed

Action

Have .onLoad() detect when R CMD build is running and unset R_FUTURE_PLAN.

@HenrikBengtsson
Copy link
Owner Author

HenrikBengtsson commented Sep 3, 2021

Ah, here's a smaller example:

$ R_FUTURE_PLAN=future.callr::callr Rscript --vanilla -e "loadNamespace('future')"
Error: .onLoad failed in loadNamespace() for 'future', details:
  call: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])
  error: cyclic namespace dependency detected when loadingfuture’, already loadingfuture.callr’, ‘futureExecution halted

and

$ R_FUTURE_PLAN=future.callr::callr R --quiet --vanilla
> loadNamespace("future")
Error: .onLoad failed in loadNamespace() for 'future', details:
  call: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])
  error: cyclic namespace dependency detected when loadingfuture’, already loadingfuture.callr’, ‘future> traceback()
3: stop(gettextf("%s failed in %s() for '%s', details:\n  call: %s\n  error: %s", 
       hookname, "loadNamespace", pkgname, deparse(conditionCall(res))[1L], 
       conditionMessage(res)), call. = FALSE, domain = NA)
2: runHook(".onLoad", env, package.lib, package)
1: loadNamespace("future")

To work around this, the future plan needs to be deferred to later (after the future package is loaded).

Details

$ R_FUTURE_DEBUG=true R_FUTURE_PLAN=future.callr::callr Rscript --vanilla -e "loadNamespace('future')"
...
[21:53:56.218] parallelly-specific environment variables:
- R_FUTURE_DEBUG=true- R_FUTURE_PLAN=future.callr::callr’
[21:53:56.231] Future-specific environment variables:
- R_FUTURE_DEBUG=true- R_FUTURE_PLAN=future.callr::callr...
[21:53:56.235] Environment variableR_FUTURE_GLOBALS_KEEPWHEREnot set
[21:53:56.237] Option 'future.plan' =future.callr::callr’
[21:53:56.237] R process uuid: cc462a76-6aa8-84ca-8578-752f3cab43ca
[21:53:56.237] Setting plan('default')
Error: .onLoad failed in loadNamespace() for 'future', details:
  call: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])
  error: cyclic namespace dependency detected when loadingfuture’, already loadingfuture.callr’, ‘futureExecution halted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant