3
votes

I have installed scala, sbt on Mac. When I try to run sbt it gives an error Unrecognized VM option 'CMSClassUnloadingEnabledn-J-Xmx2Gn'. I think there is an issue with JVM but could not find any help for this error.

More error info: Did you mean '(+/-)CMSClassUnloadingEnabled'? Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.

2
Try to execute: echo $SBT_OPTS and paste it in this answer - chengpohi
echo $SBT_OPTS does not show anything - Viktor
After I uninstalled sbt, manually removed sbtopts and sbtopts.default in the /usr/local/etc, then installed sbt again, it works ok. It looks like the issue was that during the initial installation I ran this command: echo '-J-XX:+CMSClassUnloadingEnabled\n-J-Xmx2G\n' >> /usr/local/etc/sbtopts - Viktor

2 Answers

2
votes

I faced the same issue after I ran the command I ran this command: echo '-J-XX:+CMSClassUnloadingEnabled\n-J-Xmx2G\n' >> /usr/local/etc/sbtopts. It seems the file /usr/local/etc/sbtopts contained both options in same line, separated by \n, i.e. the actual contents of the file were -J-XX:+CMSClassUnloadingEnabled\n-J-Xmx2G\n

The solution was to remove \n by editing this file, and pressing enter key instead, so that the contents of file /usr/local/etc/sbtopts look the way David mentioned in his response.

1
votes

My guess is that the sbt configuration is confused with regards to line breaks and mangles something like

-J-XX:+CMSClassUnloadingEnabled
-J-Xmx2G

into one line