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

Error during import #117

Closed
frenkiboy opened this issue Jun 19, 2017 · 12 comments
Closed

Error during import #117

frenkiboy opened this issue Jun 19, 2017 · 12 comments

Comments

@frenkiboy
Copy link

frenkiboy commented Jun 19, 2017

Dear Konrad,

I'm currently trying to switch completely to modules, however I've encountered a quite cryptic error.

When I try to do the following:
helper = modules::import('Functions_Helper')

I get the following error:
no applicable method for 'roclet_tags' applied to an object of class "c('roclet_export', 'roclet')"

I think it might have to do something with the fact that roxygen2 has an import function, which then causes the collision.
R is run with vanilla so there's nothing attached except the standard base stuff.

Here is my session info:

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.4.0 R6_2.2.2       magrittr_1.5   tools_3.4.0    roxygen2_6.0.1
 [6] Rcpp_0.12.11   xml2_1.1.1     stringi_1.1.5  stringr_1.2.0  commonmark_1.2
[11] modules_0.9.7

Any help would be appreciated,

Best,

Vedran

@klmr
Copy link
Owner

klmr commented Jun 27, 2017

I can’t reproduce the bug but I have an idea what might be causing it. I’ll get back to you soon …!


EDIT

master is using the hotfix for now, so just doing devtools::install_github('klmr/modules') will work. The following description is unnecessary.


For now, you can probably disable the bug by using the following hotfix branch instead of develop/master: https://github.com/klmr/modules/tree/hotfix-117

To use it, you’ll need to pull this branch and then compile the documentation via

make doc

After that, you can install via devtools::install('.') inside the same directory.

@klmr klmr closed this as completed in ae11abf Jun 27, 2017
@AkhilGNair
Copy link

Hi @klmr

I'm still seeing this with the master branch. A Dockerfile for an env reproducing the behavior is below:

FROM rocker/tidyverse

RUN R -e 'devtools::install_github("klmr/modules@master")' && \
    mkdir pkg && \
    cd pkg && \
    printf 'cat("Hello\n")' > help.r

Building the image as modules and running with

docker run --rm -it modules R

Then executing

modules::import("pkg/help")

Gives the error

Hello
Error in UseMethod("roclet_tags") : 
  no applicable method for 'roclet_tags' applied to an object of class "c('roclet_export', 'roclet')"

Tbh I'm expecting this to be user error, as I managed to use modules before in this manner, but I believe you've changed how things are supposed to be call since I last used it. Could you offer any advice on what's going wrong?

Thanks,
Akhil

PS - Thanks for the excellent package!

@klmr klmr reopened this Aug 14, 2017
@klmr
Copy link
Owner

klmr commented Aug 16, 2017

This issue shows me that I still haven’t fully grokked how R looks up definitions of S3 objects in different namespaces.

I know what the error is and I can produce a hotfix to work around it. But I’m still trying to figure out how to avoid it properly.

@AkhilGNair
Copy link

R is one seriously slippery fish. Is this hotfix hosted? Not that I'm under any illusion that I could help, I'm just interested to see what's causing the error.

@klmr
Copy link
Owner

klmr commented Aug 16, 2017

Uhm. Never mind — I think?!

Turns out, when re-deploying the existing code without changes everything works. Apparently I had failed to re-generate the NAMESPACE file previously. The following change is all that’s needed:

diff --git a/NAMESPACE b/NAMESPACE
index 443ea2d..88bedd5 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -13,10 +17,6 @@ export(module_help)
 export(module_name)
 export(register_S3_method)
 export(reload)
-export(roclet_clean.roclet_export)
-export(roclet_output.roclet_export)
-export(roclet_process.roclet_export)
-export(roclet_tags.roclet_export)
+S3method(roclet_clean,roclet_export)
+S3method(roclet_output,roclet_export)
+S3method(roclet_process,roclet_export)
+S3method(roclet_tags,roclet_export)
 export(set_script_path)
 export(unload)
 importFrom(roxygen2,roclet_clean)

Anyway, my understanding of S3 lookup in R has been vindicated (again: I think). I’ll fix master ASAP.

@grst
Copy link

grst commented Nov 24, 2019

This issue is back for me (latest version of modules, R 3.6.1).

The bad news is, it only happens in Rstudio (using exactly the same environment as on the command line). Any ideas?

I'm struggling to provide more information as I cannot even reproduce it on the command line (as I said, using the same R installation...). But let me know if you need any additional information.

@mschubert
Copy link
Collaborator

mschubert commented Nov 24, 2019

Same issue for me on the R command line:

Error in UseMethod("roclet_tags") :
  no applicable method for 'roclet_tags' applied to an
  object of class "c('roclet_rd', 'roclet')"

R 3.6.1, modules 0.9.11, roxygen2 7.0.1 (CRAN) or 7.0.0.9000 (r-lib/roxygen2).

Works with 6.0.1.9000 (klmr/roxygen)

@klmr
Copy link
Owner

klmr commented Nov 25, 2019

@mschubert To confirm, this is caused by updated roxygen2? Annoying. That said, please open a new issue, this would be unrelated, even if the error message is quite similar.

@klmr
Copy link
Owner

klmr commented Nov 25, 2019

@grst From Michael’s description I’m guessing you have a different library and thus different version of roxygen2 active in the console and RStudio, can you confirm this?

@grst
Copy link

grst commented Nov 25, 2019

@grst From Michael’s description I’m guessing you have a different library and thus different version of roxygen2 active in the console and RStudio, can you confirm this?

Nope - it's roxygen2 7.0.1 in both cases (both Rstudio and the command line are using the same conda env).

Actually, using the R console it fails, too:

> R
>>> modules::import('test_module')
Error in UseMethod("roclet_tags") : 
  no applicable method for 'roclet_tags' applied to an object of class "c('roclet_rd', 'roclet')"

But using Rscript -e "modules::import('test_module')" works.

@klmr
Copy link
Owner

klmr commented Nov 25, 2019

OK, thanks for verifying. The reason Rscript -e works is that in non-interactive usage, modules doesn’t parse documentation. Anyway, this is a new issue is because roxygen2 broke backwards compatibility with their new release. The short-term fix is to downgrade roxygen2. I’ll deploy a proper fix once I find time but unfortunately this isn’t trivial since I have no idea how to use the new roxygen2 API, and it isn’t documented.

@klmr
Copy link
Owner

klmr commented Dec 27, 2019

@grst @mschubert This should now hopefully be fixed (unless I messed up the deployment again). Apologies for the delay.

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

No branches or pull requests

5 participants