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

problem with loadMethod for lubridate in Rscript #499

Closed
pchtsp opened this Issue Dec 14, 2016 · 10 comments

Comments

Projects
None yet
6 participants
@pchtsp

pchtsp commented Dec 14, 2016

I had written in #314 but, since it's already close, I think it's better to open a new one. Although it seems to be the same problem. Also similar to #407, apparently.

This (original example) works:

Rscript -e "lubridate::round_date(Sys.time(),'minute')"

But this one doesn't:

Rscript -e "lubridate::dhours(22)"

I get the following (sorry for the spanish):

Error in .setupMethodsTables(fdef, initialize = TRUE) :
  tentativa de obtener un slot "group" de un objeto de una clase básica ("NULL") sin slots
Calls: <Anonymous> ... getMethodsForDispatch -> .getMethodsTable -> .setupMethodsTables
Ejecución interrumpida

I'm using lubridate as dependency in a package I'm building. I'm calling the package from a single R script that gets executed via Rscript.
I have tried adding methods and or lubridate as imports in the NAMESPACE of the package and still get the same error. I have had to add library(methods) to the R script that calls the package in order to make it work. But this doesn't seem to be a "nice" solution to the problem.

Any advice?
Thanks!

@vspinu

This comment has been minimized.

Member

vspinu commented Dec 21, 2016

Which version of R is this? I am getting this on 3.2.4:

 Rscript -e "lubridate::dhours(22)"
Loading required package: grDevices
[1] "79200s (~22 hours)"
Warning message:
In .doLoadActions(where, attach) :
  trying to execute load actions without 'methods' package

warning is annoying but there is little we can do about it (I think).

@pchtsp

This comment has been minimized.

pchtsp commented Dec 21, 2016

sorry, forgot to add sessionInfo(), here it goes:

R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 14393)

locale:
[1] LC_COLLATE=Spanish_Spain.1252  LC_CTYPE=Spanish_Spain.125
[3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.1252

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

I tried also with R-3.2.3, which I also had installed in my pc. I only got the warning as you mentioned.

@edzer

This comment has been minimized.

edzer commented Feb 21, 2017

Rscript -e, as opposed to R -e, does not load methods on startup. If you need to use Rscript -e, load it manually:

Rscript -e "library(methods); lubridate::dhours(22)"
[1] "79200s (~22 hours)"
@pchtsp

This comment has been minimized.

pchtsp commented Feb 21, 2017

@edzer

This comment has been minimized.

edzer commented Feb 21, 2017

Fork lubridate, and remove the dependency on methods; not so sure whether this would count as "better".

@vspinu

This comment has been minimized.

Member

vspinu commented Feb 21, 2017

One cannot remove dependency on methods, it's too deeply rooted. This issue is not lubridate specific and has been there for years. There have been rumors that it has been fixed on R side, but seems like it wasn't.

@wehopkins

This comment has been minimized.

wehopkins commented Apr 11, 2017

This error makes package development more difficult, especially if one follows the recommendation to not load packages. The code was well tested from within RStudio, then run within an Rscripted shell file (so that it can be invoked via cron), only to fail. These kinds of errors are pernicious - everything works fine in the environment best suited for development, but then fails due to a subtle difference in a more production-oriented batch environment.

Simplified code to demonstrate the error; in a shell file:

#! /opt/R/3.3.1/bin/Rscript

message("lubridate version: ", packageVersion("lubridate"))
sessionInfo()

year.ago <- lubridate::today() - lubridate::dyears(1)

message("year ago: ", year.ago)

Result:

$ ./testscript.sh
lubridate version: 1.6.0
R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.1 LTS

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 base
Error in .setupMethodsTables(fdef, initialize = TRUE) :
trying to get slot "group" from an object of a basic class ("NULL") with no slots
Calls: ... getMethodsForDispatch -> .getMethodsTable -> .setupMethodsTables
Execution halted

Grab the text above and run from an R console (i.e., use R instead of Rscript):

message("lubridate version: ", packageVersion("lubridate"))

lubridate version: 1.6.0

sessionInfo()

R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.1 LTS

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

year.ago <- lubridate::today() - lubridate::dyears(1)

message("year ago: ", year.ago)

year ago: 2016-04-11

Yup. methods was added when running from R.

I suppose this report belongs elsewhere...

@mmuurr

This comment has been minimized.

mmuurr commented Jun 23, 2017

I've just been bitten by this again, too (with R 3.3.3)... :-/

% Rscript -e 'lubridate::days(1)'
Error in .setupMethodsTables(fdef, initialize = TRUE) :
  trying to get slot "group" from an object of a basic class ("NULL") with no slots
Calls: <Anonymous> ... getMethodsForDispatch -> .getMethodsTable -> .setupMethodsTables
Execution halted

Did R 3.3.x revert to old behavior somehow (i.e. I lost the warning and only receive the error now)?

@RoyalTS

This comment has been minimized.

RoyalTS commented Sep 14, 2017

Same error here. Ubuntu, R 3.4.0, lubridate_1.6.0.9009:

~> Rscript -e 'lubridate::days(1)'
Error in .setupMethodsTables(fdef, initialize = TRUE) :
  trying to get slot "group" from an object of a basic class ("NULL") with no slots
Calls: <Anonymous> ... getMethodsForDispatch -> .getMethodsTable -> .setupMethodsTables
Execution halted
@vspinu

This comment has been minimized.

Member

vspinu commented Oct 1, 2017

Folks, I am sorry, but nothing could be done on this end. Lubridate uses S4, and that means "methods" pacakge. It's not our fault that R and RScript don't behave identically.

For better o worse, we are stuck with S4 and that won't change till we have a fresh stab for a more lightweight date-time package(s).

@vspinu vspinu closed this Oct 1, 2017

infotroph added a commit to infotroph/lubridate that referenced this issue Oct 4, 2017

infotroph added a commit to infotroph/pecan that referenced this issue Oct 5, 2017

Supply missing dependencies
Note that depending on methods is a workaround for a bug in lubridate (tidyverse/lubridate#499) and we do not use any of its festures directly.

infotroph added a commit to infotroph/lubridate that referenced this issue Oct 6, 2017

infotroph added a commit to infotroph/lubridate that referenced this issue Oct 6, 2017

infotroph added a commit to infotroph/lubridate that referenced this issue Oct 6, 2017

vspinu added a commit that referenced this issue Oct 8, 2017

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