简体   繁体   中英

Trying to run a scala script, conscript errors when install “sbt/sbt”

I'm trying to install sbt/sbt with conscript on OSX

cs sbt/sbt --branch 0.13.8

following the sbt doc: http://www.scala-sbt.org/release/docs/Scripts.html

I got the following errors:

.......

[SUCCESSFUL ] org.scala-sbt#apply-macro;0.13.6!apply-macro.jar (4702ms)
:: retrieving :: org.scala-sbt#boot-app
    confs: [default]
    44 artifacts copied, 0 already retrieved (13750kB/113ms)
[error] Not a valid command: version (similar: session)
[error] version
[error]        ^
[error] Not a valid command: version
[error] version
[error]        ^
[error] Not a valid command: version
[error] version
[error]        ^

Conscripted sbt/sbt to ~bin/sbt
Conscripted sbt/sbt to ~/bin/scalas
Conscripted sbt/sbt to ~/bin/screpl

scalas and screpl seem installed correctly? But, when I tried to execute the following script helloworld.scala ,

#!/usr/bin/env scalas

/***
scalaVersion := "2.11.6"
*/

println("hello")

I got errors like:

>./helloworld.scala
~ ./helloworld.scala:5: error: eof expected but ';' found.
  */
^
[error] Error parsing expression.  Ensure that settings are separated by blank lines.

Another script example test.scala :

#!/usr/bin/env scalas

/***
scalaVersion := "2.11.6"
libraryDependencies += "net.databinder.dispatch" %% "dispatch-core" % "0.11.2"
  */
import dispatch._, Defaults._
case class Location(city: String, state: String)
    def weatherSvc(loc: Location) = {
      host("api.wunderground.com") / "api" / "5a7c66db0ba0323a" /
        "conditions" / "q" / loc.state / (loc.city + ".xml")
    }
    val nyc = Location("New York", "NY")
    for (str <- Http(weatherSvc(nyc) OK as.String))
      println(str)

I got errors like:

./test.scala:18: error: not found: value Location
val nyc = Location("New York", "NY")
          ^
./test.scala:14: error: not found: value host
  host("api.wunderground.com") / "api" / "5a7c66db0ba0323a" /
  ^
./test.scala:13: error: not found: type Location
def weatherSvc(loc: Location) = {
                    ^
sbt.compiler.EvalException: Type error in expression
    at sbt.compiler.Eval.checkError(Eval.scala:384)
......

Could anybody suggest?

It turns out the whitespace( " */" ) in the head of last comment line failed. IntelliJ automatically add space to prettify the comments (or is it scala convention to add whitespace?) but scalas doesn't strip it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM