rJava in RStudio Pro - rjava

I have a clean install of RStudio Server (Pro) on clean Ubuntu 14.04. Install was smooth only problem I have is with rJava. Everything else appears to be working fine.
To install the rJava package I installed the package from the R (running as sudo) from the console. This is what I have always done when setting up RStudio Servers. Once installed rJava works fine from the R console as sudo or normal user.
From the RStudio IDE I can load the rJava package, but when I call .jinit() I get errors:
library(rJava)
.jinit()
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error in .jinit() : Cannot create Java virtual machine (-4)
This is contrary to what happens if I ssh onto the server directly as same user and run the same commands from R console - this does not generata any error.
Any idea what is going on here? I have searched around and not found anything that helps. I tried completely uninstalling openjdk, tried reinstalling the package. Nothing seems to work - and because I get different behavior between the R console on the terminal and the R console in RStudio Server I am slightly puzzled.
The version of R on the console is:
$platform
[1] "x86_64-pc-linux-gnu"
$arch
[1] "x86_64"
$os
[1] "linux-gnu"
$system
[1] "x86_64, linux-gnu"
$status
[1] ""
$major
[1] "3"
$minor
[1] "1.2"
$year
[1] "2014"
$month
[1] "10"
$day
[1] "31"
$`svn rev`
[1] "66913"
$language
[1] "R"
$version.string
[1] "R version 3.1.2 (2014-10-31)"
$nickname
[1] "Pumpkin Helmet"
This is the same as the version that R Studio Server is using.
JAVA_HOME is the same from R console on terminal and R console in RStudio Server
> Sys.getenv('JAVA_HOME')
[1] "/usr/lib/jvm/java-1.7.0-openjdk-amd64/jre"
This is the same as the JAVA_HOME I get from the shell.
I have the following java version:
java -version
java version "1.7.0_75"
OpenJDK Runtime Environment (IcedTea 2.5.4) (7u75-2.5.4-1~trusty1)
OpenJDK 64-Bit Server VM (build 24.75-b04, mixed mode)
Would love some suggestions or input from folks who have struggled with this same problem.
Cheers,
Matt

Have you check how much memory you set up for the JVM? I had the same issue as initially I set it up as 8g.
You can set up the size of JVM's memory using the following command:
options( java.parameters = "-Xmx8g" )

Related

How to downgrade JDK/javac - MacOS

I am trying to downgrade the jdk for a project I'm running from 17.0.5 to 1.8, but have not been able to replicate any of the results I've found online. Specs and attempts below.
Specs:
MacOS Big Sur v11.6.8
Java v1.8.0_351
Javac v17.0.5
Gradle v7.6
Homebrew v3.6.16
Running /usr/libexec/java_home -V:
Matching Java Virtual Machines (4):
17.0.5 (x86_64) "Oracle Corporation" - "Java SE 17.0.5" /Library/Java/JavaVirtualMachines/jdk-17.0.5.jdk/Contents/Home
1.8.351.10 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
1.8.0_351 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_351.jdk/Contents/Home
1.8.0_341 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_341.jdk/Contents/Home
First, I tried replicating the code from this answer regarding downgrading java:
https://stackoverflow.com/a/48422257/20834861
I quickly realized that the bash profile from sudo nano was already used to downgrade java to v1.8.
Then, I tried this solution: https://stackoverflow.com/a/23819062/20834861
But sudo mv jdk1.8.0_351.jdk ~/Desktop/ returns the following error: mv: rename jdk1.8.0_351.jdk to /Users/sahil/Desktop/jdk1.8.0_351.jdk: No such file or directory
So next, I tried the solution from this link:
https://mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/#java-home-and-macos-11-big-sur
When I tried the final line of code, echo $JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_351.jdk/Contents/Home , I received the following error: zsh: permission denied: /Library/Java/JavaVirtualMachines/jdk1.8.0_351.jdk/Contents/Home .
Finally, I tried a similar line of code but with source as the bash_file instead of zshenv. I got the same error.
I must be missing something really obvious but I could not find anything else on the internet. Any help is appreciated.
With OSX you can select which jdk to use by using the JAVA_HOME environment variable. To set it.
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_351.jdk/Contents/Home
That should work because it is in the list of jdk's you have available according to java_home. You can also use the java_home command to get the appropriate jdk.
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
Then when you run java or javac it should be from the version selected.

OSX fix Selenium Chromedriver launch error spawn Unknown system error -86 Bad CPU type in executable?

Suddenly on the afternoon of January 6, 2021, my Selenium Protractor tests under OSX stopped working with the mysterious error
spawn Unknown system error -86
I did some research and discovered that error number 86 is the same as
Bad CPU type in executable
and ran the following to compare the cpu architecture of my chromedriver binary to my system:
% file chromedriver_87.0.4280.88
chromedriver_87.0.4280.88: Mach-O 64-bit executable arm64
% uname -a
Darwin kobl179273m 19.6.0 Darwin Kernel Version 19.6.0: Thu Oct 29 22:56:45 PDT 2020; root:xnu-6153.141.2.2~1/RELEASE_X86_64 x86_64
% uname -p
i386
How can I fix the chromedriver binary used by my Selenium so that it will run on my Intel x64 mac and clear the "system error -86" or "Bad CPU type" message?
The issue is described in https://github.com/angular/webdriver-manager/issues/476.
This has been now fixed in 12.1.8 so just update to that webdriver manager.
For most users this can be accomplished with
npm uninstall protractor && npm install protractor
Edit: this answer should be considered deprecated now that the underlying bug in webdriver-manager has been fixed. A better solution would be to upgrade to the newest version of webdriver-manager. The answer below may be useful if people need to use an older version of webdriver-manager which still has the bug.
As per Deepak Srinivasan's comment above, this error is caused by https://github.com/angular/webdriver-manager/issues/476
Root Cause:
The ChromeDriver team added "_m1" to the end of the filename for their Apple Silicon ARM builds of Chromedriver -- but both the Silicon and Intel versions of chromedriver have "mac64" in the filename, and the version number is exactly the same. This causes webdriver-manager to always download the Silicon build of Chromedriver, even on Intel macs. As a general solution, simply avoid using the chromedriver that has _m1 in its filename if you are on an Intel mac.
Solution 1: Downgrade to Chrome 86.0.4240.198 and Chromedriver 86.0.4240.22. These versions work together and are the most recent versions prior to the new and problematic support for Silicon ARM
Chrome 86 download page:
https://google-chrome.en.uptodown.com/mac/download/2920124
Disable auto-updates in Chrome: https://superuser.com/questions/1359017/how-do-i-disable-automatic-updates-of-google-chrome-on-mac-os-x
Chromedriver 86: https://chromedriver.storage.googleapis.com/index.html?path=86.0.4240.22/
% webdriver-manager update --versions.chrome=86.0.4240.22
Solution 2: Modify the webdriver-manager npm package to point to the correct chromedriver (thanks to ciekaway from the angular github issue page for this fix)
Modify the following file
node_modules/webdriver-manager/built/lib/files/file_manager.js
or, if using protractor
node_modules/protractor/node_modules/webdriver-manager/built/lib/files/file_manager.js
Near the top of the downloadFile method around line 166, add the following line to remove "_m1" from the name of the file:
fileUrl.url = fileUrl.url.replace(/_m1/, '');
It needs to be after the beginning of the .then block that starts with
binary.getUrl(binary.version()).then(fileUrl => {
it also needs to be before the next reference to fileUrl.
For example:
binary.getUrl(binary.version()).then(fileUrl => {
binary.versionCustom = fileUrl.version;
fileUrl.url = fileUrl.url.replace(/_m1/, '');
let filePath = path.resolve(outputDir, binary.filename());
Note that this solution is temporary. It will be overwritten by an npm install. The Chromedriver and/or the webdriver-manager team will probably fix this issue, at which point you should clear the modified version of your webdriver-manager and download the fix from npm.
For macOS Catalina Version 10.15.6 (19G73)
In my case I was working with Rails and Capybara for feature tests. What worked for me was
First, find the actual chromedriver location running:
which chromedriver
# Which returned:
/Users/alex/.webdrivers/chromedriver
Then, install chromedriver via Homebrew:
brew install chromedriver
Then, remove old chromedriver reference found at previous location with:
rm /Users/alex/.webdrivers/chromedriver
Now, link the old chromedriver reference to the one installed with brew:
ln -s /usr/local/bin/chromedriver /Users/alex/.webdrivers/chromedriver
Then, open Finder app, then click on Go menu and then click Go to folder ... option, and enter this route:
/usr/local/Caskroom/chromedriver/
There you should see a folder with the chromedriver version you have installed, something like this:
88.0.4324.96
Enter that folder and you should see the chromedriver binary file.
Right click on it, and click on Open
Now, you should get a terminal window popping up with the output:
Last login: Sun Jan 31 12:29:15 on ttys001
/usr/local/Caskroom/chromedriver/88.0.4324.96/chromedriver ; exit;
  ~  /usr/local/Caskroom/chromedriver/88.0.4324.96/chromedriver ; exit;
Starting ChromeDriver 88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b- refs/branch-heads/4324#{#1784}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Finally, press Ctrl+C to stop the execution and quit the terminal window.
Now, you should be able to run capybara tests.
npm uninstall protractor && npm install protractor
If you use webdrivers gem, upgrade it:
bundle update webdrivers

sdkman installed grails 4.0.4, now grails is broken and wont start

I have some older version of grails installed (3.3.8), and tried to use sdkman to install a newer version (4.0.4). The install worked, but grails is now completely broken. i also updated java to 14 from the dmg from the oracle website. Basically grails is now completely broken. Any ideas how to fix?
mac 10.14.4
$ sdk version
SDKMAN 5.7.3+337
$ sdk current java
Not using any version of java
$ java -version
java version "14.0.2" 2020-07-14
Java(TM) SE Runtime Environment (build 14.0.2+12-46)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)
$ sdk current
Using:
groovy: 2.5.8
$ grails --version
| Grails Version: 3.3.8
| Groovy Version: 2.4.15
| JVM Version: 14.0.2
$ sdk install grails
Downloading: grails 4.0.4
In progress...
######################################################################## 100.0%
Installing: grails 4.0.4
Done installing!
Setting grails 4.0.4 as default.
$ sdk current
Using:
groovy: 2.5.8
$ grails --version
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
at org.codehaus.groovy.vmplugin.VMPluginFactory.<clinit>(VMPluginFactory.java:43)
at org.codehaus.groovy.reflection.GroovyClassValueFactory.<clinit>(GroovyClassValueFactory.java:35)
at org.codehaus.groovy.reflection.ClassInfo.<clinit>(ClassInfo.java:107)
at org.codehaus.groovy.reflection.ReflectionCache.getCachedClass(ReflectionCache.java:95)
at org.codehaus.groovy.reflection.ReflectionCache.<clinit>(ReflectionCache.java:39)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.registerMethods(MetaClassRegistryImpl.java:209)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:107)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:85)
at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:36)
at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:86)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.bitwiseNegate(ScriptBytecodeAdapter.java:842)
at org.grails.config.NavigableMap.<clinit>(NavigableMap.groovy)
at org.grails.cli.GrailsCli.<clinit>(GrailsCli.groovy:77)
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
at org.codehaus.groovy.runtime.dgmimpl.NumberNumberMetaMethod.<clinit>(NumberNumberMetaMethod.java:33)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:124)
at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:346)
at java.base/java.lang.Class.newInstance(Class.java:604)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.createMetaMethodFromClass(MetaClassRegistryImpl.java:257)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:110)
at org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.<init>(MetaClassRegistryImpl.java:85)
at groovy.lang.GroovySystem.<clinit>(GroovySystem.java:36)
at org.codehaus.groovy.runtime.InvokerHelper.<clinit>(InvokerHelper.java:86)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.bitwiseNegate(ScriptBytecodeAdapter.java:842)
at org.grails.config.NavigableMap.<clinit>(NavigableMap.groovy)
at org.grails.cli.GrailsCli.<clinit>(GrailsCli.groovy:77)
I dont see an easy way to uninstall java 14, or go back in time.
echo $PATH
/Users/xx/.sdkman/candidates/groovy/current/bin:/Users/xx/.sdkman/candidates/grails/current/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Appz/apache-jmeter-5.3/bin:/usr/local/go/bin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/xx/go/bin:/Users/xx/dev/grails-3.3.8/bin:/Users/xx/dev/flutter/bin:/Users/xx/dev/gradle-5.1.1/bin:/appz/cassandra/bin
I am guessing I can try to hack the path etc, to fix.
This is my current .bash_profile:
vi .bash_profile
export JAVA_HOME=`/usr/libexec/java_home`
export GRAILS_HOME=/Users/xx/dev/grails-3.3.8
export GOPATH=$HOME/go
export GOBIN=$GOPATH/bin
export PATH=$PATH:$GOBIN
export PATH=$PATH:$GRAILS_HOME/bin
# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
export GRADLE_HOME=/Users/xx/dev/gradle-5.1.1
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
PATH="${PATH}:/Users/xx/dev/flutter/bin"
PATH=$PATH:$GRADLE_HOME/bin
# Cassandra
if [ -d "/appz/cassandra" ]; then
export PATH="$PATH:/appz/cassandra/bin"
fi
export PATH
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="/Users/simonh/.sdkman"
[[ -s "/Users/xx/.sdkman/xx/sdkman-init.sh" ]] && source "/Users/xx/.sdkman/bin/sdkman-init.sh"
~
This is odd, why is grails home still 3.3.8, when sdkman installed and made 4.0.4 current? Why didnt it edit the path? What version should I set gradle to? How do I go back to java 8, as I think there are bugs in java 14 which is causing issues with grails?
OK, figured it out.
First, I had to manually fix the java version.
To do this go to
$ /usr/libexec
$ ./java_home -V
This outputs one or more versions:
14.0.2, x86_64: "Java SE 14.0.2" /Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home
1.8.0_131, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home
Now edit our .bash_profile and replace the JAVA_HOME line with the version you want, either the whole thing (1.8.0_131) or just the major (1.8) thusly:
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
Now when you open a new window, and do "java -version" you get 1.8, and when you do "grails -version" I finally get 4.0.4.
Yay!
The strange part is that just changing JAVA_HOME should not affect whats on the path, but it seems to. i.e. just setting JAVA_HOME should not affect what version of java is run when I type in "java", but it does. i.e. there is no line suchy as "PATH=$PATH:$JAVA_HOME/bin in muy bash_profile.

