How can I enable remote debugging for SBT in windows? - scala

I would like to accomplish running the equivalent of this
sbt -jvm-debug 5005
However I don't seem to be able to pass in args in Windows. This is what I am seeing
>sbt -jvm-debug 5005
[info] Loading project definition from [myProject]
[info] Set current project to [myProject] (in build file myProject)
[error] Expected letter
[error] Expected symbol
[error] Expected '!'
[error] Expected '+'
[error] Expected '++'
[error] Expected ';'
[error] Expected end of input.
[error] Expected 'show'
[error] Expected '*'
[error] Expected '{'
[error] Expected project ID
[error] Expected configuration
[error] Expected key
[error] 5005
[error] ^
[error] Not a valid command: jvm-debug
[error] Not a valid project ID: jvm-debug
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: jvm-debug
[error] jvm-debug
[error] ^
I would like to be able to remote debug this application from Intellij. Any help would be great!

set SBT_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
sbt run
was the only working solution on Windows 7.

Seems like the Windows version of SBT doesn't define this functionality.
On Linux it is defined in the $SBT_HOME/sbt/bin/sbt-launch-lib.bash as
addDebugger () {
addJava "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=$1"
}
You can achieve the same result by setting the SBT_OPTS environmental variable on Windows.
Run SBT like this, to make the debugger listen on port 5005
set SBT_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005" && sbt

Currently, I'd downloaded the last updated sbt, exactly sbt 1.3.3 but when I want to enable debug in the project, I had the same problem as you. Investigating, I could see that I haven't this file (sbt-launch-lib.bash) in my own root C:\Program Files (x86)\sbt\bin so when I see in another machine, I could notice that sbt, It was 1.2.8 and yes it had the file that I mentioned before so I uninstalled sbt 1.3.3 and I installed sbt 1.2.8 and put in my project sbt -jvm-debug 9999 and it works.

Related

How to invoke plugin from command line (sbt beginner)?

Following https://scalameta.org/scalafmt/docs/installation.html I'm trying to reformat my Scala code via command line.
How to execute the scalafmt command ?
Loading sbt from the project can I invoke scalafmt ?
Using below returns error :
sbt:skeleton> scalafmt
[error] Not a valid command: scalafmt (similar: last)
[error] Not a valid project ID: scalafmt
[error] Expected ':'
[error] Not a valid key: scalafmt (similar: scalaHome, scalaArtifacts, scalaInstance)
[error] scalafmt
[error] ^
sbt:skeleton> my-project/scalafmt
[error] Expected ':'
[error] Not a valid key: scalafmt (similar: scalaHome, scalaArtifacts, scalaInstance)
[error] my-project/scalafmt
[error] ^
sbt:skeleton>
First I would suggest checking your project/plugins.sbt if it includes
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % scalaMetaVersion)
looks like it can't find scalafmt command.
Second run sbt plugins to check if it's enabled - you should have something like this: org.scalafmt.sbt.ScalafmtPlugin: enabled in skeleton

IntelliJ can't import sbt project

Error while importing sbt project:
d; set _root_.org.jetbrains.sbt.StructureKeys.sbtStructureOptions in Global := "download resolveClassifiers" ;*/*:dumpStructureTo /private/var/folders/5v/g3zxt_7d64g3sd_56bzpqbvh0000gn/T/sbt-structure.xml; session clear-all
[error] Expected ID character
[error] Not a valid command: d
[error] Expected 'debug'
[error] Expected project ID
[error] Expected configuration
[error] Expected ':' (if selecting a configuration)
[error] Expected key
[error] Not a valid key: d
[error] d; set _root_.org.jetbrains.sbt.StructureKeys.sbtStructureOptions in Global := "download resolveClassifiers" ;*/*:dumpStructureTo /private/var/folders/5v/g3zxt_7d64g3sd_56bzpqbvh0000gn/T/sbt-structure.xml; session clear-all
[error] ^
The error appeared after I upgraded the sbt version to sbt.version=0.13.16 in ./project/build.properties. Using sbt from the terminal works just fine.
Update: A workaround I found is to disable importing the project via the sbt shell.
Try deleting the target folder and running the commands again

