Error in verifying sbt installation - scala

I am new to Scala and have just downloaded sbt on my Mac.
After installing using the following command -
brew install sbt
i am trying to verify that the installation completed successfully by running this command -
sbt --version
I am expecting something like -
sbt launcher version 0.13.0
but getting the following instead -
sbt --version
[error] Not a valid command: version (similar: session)
[error] version
[error] ^
I have tried to uninstall and reinstall sbt on my machine but in vain.
Can someone let me know what I could be missing here?
thanks!

SBT launcher script simply doesn't support --version. Run sbt -h to see supported options. To show the SBT version used for current project, run sbt "show sbtVersion".

Related

SBT main class "not" not found

I'm seeing a strange issue when trying to run sbt on any of my projects on my new Mac. These are known-good projects so it is likely to be something up with sbt on my new machine (installed using brew install sbt).
As you can see below something is "not[newline]found", which is leading to the "Could not find or load main class not" error. I can't tell what this is or why it is happening, has anyone seen this before?
sbt -v
[sbt_options] declare -a sbt_options='([0]="-Dsbt.jse.engineType=Node" [1]="-Dsbt.jse.command=node" [2]="not" [3]="found")'
[process_args] java_version = '8'
# Executing command line:
java
-Dfile.encoding=UTF-8
-Xms1024m
-Xmx1024m
-Xss4M
-XX:ReservedCodeCacheSize=128m
-Dsbt.jse.engineType=Node
-Dsbt.jse.command=node
not
found
-jar
/usr/local/Cellar/sbt/1.5.6/libexec/bin/sbt-launch.jar
Error: Could not find or load main class not
Thanks to #LuisMiguelMejíaSuárez for the answer that helped get this working.
Uninstalled brews version of sbt (brew uninstall sbt)
Installed coursier CLI (https://get-coursier.io/docs/cli-installation)
Installed sbt via coursier (cs install sbt).

sbt installation does not set up scala; cant run scala files

I followed instructions on this site because I didn't want to work with intellij.
With this installation, scala is not available as a command. How would I go about running .scala files?
Installing sbt doesn't get scala REPL for you. If you have sbt in your PATH variable, then you can use sbt console command to do and verify simple scala commands.
Otherwise you need to install scala separately.
The easy way to install scala and sbt is to use sdkman. Follow steps here.
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install sbt
sdk install scala

sbt is installed but not found

Fedora 25. sbt is installed and I have been using it, probably last time was a week ago. But today it is not found.
$ sbt
bash: sbt: command not found...
Install package 'sbt' to provide command 'sbt'? [N/y]
Tried a reinstall but dnf knows what I do
$ sudo dnf install sbt
[sudo] password for xxx:
Last metadata expiration check: 0:31:12 ago on Thu Apr 27 19:39:34 2017.
Package sbt-0.13.15.2-2.noarch is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!
Checked for install location with which but no luck
$ which sbt
/usr/bin/which: no sbt in (/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/xxx/.local/bin:/home/xxx/bin)
I would guess the problem is in my $PATH however I have not altered it, although I have installed some packages
$ echo $PATH
/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/home/xxx/.local/bin:/home/xxx/bin
Finally i did find a jar named sbt-launch.jar in /usr/share/sbt/bin/ but I don't think /usr/share has ever been part of my $PATH.
Recommendations? thx
fixed it by running
$dnf reinstall sbt
Out of curiosity I checked $PATH again afterwards and it was the same. So it was something else evidently.
I have resolved it reinstalling:
First, uninstall sbt:
yum remove sbt
Then download the version you want from https://dl.bintray.com/sbt/debian/
wget http://dl.bintray.com/sbt/rpm/sbt-0.13.16.rpm
And install by yum
sudo yum install sbt-0.13.16.rpm
Check it with sbt about
sbt about
It must show you similar to
sbt about
[info] This is sbt 0.13.16
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.6

How to install an older version of scala

I currently had installed scala 2.11.7 but in order to fix this issue, I have to install a older version of scala(2.10.5). When I try to install with brew, I keep getting the following error
Error: No available formula for 2.10.5
I tried downloading the binaries for scala download page but when I load the SDK and all the libraries in IntelliJ, I just get this error
Error:scalac: No 'scala-library*.jar' in Scala compiler classpath in Scala SDK scala-sdk-2.10.5
So what is the right way to install an older version of scala and setting the same in intellij
The following should work for Homebrew 0.9.5:
Install Tapped version of Scala 2.10
brew install homebrew/versions/scala210
Unlink version of Scala 2.11 (if installed)
brew unlink scala
Link Tapped version of Scala 2.10
brew link scala210 --force
Check scala version
scala -version
brew search scala
then you will find all the available versions like below
scala scala#2.10 scala#2.11 scalaenv scalariform scalastyle
homebrew/science/scalapack Caskroom/cask/scala-ide
Then choose whichever version you want to install. say if you want to install scala 2.11 then you can do that by runnig the command like below
brew install scala#2.11
If you manage your project with sbt, the scala built tool, either directly or via IntelliJ, the version of scala for that code is defined in the build file (build.sbt or Build.scala):
scalaVersion := "2.10.5"
Choosing this path, there isn't even a need to install scala on your Mac at all. Each project will have its own version -- pulled from your local ivy repository, so it doesn't have to download it each time.
And rather than typing scala to get to the REPL, you type sbt console to get to the REPL with the project's scala version and dependencies loaded.
Homebrew installs scala 2.10.5 with the formula scala210:
$ brew install scala210
==> Installing scala210 from homebrew/homebrew-versions
==> Downloading https://homebrew.bintray.com/bottles/scala210-2.10.5.yosemite.bottle.tar.gz
==> Downloading http://www.scala-lang.org/files/archive/scala-2.10.5.tgz
######################################################################## 100,0%
However, if you are using a build tool like maven or sbt, you should be able to set another scala version in your build config. You should then be able to import your project into IntelliJ and IntelliJ should automatically use the dependencies defined in your build config.
Using brew to install specific version:
$ brew search scala
==> Formulae
scala scala#2.10 scala#2.11 scalaenv
scalapack scalariform scalastyle
==> Casks
scala-ide
Make sure you default version in profile
$echo 'export PATH="/usr/local/opt/scala#2.11/bin:$PATH"' >> ~/.bash_profile

Could not retrieve sbt 0.13.9 on fresh Ubuntu install

After a fresh install of Ubuntu 15.04, I attempted to install and run SBT using the instructions from www.scala-sbt.org. It installed fine, but when I run it for the first time, I get a bunch of errors:
~$ sbt
...
:::: ERRORS
Server access Error: java.lang.RuntimeException: Unexpected error:
java.security.InvalidAlgorithmParameterException: the trustAnchors
parameter must be non-empty
url=https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.jar
:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
unresolved dependency: org.scala-sbt#sbt;0.13.9: not found
Error during sbt execution: Error retrieving required libraries
(see /root/.sbt/boot/update.log for complete log)
Error: Could not retrieve sbt 0.13.9
What is going wrong?
I have had same problem with xubuntu 15.10. I installed package ca-cacert:
sudo apt-get install ca-cacert
It solved this problem.
After a bit of debugging, I found that the cacerts file is missing from the latest version of OpenJDK.
All I had to do was copy the cacerts file from /etc/ssl/certs/java/cacerts from a working computer to my new workstation, and it worked fine.
I've made my file available at this link.