From ripley at stats.ox.ac.uk  Thu Jul 19 14:31:54 2012
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu, 19 Jul 2012 13:31:54 +0100
Subject: [Rd] Warning when sourcing file after require
In-Reply-To: <5007F393.90103@gmail.com>
References: <CAGf+n7V+zUJ1dBUsGmTXoa1nBNbMv=G6TbveMXCjOV7Nzb5T0Q@mail.gmail.com>
	<5007F393.90103@gmail.com>
Message-ID: <5007FE3A.5000202@stats.ox.ac.uk>

On 19/07/2012 12:46, Duncan Murdoch wrote:
> I don't see this in R-patched; I don't have 2.15.1 installed on this
> machine.  But the problem appears to be that XML exports a function
> called source() (a generic), and you're using it -- but not the current
> version, which doesn't give the warning.

Whenever you upgrade your R you need to re-install your packages.  And 
this is particularly true of noisome packages (mainly using the 
'methods' package) which make copies of code from R itself.  XML is a 
known example.

conflicts()
update.packages(checkBuilt=TRUE)

are your friends. E.g.

 > library(XML)
 > conflicts(, TRUE)
$`package:XML`
[1] "coerce" "show"   "source"

$`package:methods`
[1] "coerce"    "show"      "body<-"    "kronecker"

$`package:base`
[1] "body<-"    "kronecker" "source"


>
> Duncan Murdoch
>
> On 12-07-18 1:36 PM, David Hastie wrote:
>> Hi
>>
>> I have recently upgraded to R 2.15.1. Since the upgrade, I am getting
>> some odd behaviour that I don't understand. If I source a file which
>> has a function with a require (or library) statement in it, then the
>> first time I source it behaves as expected. If I then call the
>> function (so that the require statement is evaluated) the function
>> also runs ok. However, if I then subsequently try to source the file
>> again I get an .Internal(eval.with.vis) warning.
>>
>> At first I obviously thought it must be an error of mine in the file
>> containing the functions I had written. However, subsequent tests show
>> that even if the following code
>>
>> foo<-function(){
>>     require(XML)
>>     cat("This is a test fn\n")
>> }
>>
>> is put in the file foo.R, then running the following code gives the
>> warning.
>>
>>> source('foo.R')
>>> foo()
>> Loading required package: XML
>> This is a test fn
>>> source('foo.R')
>> Warning message:
>> In eval.with.vis(ei, envir) :
>>    .Internal(eval.with.vis) should not be used and will be removed soon
>>
>> The key part to this is the inclusion of the require statement. If the
>> require statement was not in the function, then there are no warnings.
>> I experience this behaviour on my desktop running Ubuntu 12.04 and on
>> my Mac running OSX. From looking at the change log of 2.15.1 I notice
>> that the way files are sourced has changed (and seems to relate to
>> this warning), but it is not clear to me what if anything this means I
>> should change.
>>
>> I would be grateful for any tips.
>>
>> Kind regards
>> Dave
>>
>> --
>> David Hastie, Ph.D.
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Warning when sourcing file after require
Prof Brian Ripley