object scalatest is not a member of package org [error] Cygwin

I was wondering if I could get some help with this one. I know there are many different issues with the same title, however, after following all the instructions (I hope), I could not get it to compile still. I've been at this for over 7 hours.
This is my issue. I am using Cygwin64 terminal to do some scala programming with sbt. I run the test and make sure that the test file is in the test folder but nothing is working. I have tried to compile it without the test file and then bring it back in but it does not work either.
$ sbt test
[info] Loading project definition from C:\cygwin64\home\Sam\hof\project
[info] Set current project to hof (in build file:/C:/cygwin64/home/Sam/hof/)
[info] Compiling 1 Scala source to C:\cygwin64\home\Sam\hof\target\scala-2.10\test-classes...
[error] C:\cygwin64\home\Sam\hof\src\test\scala\TestSuite.scala:3: object scalatest is not a member of package org
[error] class TestSuite extends org.scalatest.FunSuite {
[error] ^
[error] C:\cygwin64\home\Sam\hof\src\test\scala\TestSuite.scala:5: not found: value test
[error] test("map2 with add"){
[error] ^
[error] two errors found
[error] (test:compileIncremental) Compilation failed
[error] Total time: 3 s, completed Sep 19, 2016 1:07:10 AM
Is there anything I can do?
I had the same problem. Running sbt test in the project root gave me the object scalatest is not a member of package org error. But when I changed to src/test directory, it completed successfully.

sbt assembly is giving error

C:\scala\spark-1.6.1-bin-hadoop2.6\spark-1.6.1-bin-hadoop2.6>sbt assembly
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; su
port was removed in 8.0
[info] Set current project to spark-1-6-1-bin-hadoop2-6 (in build file:/C:/scal
/spark-1.6.1-bin-hadoop2.6/spark-1.6.1-bin-hadoop2.6/)
[error] Not a valid command: assembly
[error] Not a valid project ID: assembly
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: assembly
[error] assembly
[error] ^
Tried everything given on web,still unable to sort out this issue,any help/pointers please ...
"./sbt/sbt assembly" errors "Not a valid command: assembly" for Apache Spark project
above solution is also not working...
Problem is you have not added sbt-assembly plugin.
In windows, C:\Users\<username>\.sbt\0.13\plugins\plugins.sbt and add
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
then it will work. Explained here

How to install sbt-sh plugin

https://github.com/steppenwells/sbt-sh
I'm using sbt 0.13.9 and try to install sbt-sh with given instructions. However sbt does not recognize sh command:
> sh ls
[error] Expected ID character
[error] Not a valid command: sh
[error] Expected 'show'
[error] Expected project ID
[error] Expected configuration
[error] Expected ':' (if selecting a configuration)
[error] Expected key
[error] Not a valid key: sh
[error] sh ls
[error] ^
>
Instructions are for sbt 0.10, maybe things have changed since those days and this guide is out of date?
The instructions are a bit outdated. Instead of ~/.sbt/plugins/project, you should put the MyPlugins object in ~/.sbt/0.13/plugins/project/MyPlugins.scala.
However, sbt-sh doesn't seem to work, even with that correction:
[error] $HOME/.sbt/0.13/staging/1375c2d4ab8153e18523/sbt-sh/src/main/scala/org/sbtsh/SbtShPlugin.scala:4: object CommandSupport is not a member of package sbt
[error] import sbt.CommandSupport._
[error] ^
[error] one error found
[error] ({git://github.com/steppenwells/sbt-sh.git}sbt-sh/compile:compileIncremental) Compilation failed
Can you try xsbt-sh instead?
Create a file ~/.sbt/0.13/plugins/xsbt-sh.sbt with this content:
resolvers += "Element Releases" at "http://repo.element.hr/nexus/content/repositories/releases/"
addSbtPlugin("hr.element.xsbt" % "xsbt-sh" % "0.0.2")
The Github README refers to 0.1.0 but that doesn't seem to have been yet released to the repository.