mumoshu / play2-typescript

TypeScript assets handling for Play 2.0. Compiles .ts files under the /assets dir along with the project.
Other
74 stars 14 forks source link

doesn't work on Windows #5

Open jamesd8 opened 11 years ago

jamesd8 commented 11 years ago

I am running play 2.0.3 on Windows 7 64 bit.

I installed everything per your instructions and put a test .ts file in assets/javascripts. When I reload the page the plugin tries to compile it but fails on the external call to tsc. I checked and tsc is definitely in the system path (and runs from the same command window that I ran play from), so my best guess is that the scala ProcessBuilder doesn't use the system path by default.

If my guess is correct, then it might be useful to allow the specification of a tsc path in some appropriate config file.

If I'm doing something wrong, I'd love to know what it is. The call stack of the failure is:

[error] {file:/C:/work/project/}project/*:play-copy-assets: java.io.IOException: Cannot run program "tsc": CreateProcess error=2, The system cannot find the file specified
[error] application -

! Internal server error, for request [GET /] ->

play.api.UnexpectedException: Unexpected exception [IOException: Cannot run program "tsc": CreateProcess error=2, The system cannot find the file specified]
        at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4$$anonfun$apply$12.apply(PlayReloader.scala:233) ~[na:na]
        at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4$$anonfun$apply$12.apply(PlayReloader.scala:226) ~[na:na]
        at scala.Option.map(Option.scala:133) ~[scala-library.jar:0.11.3]
        at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4.apply(PlayReloader.scala:226) ~[na:na]
        at sbt.PlayReloader$$anon$2$$anonfun$reload$3$$anonfun$4.apply(PlayReloader.scala:224) ~[na:na]
        at scala.Either$LeftProjection.map(Either.scala:183) ~[scala-library.jar:0.11.3]
java.io.IOException: Cannot run program "tsc": CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessBuilder.start(Unknown Source) ~[na:1.6.0_32]
        at scala.sys.process.ProcessBuilderImpl$Simple.run(ProcessBuilderImpl.scala:68) ~[scala-library.jar:na]
        at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.run(ProcessBuilderImpl.scala:99) ~[scala-library.jar:na]

        at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.run(ProcessBuilderImpl.scala:98) ~[scala-library.jar:na]

        at net.litola.TypeScriptCompiler$.runCompiler(TypeScriptCompiler.scala:50) ~[na:na]
        at net.litola.TypeScriptCompiler$.compile(TypeScriptCompiler.scala:17) ~[na:na]
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessImpl.create(Native Method) ~[na:1.6.0_32]
        at java.lang.ProcessImpl.<init>(Unknown Source) ~[na:1.6.0_32]
        at java.lang.ProcessImpl.start(Unknown Source) ~[na:1.6.0_32]
        at java.lang.ProcessBuilder.start(Unknown Source) ~[na:1.6.0_32]
        at scala.sys.process.ProcessBuilderImpl$Simple.run(ProcessBuilderImpl.scala:68) ~[scala-library.jar:na]
        at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.run(ProcessBuilderImpl.scala:99) ~[scala-library.jar:na]

Thanks!

mumoshu commented 11 years ago

Hi,

Thanks for your report. I will check it but it will take some time as I don't own any Windows PCs.

Btw, would you please tell me which version of JDK you are using, 1.6 or 1.7?

jamesd8 commented 11 years ago

I'm running 64-bit Sun Java 1.6.0_32-b05. Let me know if I can help with some tests or what have you.

jamesd8 commented 11 years ago

It might also be that the windows command is "tsc.cmd", not "tsc". In the command window it is ok to type just tsc but all bets are off when calling from the Scala ProcessBuilder. Now that I think of it, that actually seems like the more likely culprit than the path. Would it be possible to try both "tsc" and "tsc.cmd" and only throw the exception if both fail?

mumoshu commented 11 years ago

Hi,

I have fixed the plugin to use "cmd /C tsc" when ran on Windows, which invokes "tcs.cmd" as you mentioned. The fix is available in 0.1.2-SNAPSHOT. Would you please try that and report if you find any problem?