From simon.urbanek at r-project.org  Mon Jan 26 18:25:24 2009
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Mon, 26 Jan 2009 12:25:24 -0500
Subject: [Rd] [R] can't load rJava in R 2.8.1 on Windows XP
In-Reply-To: <497DB715.4030501@stats.uwo.ca>
References: <4979BA58.20909@googlemail.com>	<4979CAB7.1090708@stats.uwo.ca>	<4979D7D4.7000509@googlemail.com>	<4979DACF.2070206@stats.uwo.ca>	<loom.20090123T170231-341@post.gmane.org>	<497A21C5.1040507@stats.uwo.ca>	<loom.20090123T203821-818@post.gmane.org>	<497A5D6E.30309@stats.uwo.ca>	<loom.20090124T205510-904@post.gmane.org>	<497B879D.2000305@stats.uwo.ca>	<loom.20090126T082805-644@post.gmane.org>
	<497DA6D7.6070908@stats.uwo.ca> <497DB715.4030501@stats.uwo.ca>
Message-ID: <888FEDF8-C075-4489-BDF2-8C5CE7EF88FC@r-project.org>

Duncan,

thanks for the analysis, I have updated rJava to check for the  
truncation and issue a warning with the kb link when detected. I have  
also made sure to not use file.path since it's using the wrong  
separator. The updated rJava version (0.6-2) should be available on  
CRAN soon.

Thanks,
Simon


On Jan 26, 2009, at 8:13 , Duncan Murdoch wrote:

> On 1/26/2009 7:04 AM, Duncan Murdoch wrote:
>> Dieter Menne wrote:
>>> Duncan Murdoch <murdoch <at> stats.uwo.ca> writes:
>>>
>>>
>>>> I don't know what's going wrong on your system.  I added a  
>>>> browser() call to the .onLoad function in R/windows/FirstLib.R on  
>>>> my system, and I see it successfully gets JAVA_HOME from the  
>>>> registry.  It gets a number of other files, then adds these paths  
>>>> to my PATH variable.  I've used strsplit() to separate them for  
>>>> viewing.
>>>>
>>>> [14] "C:\\Program Files\\Java\\jre1.6.0_07\\bin\\client"
>>>> [15] "C:\\Program Files\\Java\\jre1.6.0_07/bin"
>>>> [16] "C:\\Program Files\\Java\\jre1.6.0_07/bin/client"
>>>> [17] "C:\\Program Files\\Java\\jre1.6.0_07/jre/bin/client"
>>>>
>>>> I believe LoadLibrary needs paths to be specified with  
>>>> backslashes, so you might be able to fix things on your system by  
>>>> changing the file.path calls in that function to use fsep="\\"  
>>>> instead of the default "/".
>>>>
>>>
>>> Thanks for your help.
>>> I think I tracked it down. It has nothing to do with rJava, but
>>> rather with Sys.getenv(). Looks like this function truncates  
>>> around 1024
>>> characters, and my path is very long due to Visual Studio + Delphi
>>> + SQL Server.
>>>
>>> See the printout below. Note that the last entry should read \ 
>>> \Delphi,
>>> and that more entries are coming in my system path.
>>> This also explains why only some people have the problem.
>>> No workaround found yet. I keep this message here for other people  
>>> who have the problem, but possibly this is more for R-devel to be  
>>> continued.
>>>
>> Yes, I've moved this to R-devel.
>> If this is an R problem, it's in Sys.setenv:  putting a very long  
>> string and then starting a shell shows the truncated string, but  
>> within the shell it's possible to set a much longer one.
>> However, I don't see a fixed buffer size in the internal R code, so  
>> this looks like a problem in the run-time.  The docs on MSDN say  
>> that the system maintains separate user environment variables and  
>> system environment variables, and the system ones are limited to  
>> 1024 characters:  so this could be our problem.  Our _wputenv call  
>> may be trying to set a system environment variable, and having it  
>> truncated.  (There's also an overall limit of 32767 chars for all  
>> environment variables, but I'd guess you're hitting the 1024 byte  
>> limit.)
>> The docs also say there's a SetEnvironmentVariable API function as  
>> of Win2k, which is our minimal platform these days, so maybe  
>> switching to that would solve the problem.  I'll give it a try, but  
>> probably not today.
>
> One more followup:  This article
>
> http://support.microsoft.com/kb/906469
>
> says that this is a problem in Windows XP SP2 and Windows Server  
> 2003, and provides a fix for those systems.
>
> Duncan Murdoch
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>



[Rd] [R] can't load rJava in R 2.8.1 on Windows XP
Simon Urbanek