Downloading Scala issues - scala

So I need to download scala for one of my classes. I am using a mac pro and the command line to do so.
I downloaded sbt using homebrew which worked fine.
After these are the directions given:
Install the SBT plugin:
mkdir ~/.sbt
mkdir ~/.sbt/0.13
mkdir ~/.sbt/0.13/plugins
echo 'addSbtPlugin("edu.umass.cs" % "cmpsci220" % "3.0.0")' > ~/.sbt/0.13/plugins/plugins.sbt
To verify that everything is installed, I have to type 'sbt' to start SBT. Once typed, I should see output that looks like this:
[info] Loading global plugins from /Users/arjun/.sbt/0.13/plugins
[info] Updating {file:/Users/arjun/.sbt/0.13/plugins/}global-plugins...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] downloading https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/edu.umass.cs/cmpsci/scala_2.10/sbt_0.13/3.0.0/jars/cmpsci.jar ...
[info] [SUCCESSFUL ] edu.cs#cmpsci;3.0.0!cmpsci.jar (1261ms)$
However, My issue is that once I type 'sbt' to verify things I get this line:
[info] Set current project to home (in build file:/Users/home/)
It asks me for a command. I have tried 'run', 'test', 'update'. They all run fine but it keeps asking me a command.
My goal is to get to the 'sbt console' so I can run scala, import packages, scripts, etc..
Any ideas on what the issue is?

You need to be in the folder of your SBT project to do sbt run.
First cd into it, then sbt run to run it (or sbt test or whatever :))

Type console at the sbt prompt.
Edit:
So actually, why do you think this is what you want? Are you trying to run scala code that you're given? Or are you trying to write scala code? If the latter, you should download intellij and the scala plugin.

Please make sure there is a scala file in the directory you run sbt.
You may also check this for others: http://www.scala-sbt.org/0.13/docs/Hello.html

Related

Tasks stuck with sbt 1.0

Following the "https://www.coursera.org/learn/scala-spark-big-data/supplement/R7FJ9/eclipse-tutorial" course, I'm trying to create a eclipse project from sbt, by adding sbteclipse plugin.
sbt new scala/hello-world.g8
cd hello-world
echo 'addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0")' > project/plugins.sbt
sbt> eclipse
It should last a minute and return several successful, but instead it stay still, it gets stuck. The message I've received is
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
I've installed sbt 1.0.2, it fails, then I'd install sbt 0.13.16 and still fails. Checking the sbt version it says it's 1.0.2 (although I'd uninstalled sbt 1.0.2 to install the older version).
checking https://github.com/typesafehub/sbteclipse/issues/346 it seen like this is a brand new issue, it's supose the gets fix by typing sbt.version=0.13.16 in project/build.properties, but even after that the problem persist. I don't know if problem persist because is a fix for Mac and I'm working on windows 10, or if the solution saids is for sbt.version=0.13.15 and I'm using sbt.version=0.13.16.
Checking the \scala hello world\hello-world\eclipse file it says:
[error] [C:\Users\israel.rodriguez\Documents\eclipse\scala hello world\hello-world\project\plugins.sbt]:1: unclosed character literal
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
Terminate batch job (Y/N)?
checking the \scala hello world\hello-world\project\plugins.sbt I found :
'addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0")'
when removing the ' ' at the beginning and the end. the \scala hello world\hello-world\eclipse file saids :
[info] Loading project definition from
C:\Users\israel.rodriguez\Documents\eclipse\scala hello
world\hello-world\project
[info] Set current project to hello-world (in build file:/C:/Users/israel.rodriguez/Documents/eclipse/scala%20hello%20world/hello-world/)
and it remain there for eternity. with the same message on windows shell :
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option
MaxPermSize=256m; support was removed in 8.0
My question is, what's wrong over here? ,and how can I solve or work around this. Sorry for the rookie question, is my firt time with sbt, scala or spark.
I was in exact same scenario with the same problem as mentioned above. Here is how I overcame it.
Firstly there is no problem in steps that you follow everything is correct except:
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0")
Use latest version for the sbt plugin form, which is:
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")
The latest version handles the hanging console problem as described here, also there is no need to use '' at the beginning and the end.
Step: 1. Download and install sbt from here (windows sbt-1.0.4.msi)
Step 2. Go to cmd prompt and type sbt about, it will display something like this
C:\Users\rajnish.kumar>sbt about
"C:\Users\rajnish.kumar\.sbt\preloaded\org.scala-sbt\sbt\"1.0.4"\jars\sbt.jar"
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[warn] Executing in batch mode.
[warn] For better performance, hit [ENTER] to switch to interactive mode, or
[warn] consider launching sbt without any commands, or explicitly passing 'shell'
[info] Loading project definition from C:\Users\rajnish.kumar\project
[info] Set current project to rajnish-kumar (in build file:/C:/Users/rajnish.kumar/)
[info] This is sbt 0.13.15
[info] The current project is {file:/C:/Users/rajnish.kumar/}rajnish-kumar 0.1-SNAPSHOT
[info] The current project is built against Scala 2.10.6
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, sbt.plugins.Giter8TemplatePlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.6
I'm not sure why it says "This is sbt 0.13.15"; if anybody knows please answer it here.
Step 3. Go to your workspace form cmd prompt and type and hit sbt new sbt/scala-seed.g8, type project name as (e.g. hello) when asked.
Step 4. Now move to your project directory i.e cd hello
Step 5. Now type echo addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4") > project/plugins.sbt
Step 6. Make sure you are inside the hello project and then instead of calling sbt > eclipse (if you will do like this way then it will get stuck in the same infinite loop as you're getting) only call sbt and it will start the server on default port.
Step 7. Now type eclipse, now it will start downloading all dependency, eventually it will show Successfully created Eclipse project files for project(s):
Step 8. Import project (hello) to Eclipse as normal and it will work. Please not do not call sbt > eclipse in single go call them one by one first call sbt and when server is started then only call Eclipse.
I had the same issue when I start reading about scala.
Concerning the problem of [\plugins.sbt]:1: unclosed character literal] use :
echo addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0") > project/plugins.sbt
Remove the simple quote from the begining and the end of the echo first parameter
I had the very same issue as you describe. I use Windows 10 and wonder if it just occurs on that system.
It works if I use sbteclipse 5.2.4 and some other small modifications:
cd hello-world
echo 'addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")' > project/plugins.sbt
Next, I need to go to project/plugins.sbt and remove the ' at the beginning and end of the line.
Now, do NOT enter sbt > eclipse! This will just pipe the sbt console into a the newly created file and you won't execute eclipse. Instead, typ the following into the command line:
sbt eclipse

