Reputation: 2043
I'm a rookie developer trying to run an application using play framework. I've followed the tutorial and can successfully create a new project.
However when I go to the directory that has the project I'm supposed to work on and enter the play command I get the following error:
[error] Not a valid command: play (similar: last, alias, loadp)
[error] Not a valid project ID: play
[error] Not a valid configuration: play
[error] Not a valid key: play (similar: clean)
[error] play
I have very little knowledge regarding the framework and don't know where to start correcting my mistake. Any suggestions ?
Upvotes: 6
Views: 7526
Reputation: 2937
I also got the same problem! What happened was in my /user/xxx/project folder there were old projects from 1.x version. Deleting that folder worked for me!
Upvotes: 0
Reputation: 1096
Depending on the language you're using, make sure one of the following is in your build.sbt file:
play.Project.playJavaSettings
play.Project.playScalaSettings
Upvotes: 0
Reputation: 1637
I am facing this problem in the context of sub projects.
This is what worked for me.
Code:
import sbt._
import sbt.Keys._
object ApplicationBuild extends Build {
val helloWorldProj = Project(id = "HelloWorld", base = file("helloworld"))
val appName = "WebApp"
val appVersion = "1.0"
val appDependencies = Seq()
val webAppProj = PlayProject( appName, appVersion, appDependencies, path = file("webapp"), mainLang = PlayProject.SCALA)
.dependsOn(helloWorldProj)
.aggregate(helloWorldProj)
}
On running the play
command, I get the following error:
Error:
[info] Set current project to HelloWorld (in build file:/D:/EclipseProjects/HelloWorldPlayMultiProject/)
[error] Not a valid command: play (similar: last, alias, loadp)
[error] Not a valid project ID: play
[error] Not a valid configuration: play
[error] Not a valid key: play (similar: play-hash, play-dist, play-conf)
[error] play
[error] ^
Solution:
Now, if I rename helloWorldProj
as zhelloWorldProj
, it works!
In this case, play
sets the active project to WebApp
.(Since webAppProj
variable name alphabetically comes before zhelloWorldProj
)
I can then change the active project to HelloWorld
by giving the command project HelloWorld
.
I think this has something to do with how sbt
finds the Project objects using reflection.
Upvotes: 2
Reputation: 2043
The problem was the version difference of play. The project I was suppose to work on was developed in play 1.2 where as I installed the version 2.0 .
By the way, working with 2.0 on a project developed by version 1.2 is possible, but I strongly recommend not to do it that way as there are problems on the later stages as well.
Upvotes: 0
Reputation: 21
I delete all directories in the project folder and it works. Do not delete files (build.properties, Build.scala and plugins.sbt)
Upvotes: 1
Reputation: 8578
You have to run the play command this way:
./play cmd [app_path] [--options]
where in case of running a project, it is
./play run /path/to/projectname
Upvotes: 3
Reputation: 54934
Need to have more detail about your environment (OS, Play version etc) but if you are getting errors that play is not a valid command, my first course of action would be to check that the path to play.sh (I assume you are using non-windows) is included in your system path?
Upvotes: 1