ScalaBuff icon indicating copy to clipboard operation
ScalaBuff copied to clipboard

unable to "sbt run", No main class detected

Open alanngai opened this issue 11 years ago • 9 comments

I'm trying to use scalabuf to generate scala code from protofiles, but I'm having trouble getting it to even run. I'm using scala 2.10.3, sbt 0.13.1, and java 1.7.0_21

after checking out the repo,

$ sbt run Loading /Users/alan/dev/sbt-0.13.1/bin/sbt-launch-lib.bash [info] Loading project definition from /Users/alan/work/cloudmon/dev-master/ProtoServer/tools/protobuf-src-gen/src/github.com/SandroGrzicic/ScalaBuff/project [info] Set current project to scalabuff (in build file:/Users/alan/work/cloudmon/dev-master/ProtoServer/tools/protobuf-src-gen/src/github.com/SandroGrzicic/ScalaBuff/) java.lang.RuntimeException: No main class detected. at scala.sys.package$.error(package.scala:27) [trace] Stack trace suppressed: run last scalabuff/compile:run for the full output. error No main class detected. [error] Total time: 0 s, completed Jan 17, 2014 5:15:12 PM

so I ran sbt again to enter the console and ran the following to get the stack trace

run java.lang.RuntimeException: No main class detected. at scala.sys.package$.error(package.scala:27) [trace] Stack trace suppressed: run last scalabuff/compile:run for the full output. error No main class detected. [error] Total time: 0 s, completed Jan 17, 2014 5:17:10 PM last scalabuff/compile:run java.lang.RuntimeException: No main class detected. at scala.sys.package$.error(package.scala:27) at sbt.Defaults$$anonfun$runTask$1$$anonfun$apply$36$$anonfun$apply$37$$anonfun$26.apply(Defaults.scala:655) at sbt.Defaults$$anonfun$runTask$1$$anonfun$apply$36$$anonfun$apply$37$$anonfun$26.apply(Defaults.scala:655) at scala.Option.getOrElse(Option.scala:120) at sbt.Defaults$$anonfun$runTask$1$$anonfun$apply$36$$anonfun$apply$37.apply(Defaults.scala:655) at sbt.Defaults$$anonfun$runTask$1$$anonfun$apply$36$$anonfun$apply$37.apply(Defaults.scala:654) at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47) at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42) at sbt.std.Transform$$anon$4.work(System.scala:64) at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237) at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237) at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18) at sbt.Execute.work(Execute.scala:244) at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237) at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237) at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160) at sbt.CompletionService$$anon$2.call(CompletionService.scala:30) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) at java.util.concurrent.FutureTask.run(FutureTask.java:166) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:722) error No main class detected.

alanngai avatar Jan 18 '14 01:01 alanngai

figured out the command should be

sbt 'project scalabuff-compiler' 'run --proto_path=.. --scala_out=...'

would be nice to see this in the documentation

alanngai avatar Jan 18 '14 02:01 alanngai

Actually, by default you should be in the scalabuff-compiler project already. I'm guessing this is due to some change in sbt that I need to fix (probably add a default project). Please reopen the ticket, I need to fix the problem. Thanks for the report!

Also you can try using sbt-scalabuff (linked to from the readme) for easier generation in your existing sbt project. On 18 Jan 2014 03:00, "Alan Ngai" [email protected] wrote:

Closed #76 https://github.com/SandroGrzicic/ScalaBuff/issues/76.

— Reply to this email directly or view it on GitHubhttps://github.com/SandroGrzicic/ScalaBuff/issues/76 .

SandroGrzicic avatar Jan 18 '14 07:01 SandroGrzicic

re-opening as requested

alanngai avatar Jan 18 '14 08:01 alanngai

@SandroGrzicic I'm facing the same issue while compiling .proto files with following command,

> run --proto_path=src/main/resources/ --scala_out=src/main/scala/code/model/

from sbt-project$ ./sbt.

References

Usage examples

prayagupa avatar Mar 17 '14 09:03 prayagupa

Me too - with an old version (1.2.0) though - and when I use the command above : sbt 'project scalabuff-compiler' 'run --proto_path=.. --scala_out=...'

I runs, confirms a successful run, but does not generate any scala classes

Vipuls-MacBook-Pro-3:ScalaBuff-1.2.0 vipul$ sbt 'project scalabuff-compiler' 'run --proto_path=/path/to/proto/ --scala_out=/path/to/scala' [info] Loading project definition from /Users/.../ScalaBuff/1.2.0/ScalaBuff-1.2.0/project [info] Set current project to scalabuff-1-2-0 (in build file:/Users/.../ScalaBuff/1.2.0/ScalaBuff-1.2.0/) [info] Set current project to scalabuff-compiler (in build file:/Users/.../ScalaBuff/1.2.0/ScalaBuff-1.2.0/) [warn] Credentials file /Users/vipul/.ivy2/.credentials does not exist [warn] Credentials file /Users/vipul/.ivy2/.credentials does not exist [info] Running net.sandrogrzicic.scalabuff.compiler.ScalaBuff --proto_path=/path/to/proto/ --scala_out=/path/to/scala [success] Total time: 0 s, completed Apr 1, 2014 2:34:24 PM

but /path/to/scala has nothing in it

~Vipul

lupiv avatar Apr 01 '14 21:04 lupiv

btw same thing runs with 1.2.2

lupiv avatar Apr 01 '14 21:04 lupiv

Have you tried the latest version (1.3.7)?

SandroGrzicic avatar Apr 01 '14 21:04 SandroGrzicic

Oh yes, It works like a charm with 1.3.7 - the only problem is that I"m using this with Spark which comes packaged with Protobuf 2.4.1 and using 1.3.7 creates conflicts. I had no choice but to go back in time and get 1.2.*

lupiv avatar Apr 01 '14 21:04 lupiv

Sorry to hear that. Have you been able to resolve this? I'm hoping a newer release of Spark has a newer Protobuf.

SandroGrzicic avatar Feb 10 '15 02:02 SandroGrzicic