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

S7 method<- errors when called from non-installed pseudo-package #512

Open
t-kalinowski opened this issue Dec 13, 2024 · 1 comment
Open

Comments

@t-kalinowski
Copy link
Member

Here, the current working directory is a real package, pkgb. pkgb imorts pkga, and pkga calls method<-. Attempting to only partially load pkgb with roxygen2::load_source() signals this cryptic error.

> roxygen2::load_source(".")
Error in `loadNamespace()`:
! there is no package calledroxygen_devtestRun `rlang::last_trace()` to see where the error occurred.
> rlang::last_trace()
<error/rlang_error>
Error in `loadNamespace()`:
! there is no package calledroxygen_devtest---
Backtrace:1. └─roxygen2::load_source(".")
  2.   └─base::lapply(package_files(path), sys_source, envir = env)
  3.     └─roxygen2 (local) FUN(X[[i]], ...)
  4.       └─base::eval(expr, envir = envir)
  5.         └─base::eval(expr, envir = envir)
  6.           └─S7::`method<-`(`*tmp*`, Variable, value = `<fn>`)
  7.             └─S7:::register_method(generic, signature, value, env = parent.frame())
  8.               └─S7:::external_methods_add(package, generic, signature, method)
  9.                 └─S7:::S7_methods_table(package)
 10.                   └─base::asNamespace(package)
 11.                     └─base::getNamespace(ns)
 12.                       ├─.Internal(getRegisteredNamespace(name)) %||% ...
 13.                       └─base::loadNamespace(name)
 14.                         └─base::withRestarts(stop(cond), retry_loadNamespace = function() NULL)
 15.                           └─base (local) withOneRestart(expr, restarts[[1L]])
 16.                             └─base (local) doWithOneRestart(return(expr), restart)

(roxygen_devtest is a pseudo package env created by roxygen2. We don't need to support roxygen specially here, but S7 should be robust to the asNamespace() call failing.)

@mmaechler
Copy link
Collaborator

well... I apologize for being somewhat controversial ...
but, as S7 should become a very basic R package and possibly even base or "base - like" ..
Why would it have to support a concept (viz. "pseudo package") that is I think entirely outside of base R?
Shouldn't the other package writers (in this case maintainer("roxygen2") adapt to basic S7 functionality rather than the other way around?

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

No branches or pull requests

2 participants