diff --git a/com.oracle.truffle.r.native/run/R.sh b/com.oracle.truffle.r.native/run/R.sh
index eaba495fc35a8995396db4dacd7f24fe2a3192fd..c59f02c5579b62db71209da87cf10ece03830c3d 100644
--- a/com.oracle.truffle.r.native/run/R.sh
+++ b/com.oracle.truffle.r.native/run/R.sh
@@ -33,14 +33,17 @@ source="${BASH_SOURCE[0]}"
 while [ -h "$source" ] ; do source="$(readlink "$source")"; done
 PRIMARY_PATH="$( cd -P "$( dirname "$source" )" && pwd )"/../..
 
-mx=`which mx`
-if [ -z "$mx"] ; then
+which mx >/dev/null 2>&1
+whichrc=$?
+if [ $whichrc == 1 ] ; then
     if [ -z "$MX_HOME" ] ; then
-	echo "Error: mx cannot be found: add to PATH or set MX_HOME"
-	exit 1
+	    echo "Error: mx cannot be found: add to PATH or set MX_HOME"
+	    exit 1
     else
-	mx=$MX_HOME/mx
+	    mx=$MX_HOME/mx
     fi
+else
+    mx=`which mx`
 fi
 
 exec $mx $MX_R_GLOBAL_ARGS R $MX_R_CMD_ARGS "$@"
diff --git a/com.oracle.truffle.r.native/run/Rscript_exec.sh b/com.oracle.truffle.r.native/run/Rscript_exec.sh
index 8608362c6d8dc7b5e660fe10a1dcdeb060da9fb9..fab2fc1f0ef8b1afbf862a04abbdfa7f782b76f5 100644
--- a/com.oracle.truffle.r.native/run/Rscript_exec.sh
+++ b/com.oracle.truffle.r.native/run/Rscript_exec.sh
@@ -29,14 +29,17 @@ source="${BASH_SOURCE[0]}"
 while [ -h "$source" ] ; do source="$(readlink "$source")"; done
 PRIMARY_PATH="$( cd -P "$( dirname "$source" )" && pwd )"/../..
 
-mx=`which mx`
-if [ -z "$mx"] ; then
+which mx >/dev/null 2>&1
+whichrc=$?
+if [ $whichrc == 1 ] ; then
     if [ -z "$MX_HOME" ] ; then
-	echo "Error: mx cannot be found: add to PATH or set MX_HOME"
-	exit 1
+	    echo "Error: mx cannot be found: add to PATH or set MX_HOME"
+	    exit 1
     else
-	mx=$MX_HOME/mx
+	    mx=$MX_HOME/mx
     fi
+else
+    mx=`which mx`
 fi
 
 exec $mx $MX_R_GLOBAL_ARGS Rscript $MX_R_CMD_ARGS "$@"
diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/TestRPackages.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/TestRPackages.java
index 3764dab2488150dcc805f7c9a7ef3dfa728c92c5..67b6c651ae858311d125aa54ab9fdf59adb04791 100644
--- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/TestRPackages.java
+++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/rpackages/TestRPackages.java
@@ -85,7 +85,7 @@ public class TestRPackages extends TestBase {
             Map<String, String> env = pb.environment();
             env.put("R_LIBS_USER", rpackagesLibs.toString());
             if (!generatingExpected()) {
-                env.put("R_INSTALL_TAR", "/usr/bin/tar");
+                env.put("R_INSTALL_TAR", REnvVars.get("TAR"));
             }
             try {
                 if (FastROptions.debugMatches("TestRPackages")) {