installation of package 'rmarkdown' had non-zero exit status

Im trying to update the Rmarkdown package in RStudio but am getting the following error
Warning messages:
1: running command '"C:/Program Files/R/R-3.2.3/bin/x64/R" CMD INSTALL -l "C:\Users\foo\Documents\R\win-library\3.2" C:\Users\foo\AppData\Local\Temp\RtmpUdFXnp/downloaded_packages/rmarkdown_0.9.2.tar.gz' had status 1
2: In utils::install.packages(c("rmarkdown"), repos = "https://cran.rstudio.com/", :
installation of package 'rmarkdown' had non-zero exit status
My Session Information is below
R version 3.2.3 (2015-12-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=German_Germany.1252 LC_CTYPE=German_Germany.1252 LC_MONETARY=German_Germany.1252
[4] LC_NUMERIC=C LC_TIME=German_Germany.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] tools_3.2.3`
I do not have admin rights on my PC in work but have installed other libraries into the mydocuments section of my PC without issue

Aptana version 3.4.2.201308081805 crash

I have Aptana version 3.4.2.201308081805 on Linux Mint 15 64bit
was open just once and now anytime when I want to start the Aptana crash
here is the one from a few crash log:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGBUS (0x7) at pc=0x00007fab6e08a938, pid=4403, tid=140373276522240
#
# JRE version: 7.0_25-b30
# Java VM: OpenJDK 64-Bit Server VM (23.7-b01 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libzip.so+0x4938] Java_java_util_zip_ZipFile_getZipMessage+0x8d8
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please include
# instructions on how to reproduce the bug and visit:
# https://bugs.launchpad.net/ubuntu/+source/openjdk-7/
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Don't use OpenJDK
Use Java 7 from the wbupd8 repository
sudo apt-add-repository ppa:webupd8team/java
Prerequirements
sudo apt-get install software-properties-common
If you got problems with SWT take a look at
Eclipse cannot load SWT libraries
I managed to fix this issue by removing openjdk and installing oracle jdk.
The step by step instruction is provided in the following article
http://www.wikihow.com/Install-Oracle-Java-on-Ubuntu-Linux
so far no crash in aptana.
FYI: I am using lubuntu

Resources