That did it.   Thank you!

 - Paul

> On Jun 29, 2018, at 4:11 PM, Martin Morgan <martin.mor...@roswellpark.org> 
> wrote:
> 
> 
> 
> On 06/29/2018 06:44 PM, Paul Shannon wrote:
>> My package RCyjs reads an html/js/css file when the constructor is called, 
>> then sends that file to the user’s browser.
>> The actual path to that file is calculated at global scope in RCyjs-class.R:
>>    cyjsBrowserFile <- system.file(package="RCyjs", "browserCode", "dist", 
>> "rcyjs.html”)
>> That file cannot be found at runtime.  Using
>>   options(error=recover)
>> I can trap that error, finding these two different interpretations of 
>> system.file(package=“RCyjs”):
>>    cyjsBrowserFile:
>>        
>> "/Users/biocbuild/bbs-3.8-bioc/meat/RCyjs.buildbin-libdir/RCyjs/browserCode/dist/rcyjs.html”
>>     system.file(package="RCyjs")
>>       "/Library/Frameworks/R.framework/Versions/3.5/Resources/library/RCyjs”
>> It appears that cyjsBrowserFile is assigned at the build system’s package 
>> construction time, not at the package load and use time.
>> Maybe this is new behavior?   Any suggestions on how to defer the 
>> calculation of system.file(package=“RCyjs”) till run time?
> 
> you have the assignment at the 'top' level of your package R code
> 
> cyjsBrowserFile <- system.file(package="RCyjs", ...)
> 
> so that it gets evaluated when R source()s the file (approximately) to create 
> the package. The correct paradigm would be to create the reference when the 
> package is loaded, using .onLoad
> 
> cyjsBrowserFile <- NULL     # create symbol when built
> 
> .onLoad <- function(...) {
>    cyjsBrowserFile <<- system.file(...  # assign symbol (using <<-) on load
> }
> 
> Martin
> 
>> Thanks!
>>  - Paul
>> _______________________________________________
>> Bioc-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/bioc-devel
> 
> 
> This email message may contain legally privileged and/or confidential 
> information.  If you are not the intended recipient(s), or the employee or 
> agent responsible for the delivery of this message to the intended 
> recipient(s), you are hereby notified that any disclosure, copying, 
> distribution, or use of this email message is prohibited.  If you have 
> received this message in error, please notify the sender immediately by 
> e-mail and delete this email message from your computer. Thank you.

_______________________________________________
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel

Reply via email to