In an sbt 0.13.7 project, compile the compiler-interfaces without compiling the project code

In a freshly checked out sbt ( 0.3.7 ) project and empty ivy cache, is it possible to trigger compilation of the compiler-interface(s) needed without compiling the project itself? I have poked around but haven't found a way.
Currently if a compiler-interface is required it will be created during compilation of the project. I would like to have this compiled directly in a separate command if possible. This would allow CircleCi to cache it saving 1-3 minutes with every build because it could be cached in the dependencies section of the circle.yml.
In sbt 0.13.12 compile:compileIncremental seems to do the trick. I ran inspect compile and inspected its dependencies to find the command.

sbt console doesn't allow input

I've been trying to use sbt for one of my projects, however I've ran into the following problem - when I try to use sbt console to get the scala's REPL, it just doesn't allow any input. Example session:
[lared#lt foo]$ sbt
[info] Set current project to foo (in build file:/tmp/foo/)
> console
[info] Updating {file:/tmp/foo/}foo...
[info] Resolving org.scala-lang#scala-reflect;2.10.3 ...
[info] Done updating.
[info] Starting scala interpreter...
[info]
Welcome to Scala version 2.10.3 (OpenJDK 64-Bit Server VM, Java 1.8.0_25).
Type in expressions to have them evaluated.
Type :help for more information.
scala>
I can not type anything. It doesn't seem to take much RAM/CPU time. The problem is reproducible in any directory, regardless of if it does have a proper project structure (for example the SBT Hello World tutorial) or not.
I'm using sbt 0.13.1 and the JDK/Scala versions as seen above on Fedora 21.
The problem was solved by deleting ~/.ivy2/ and (perhaps unrelated) migration to Oracle Java 1.7 SDK.
I could not find a way to get the Fedora 24 installed sbt 0.13.1 console to work either so I downloaded the latest sbt (currently 0.13.12), unzipped into /opt and add the sbt binary to my path before /usr/bin/sbt.
The earlier suggestion to delete ~/.ivy2 did not work for me.

How to run Lift's 'Ecommerce example' app

I'm new to Scala and Lift and SBT. I've cloned Ecommerce example from Lift's sample applications.
Now I want to simply run the application.
Documentation says, that container:start should start the app. But I'm getting error:
> container:start
[error] No action named 'container:start' exists.
[info] Execute 'help' for a list of commands or 'actions' for a list of available project actions and methods.
[info]
[info] Total time: 0 s, completed 25.05.2013 16:47:05
I guess that maybe it's because version difference.
[info] using LiftProject with sbt 0.7.5 and Scala 2.7.7
How can I start this application ?
And if it's caused by version difference is it possible to upgrade the application to latest sbt and scala version ?
Update
I've tried to use jetty-start and received another error:
> jetty-start
[error] No action named 'jetty-start' exists.
[info] Execute 'help' for a list of commands or 'actions' for a list of available project actions and methods.
I've also found another similar command jetty-run from sbt help. When I run it I'm getting a huge number of compilation errors. It seems like my scala 2.9.2 cannot compile the code.
This project, as far as I see, uses the old SBT version. The old way to start the web application is:
./sbt
> jetty-start
if you want to reload the app on source change, use ~ jetty-start
Note that there's a far more up to date liftweb project example here: https://github.com/lift/lift_25_sbt
probably sbt did not download the requried jar files.
run the following command
> sbt
> update
now sbt should download the requried jar files
>jetty-run
now sbt should compile and run the web-app.

(/home/user/.sbt) has been deprecated. Please use the standard location: /home/user/project?

When I start the sbt console I get this:
alex#alex-K43U:~$ sbt console [warn] Alternative project directory
.sbt (/home/alex/.sbt) has been deprecated since sbt 0.12.0. [warn]
Please use the standard location: /home/alex/project [info] Loading
project definition from /home/alex/.sbt [info] Set current project to
default-22b2b7 (in build file:/home/alex/)
I just started using scala and sbt, so I'm not really sure what the warning means. It means that I have to move all the content of /home/alex/.sbt to /home/alex/project?
(I have this folder too: /home/alex/sbt which has a bin folder and a jansi-license.txt file. I think that's how I installed sbt).
You can run sbt from any dedicated folder besides your home to get rid of this warning.
This warn appears because you run sbt from the directory that contains the .sbt folder, that in your case is /home/alex/.sbt
Create a folder (named project or something else) inside /home/alex/ and run sbt from there. Don't move the .sbt data inside the new folder because the warn will appear again.