bnosac / taskscheduleR

Schedule R scripts/processes with the Windows task scheduler.
331 stars 72 forks source link

R Scripts cant be found if scripts are sourced using relative referencing. #101

Closed viswambaran closed 1 year ago

viswambaran commented 1 year ago

Hi,

The issue arose where a script is sourcing one or multiple other scripts using relative referencing (as new users will clone this into their own folder structures) the rscript execution cant find these sourced files as cmd is being executed from C:/WINDOWS/System.

example of main.R:

source("otherScript.R")
source("somethingelse.R")

when executed via taskscheduler the logs show the following error

Error in file(filename, "r", encoding = encoding) : 
  cannot open the connection
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
  cannot open file 'C:/WINDOWS/System/otherScript.R': No such file or directory

As such it would require users to change the source commands with the absolute path.

Will submit a PR with this issue for review Thanks

jwijffels commented 1 year ago

Just need to bump the R package version, put something in the news file and publish to cran

viswambaran commented 1 year ago

Just need to bump the R package version, put something in the news file and publish to cran

Can I just check is this an action for me or you? (i've yet to publish a package to CRAN if so)

jwijffels commented 1 year ago

I've uploaded the package on the CRAN web form. Probably should be on there in the coming days. Thanks for the contribution.