-
Notifications
You must be signed in to change notification settings - Fork 207
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
Comments
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). |
sorry, forgot to add sessionInfo(), here it goes:
I tried also with |
Rscript -e "library(methods); lubridate::dhours(22)"
[1] "79200s (~22 hours)" |
Yeah, the thing is I want to use lubridate from inside a package I'm
developing and I don't want my users to "need to load the methods package"
every time they want to use my package from their own Rscript that they
want to execute via command line (because that's really not very intuitive).
Couldn't there be any better alternative?
…Sent from my netBook
On Tue, Feb 21, 2017 at 5:41 PM, Edzer Pebesma ***@***.***> wrote:
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)"
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#499 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AFNM8w9lQG-PwGdM6bjRjUmNsTIcCGRmks5rexPEgaJpZM4LNjgF>
.
|
Fork lubridate, and remove the dependency on |
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. |
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:
Result:
Grab the text above and run from an R console (i.e., use R instead of Rscript): message("lubridate version: ", packageVersion("lubridate"))
sessionInfo()
year.ago <- lubridate::today() - lubridate::dyears(1) message("year ago: ", year.ago)
Yup. methods was added when running from R. I suppose this report belongs elsewhere... |
I've just been bitten by this again, too (with R 3.3.3)... :-/
Did R 3.3.x revert to old behavior somehow (i.e. I lost the warning and only receive the error now)? |
Same error here. Ubuntu, R 3.4.0, lubridate_1.6.0.9009:
|
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). |
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.
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:
But this one doesn't:
I get the following (sorry for the spanish):
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 orlubridate
as imports in the NAMESPACE of the package and still get the same error. I have had to addlibrary(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!
The text was updated successfully, but these errors were encountered: