diff --git a/dist/lib/funz-client-1.17.jar b/dist/lib/funz-client-1.17.jar index 5c0e801..a5db06e 100644 Binary files a/dist/lib/funz-client-1.17.jar and b/dist/lib/funz-client-1.17.jar differ diff --git a/dist/lib/funz-core-1.17.jar b/dist/lib/funz-core-1.17.jar index 16f2dbf..a956157 100644 Binary files a/dist/lib/funz-core-1.17.jar and b/dist/lib/funz-core-1.17.jar differ diff --git a/lib/Rsession-3.1.9.jar b/lib/Rsession-3.1.9.jar index 9379d3e..f777b5c 100644 Binary files a/lib/Rsession-3.1.9.jar and b/lib/Rsession-3.1.9.jar differ diff --git a/src/main/java/org/funz/run/Client.java b/src/main/java/org/funz/run/Client.java index e3fe2c9..c2ade62 100644 --- a/src/main/java/org/funz/run/Client.java +++ b/src/main/java/org/funz/run/Client.java @@ -17,6 +17,8 @@ import java.util.List; import java.util.Map; import org.funz.*; +import org.funz.log.Log; + import static org.funz.Protocol.END_OF_REQ; import static org.funz.Protocol.RET_HEARTBEAT; import static org.funz.Protocol.RET_INFO; @@ -75,7 +77,7 @@ public static class PluginInfo { boolean log = false; public void log(String s) { - //System.err.println("<<<<<<<<<<<<<<<<<<<<<<<<< " + s); + //Log.out("[Client] "+ s, 10); } public static String getProtocol() { @@ -240,6 +242,8 @@ public void flush() { _dis = new DataInputStream(_socket.getInputStream()); } catch (Exception e) { + log("Exception on Socket instanciation on "+_host+":"+_port+"\n "+e); + e.printStackTrace(); disconnect(); } } diff --git a/src/main/java/org/funz/script/RMathExpression.java b/src/main/java/org/funz/script/RMathExpression.java index 9746b71..36695bd 100644 --- a/src/main/java/org/funz/script/RMathExpression.java +++ b/src/main/java/org/funz/script/RMathExpression.java @@ -30,6 +30,7 @@ import org.math.R.RserveSession; import org.math.R.RserverConf; import org.math.R.Rsession; +import org.math.R.Rsession.RException; /** * @@ -196,15 +197,25 @@ public RMathExpression(String name, File log) { } void initR() { - try { // Fix for windows when /cygdrive/c/.. remains in HOME - R.voidEval("Sys.setenv(HOME='" - + new File(System.getProperty("user.home")).getAbsolutePath(). - replace('\\', '/') // Fix path sep - + "')"); - } catch (Rsession.RException ex) { - Log.err("Failed to setup user homedir: " + ex.getMessage(), 3); - } R.log("######################### INFORMATION ###########################", Level.WARNING); + + boolean RisLocal = (R instanceof R2jsSession) ||(R instanceof RenjinSession) || (R instanceof RserveSession && ((RserveSession) R).RserveConf.isLocal()); + if (RisLocal) // otherwise will force to use local username HOME, which may be not available on remote Rserve (if used) + try { // Fix for windows when /cygdrive/c/.. remains in HOME + R.log("Force user homedir: "+new File(System.getProperty("user.home")).getAbsolutePath().replace('\\', '/'), Level.WARNING); + R.voidEval("Sys.setenv(HOME='" + + new File(System.getProperty("user.home")).getAbsolutePath().replace('\\', '/') // Fix path sep + + "')"); + } catch (Rsession.RException ex) { + Log.err("Failed to setup user homedir: " + ex.getMessage(), 3); + } + else + try { + R.log("Let default remote homedir: "+R.eval("Sys.getenv('HOME')"), Level.WARNING); + } catch (RException e) { + Log.err("Failed to get remote homedir: " + e.getMessage(), 3); + } + printInformation(R); initLibPath(R); R.log("#################################################################", Level.WARNING); @@ -341,8 +352,10 @@ String asRList(Map m) { public static void printInformation(Rsession R) { try { + R.log(R.toString(), Level.WARNING); String nodename = (String) R.eval("Sys.info()[['nodename']]"); String rhome = (String) R.eval("Sys.getenv('R_HOME')"); + String home = (String) R.eval("Sys.getenv('HOME')"); String host = (nodename == null ? "?" : nodename) + ":" + (rhome == null ? "?" : rhome); R.log("Host " + host, Level.WARNING); String dir = R.eval("getwd()").toString(); @@ -402,7 +415,7 @@ public static void initLibPath(Rsession R) { } try { //if (RLibPath == null) { - String RLibPath = "file.path('"+Constants.APP_USER_DIR.getAbsolutePath().replace('\\', '/')+"','R')"; + String RLibPath = "file.path(Sys.getenv('HOME'),'R')"; // use getenv(HOME) which is also consistent remotely //} //if (RLibPath != null) { R.voidEval("if (!file.exists(" + RLibPath + ")) dir.create(" + RLibPath + ",recursive=TRUE)");