sbt new not a valid command - scala

I am going through a coursera course and as explained, I am trying to create a new sbt project using the below command:
sbt new scala/hello-world.g8
In a Windows machine. I have sbt 0.13.8 installed. When executing the command it is giving the below error.
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Set current project to workspaces (in build file:/D:/software%20materials%20workspaces/WorkSpaces/)
[error] Not a valid command: new (similar: set)
[error] Not a valid project ID: new
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: new (similar: name, run, runner)
[error] new
[error] ^
I am not able to understand what the problem is. Help me out in understanding and solving this problem

I agree with Seth. It looks like the first version to include new is 0.13.13. I just came across this in creating new apps with more recent versions of the Scala Play framework (ex: 2.5). The github templating command line, giter8, is called via sbt new like this:
sbt new scala/scala-seed.g8

On my Mac I ran into a similar issue and fixed it by updating brew (used to install) then updating sbt:
brew update
brew upgrade sbt
First step was needed so the latest sbt could install. If whatever package manager you are using is out of date, it may result in the same problem. Not sure what Windows needs to install but this may help with others landing on this question.

Related

Compilation error in the Scala/Play example application for Heroku using Intellij

I am trying to compile the scala/Play framework example application on my local machine, but I am getting compilation errors when trying to compile using the SBT console in IntelliJ:
error: scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
I also got this message in the event log related to different SBT versions:
14:48 Started sbt shell with sbt version 0.13.18 instead of 0.13.11 configured by project.
Update sbt version
Disable version override
Any suggestions on how to fix this?
For the first error
error: scala.reflect.internal.MissingRequirementError: object java.lang.Object in compiler mirror not found.
You might want to try and ensure that you are using a compatible java version. Like #cbley suggested, try making you are using version 8 of the JDK.
For the second error
14:48 Started sbt shell with sbt version 0.13.18 instead of 0.13.11 configured by project.
Update sbt version
Disable version override
Its just suggesting you update the version of sbt (which is most likely declared in your build.properties file in a folder called project. You can just search for it by double tapping shift in IntelliJ. But you are safe to ignore it if you cloned some example repository as well.
check

Trying to install SBT-0.13.8 for Windows 7 installs SBT version 0.12.4

I have (multiple times) tried to install SBT-0.13.8 from the SBT download page via the SBT-0.13.8-MSI button and I always end up getting an SBT version which shows the following output
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[info] Loading project definition from C:\Users\Tina\Desktop\example\project\project
error: error while loading CharSequence, class file 'C:\Program Files\Java\jre1.
8.0_20\lib\rt.jar(java/lang/CharSequence.class)' is broken (bad constant pool tag 15 at byte 1470)
[error] Type error in expression
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? i
[warn] Ignoring load failure: no project loaded.
> about
[info] This is sbt 0.12.4
[info] No project is currently loaded
[info] sbt, sbt plugins, and build definitions are using Scala 2.9.2
SBT produces an error message and (!) shows itself as version 0.12.4.!!!
I really made sure that I have no other version of SBT installed and I even made a reboot before re-installing it but nothing changed. SBT files have a creation date of March, 21, 2015. This seems to be the newest version but why does this version show up as 0.12.4 and does not work with JDK1.8?
Looks like the directory you're in is wrong, you want to launch sbt from C:\Users\Tina\Desktop\example\project not C:\Users\Tina\Desktop\example\project\project (note 1 project less).
The second problem you're having is you're trying to use sbt 0.12.4 with Java 8. sbt 0.12.4 uses (as can be seen from the output) Scala 2.9.2 which doesn't work with Java 8. I would recommend migrating to sbt 0.13.8, but if not you could always downgrade to Java 7.
Edit after comments below
The progfun Coursera course download is still configured with sbt
0.12.4 which you're having trouble building because you are using Java 8.
I had a quick go at trying to see if upgrading the project to 0.13.8 would work (FYI it involves editing project/build.properties), but then plugins need to be upgraded, then meta-build code needed to be changed because of namespace changes..
Unless you're willing to experiment more and work you're way through the various changes required to use latest sbt and latest Java (which is what I would do if this were for myself), I would recommend as an alternative to:
Downgrade to Java 7
Notify the relevant people involved in running the course that the source material should be updated as it demonstrably does not work on latest, stable Java.
If your default Java is Java 8 but you want to switch to Java 7 for this out-of-date project setup, you need to create an .sbtopts file at the root of the project containing (note: on separate lines!):
-java-home
C:\Users\Tina\PATH\TO\YOUR\JAVA\HOME

"dist" command gets "not a valid command" error

I have a working Play Framework 2.1 application generated with typesafe activator that I've developed in Scala. I'm trying to deploy it in CloudBees using the instructions that can be found here: http://wiki.cloudbees.com/bin/view/RUN/Playframework#HDeployingaPlay2application using the method described under "Using Cloudbees SDK."
However, when I load up the play console and try to run the "dist" command, I get the error "Not a valid command: dist."
I've tried two run this three different ways:
In the terminal window (I'm using Mac OS X), I navigated to the project directory, ran the "activator" application (there is no application in that directory called "play", but "activator" seems to be the), then from the prompt that appears I enter the command "dist."
I downloaded the regular (non-activator) Play Framework distirbution file, add the directory to my path using "export PATH=$PATH:/Applications/play-2.2.2", navigated to the project directory, and ran the command "play dist."
Installed play using Homebrew. Navigated to the project directory and ran "play dist".
All three methods give me the same error (see below). Is the method different for my version of play? Am I missing something from the sbt file? How can I get this working?
Full output for "play dist":
Macmini-##########-#:nimrandslibrary.searchfu.esl kpyancey$ play dist
[info] Loading project definition from /Users/kpyancey/Projects/NimrandsLibrary.SearchFu.Esl/project
[info] Set current project to NimrandsLibrary.SearchFu.Esl (in build file:/Users/kpyancey/Projects/NimrandsLibrary.SearchFu.Esl/)
[error] Not a valid command: dist (similar: set, iflast, last)
[error] Not a valid project ID: dist
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: dist (similar: test, ivy-sbt, history)
[error] dist
[error] ^
I think you have misconfigured something in your project.
To double check, generate a new project from Activator or try downloading https://github.com/CloudBees-community/play2-clickstart (which is correctly configured) and run play dist.

Just downloaded the Scala Lift chat application and use the instructions to run it, but it fails

I cloned the project from:
https://github.com/dpp/simply_lift.git
Then I followed the instructions which state:
Change directories into the chat directory and type sbt update ~jetty-run.
SBT fetches dependencies, and then I get this:
[error] Not a valid command: jetty-run
[error] Expected '/'
[error] Expected ':'
[error] Not a valid key: jetty-run (similar: run)
[error] jetty-run
[error]
Now what?
In versions of SBT newer than 0.10.0, ~jetty-run has been removed in favour of:
container:start
container:stop
deployment // compiles the changes made while jetty is running.
You should've used sbt from the packaged archive (./sbt). Instead of a system-wide SBT (which may be new).
Anyway, I suggest to use use the new SBT and everything new, too. This is the official and good starting point for a project: https://github.com/lift/lift_25_sbt/
(personally I use it and I'm cool with how it works)

Need a better "getting started" guide for Lift

I have used Scala for about a year and now want to get into Lift.
Following the official site, I got the guide at http://simply.liftweb.net/index-Chapter-2.html#toc-Chapter-2
However, the example does not work. Here is the error I get.
C:\Lift\hello>sbt update ~jetty-run
C:\Lift\hello>set SCRIPT_DIR=C:\scala\bin\
C:\Lift\hello>java -Xmx512M -jar "C:\scala\bin\sbt-launch.jar" update ~jetty-run
[info] Set current project to default-7944be (in build file:/C:/Lift/hello/)
[success] Total time: 0 s, completed 22 Feb, 2012 3:41:06 PM
[error] Not a valid command: jetty-run
[error] Not a valid project ID: jetty-run
[error] Not a valid configuration: jetty-run
[error] Not a valid key: jetty-run (similar: run)
[error] ~jetty-run
[error] ^
I have not used sbt before and prefer not to get sidetracked by having to learn sbt, maven or other stuff. I essentially want a "hello" world application (in this case, the chat application) to start up and running before I do any more digging into Lift.
It is unfortunate that the very first example in the official "getting started" guide is broken. Any ideas what the errors are. I tried the method suggested at http://groups.google.com/group/simple-build-tool/browse_thread/thread/60635edfadbcd816 without any luck
UPDATE
If what you want is just a "hello" world Lift application, I will suggest you download the official Lift 2.4 release here.
After you unzip that file, just cd scala_28\lift_blank or cd scala_29\lift_blank according to what Scala version you would like to use.
Then run sbt update ~jetty-run, this release included correct version and SBT start script for windows.
After this, you should able to browse http://localhost:8080 and get a single web page that has current date and time displayed, a typical Hello World program for web framework.
It seems you are using SBT 0.11 but Simply Lift is using SBT 0.7.x.
SBT has been made a lot of changes from 0.7.x to 0.11, there is no jetty-run command in 0.11.
You should download old SBT version if you just want it work and do not care using a old version SBT.
http://code.google.com/p/simple-build-tool/downloads/list
I think 0.7.7 will work.
It seems like you don't have ./ on your path. I believe all you need to do is go into the chat folder and use the command "./sbt update ~jetty-run" instead of "sbt update ~jetty-run".
It's and old question, but I haven't found that solution anywhere yet:
Seems like in lift 2.5 you should do container:start instead of ~jetty-run, so:
./sbt[enter]
update[enter]
container:start[enter]
My chat app was on http://0.0.0.0:8080
Install SBT 0.11+
Create a folder and follow instructions http://www.assembla.com/wiki/show/liftweb/Using_SBT
Copy src folder of https://github.com/lift/lift_24_sbt/tree/master/scala_29/lift_blank (or lift_basic) in your project folder
cd to your project folder and run sbt.
container:start will start server, container:stop to stop
OR use lifty