Closed gavinbaumanis closed 3 years ago
I ran into this problem as well. Twirl template compilation is broken in sbt 1.5.0 release candidates https://discuss.lightbend.com/t/apple-silicon-m1-playframework-broken-on-apple-silicon/7924/4?u=bpossolo
I tried to upgrade the Playframework to 1.5.0-RC1 which fails as well. These are the lines that causes the problem in twirl: https://github.com/playframework/twirl/blob/1.5.0/compiler/src/main/scala/play/twirl/compiler/TwirlCompiler.scala#L653-L656
@eed3si9n @eatkins Is this a bug in sbt 1.5.0-RC1 or is this something twirl has to fix?
Hi everyone I logged a bug #6400 for this;
As for is it a bug that twirl has to fix? (I realise it isn't always this straight forward) It works in SBT 1.4.9 but doesn't in 1.5.0- sure looks like a 1.5.0 issue to me.
As always thanks!
It's hard to tell whose bug it is.
Unlike scala-library, there's no binary compatibility guarantees between the patch versions of scala-compiler. So whenever you call the Scala compiler programmatically, it may or may not work when the Scala version changes. Play here is invoking the compiler programmatically:
val settings = new Settings
...
val origBootclasspath = settings.bootclasspath.value
It could turn out that sbt is doing some wrong to break Play, but if sbt 1.5.0 upgrading the Scala version we use internally to compile build.sbt
is the cause then I don't know if we should be responsible for debugging this. (Neither Ethan nor I work on sbt as day job).
for what it's worth, I've been completely blocked from working on my PlayFramework app partially because of this...
more specifically, playframework + sbt 1.4.* is broken on apple silicon because it uses the methvin file watcher which uses JNA which is broken atm. the maintainer of that library is unable to diagnose because he can't reproduce the issue.
from my understanding, playframework + sbt 1.5.* no longer uses the methvin file watcher (or at least doesn't attempt to load native libraries to perform file watching), but it breaks twirl template compilation...
would paying for Lightbend support possibly accelerate addressing these issues? because im kind of dead in the water atm.
...from my understanding, playframework + sbt 1.5.* no longer uses the methvin file watcher (or at least doesn't attempt to load native libraries to perform file watching)...
@bpossolo What makes you think that play + sbt 1.5 no longer uses directory watcher? This is not true, it will be used exactly like in sbt 1.4.
@mkurz oh it was a comment you wrote in another issue https://github.com/playframework/playframework/issues/10372#issuecomment-738976838
the play run task fails on Apple silicon because of the filewatcher that play uses (io methvin) so when I read that the long term plan is to use sbt’s file watcher I assumed that meant no longer using the methvin one
and in the other thread on Discuss you suggested I try sbt-1.5.0 I thought that was because it used a different filewatcher
@bpossolo Replacing directory-watcher/play-file-watcher did not happen yet, there is just this open issue: https://github.com/playframework/playframework/issues/9956 - no work was done so far. You will have the same experience in sbt 1.5 like you have in sbt 1.4, nothing changes. So your hope that sbt 1.5 fixes your Apple Silicon problem wont work out.
The core problem you face is that is seems JNA is not working yet on Apple silicon, there are reports like https://github.com/java-native-access/jna/issues/1323 which you may want to follow. Others experience the same problem: https://github.com/mefellows/sbt-dotenv/issues/91
There is nothing Play, play-file-watcher, directory-watcher or sbt can do right now, this has to be solved in JNA. I think the core problem is that you are using a device that comes with new hardware which isn't supported yet by every software, which kind was expected in the community when Apple launched the M1 chips. It will take some time until everyone catches up. This should have been an expected risk when you get such a device.
@bpossolo What comes to my mind as a workaround is you could try the jdk7 file watcher instead:
PlayKeys.fileWatchService := play.dev.filewatch.FileWatchService.jdk7(play.sbt.run.toLoggerProxy(sLog.value))
Put that your build.sbt
. This probably is slower that the native approache because AFAIK it uses polling, but until JNA gets fixed that might work for you.
I think I found the problem and the fix is very easy: So in sbt 1.5.0-RC1 the scala-compiler got upgraded from 2.12.12 to 2.12.13. Currently twirl (v1.5.0) gets build with Scala 2.12.11, defined in interplay. As soon as I build twirl with Scala 2.12.13 the problem goes away and everything works, I tested this with Play locally, using scripted tests with varous combination of sbt (1.2.8, 1.3.13, 1.4.9, 1.5.0-RC1 x Scala 2.12.13/2.13.5)
I will see if I can get Twirl 1.5.1 released and see what https://github.com/playframework/playframework/pull/10760 says afterwards.
@mkurz yah I'm aware there was risk in buying the new Mac. unfortunately I was in a situation where I had to buy a new computer and buying an intel one felt like throwing money away. I didn't expect the play/sbt ecosystem to be so dependent on native libraries since java applications tend to be very portable.
thank you for the tip on swapping out the file watcher for pure java implementation! I had no idea that was possible (I'd only seen documentation to disable file watching entirely). I'll try that later today.
@mkurz the jdk7 file watcher works! thank you very much!
The issue appears to be an incompatibility between twirl
and the scala-compiler
. I am closing it for now. Feel free to reopen it if you need some changes in sbt.
Just do let you know this was fixed in twirl version 1.5.1. All I did was updating Scala to latest version 2.12.13 for building the sbt plugin.
I used 1.5.0-RC2 on fresh seed project and got same error :
[error] /Users/roohi/Library/Caches/JNA/temp/jna13937007856668938576.tmp: no matching architecture in universal wrapper [error] /Users/roohi/Library/Caches/JNA/temp/jna13937007856668938576.tmp: no matching architecture in universal wrapper
My jdk version : OpenJDK Runtime Environment Zulu15.29+15-CA (build 15.0.2+7)
I put @mkurz solution PlayKeys.fileWatchService := play.dev.filewatch.FileWatchService.jdk7(play.sbt.run.toLoggerProxy(sLog.value)) on build.sbt and yes it works , but it make development very low.
I did not understand about what is relation between jna incompatibility problem and twirl .did I miss something ?
I did not understand about what is relation between jna incompatibility problem and twirl .did I miss something ?
There is no relation, these are completely two different problems. It just got mixed in this thread here.
I did not understand about what is relation between jna incompatibility problem and twirl .did I miss something ?
There is no relation, these are completely two different problems. It just got mixed in this thread here.
Ok Thanks do you have any idea how much time takes to fix jna problem ? It seems jna released 5.7.0 release and fixed something about ARM thing
do you have any idea how much time takes to fix jna problem ?
No.
It seems jna released 5.7.0 release and fixed something about ARM thing
I think that does not yet fix the problem you face here. Anyway, play-file-watch 1.1.16 already contains latest jna 5.7.0 release, you can try that. Also upcoming Play 2.8.8 will ship with those versions.
Play 2.8.8 is out now
I tried new version and I got same error, It seems the problem still not fixed
@roohix do you have a MCVE demonstrating the failure?
@roohix What "new version" you mean? sbt 1.5.0? Play 2.8.8? Please make sure you use latest Play 2.8.8 to be able to make use of sbt 1.4.9/1.5.0. If you are talking about the jna problem on macOS, that still is not fixed, but there is nothing we can do about that for now.
@roohix What "new version" you mean? sbt 1.5.0? Play 2.8.8? Please make sure you use latest Play 2.8.8 to be able to make use of sbt 1.4.9/1.5.0.
sbt 1.5.0 play 2.8.8
If you are talking about the jna problem on macOS, that still is not fixed, but there is nothing we can do about that for now.
yes , I mean JNA problem thank you , I will wait for jna team
I meet the same problem, it solved after bump sbt to 1.5.1 and play to 2.8.8.
I reproduce this with sbt 1.5.1 and play 2.6.25.
@tnielens Play 2.6 does not support sbt 1.5 nor sbt 1.4. Only latest Play 2.8.8 does. You should either downgrade sbt or upgrade Play...
Hi All,
I am trying to cross-compile my scala and play project with scala version 2.11.11 and 2.12.14. I am also getting the same error as
[error] at play.twirl.compiler.TwirlCompiler$TemplateAsFunctionCompiler$CompilerInstance.compiler$lzycompute(TwirlCompiler.scala:503)
My sbt version is 1.5.5. I cannot use play version 2.8.8 as the highest play version available with scala 2.11 is 2.7.9. Is there a fix for this?
@SethTisue @mkurz
@vishalsatya-sharecare You should either downgrade sbt or upgrade Play
Where are the play / sbt versions documented?
Play 2.7 does not support sbt 1.4.x, you need to stay on sbt 1.3.x. If you want to use latest sbt 1.5.5 you have to use the latest available Play version 2.8.x.
Where are the play / sbt versions documented?
Until sbt 1.4 there were not really compatibility problems with Play <-> sbt version, so there was not documentation necessary. Only starting with sbt 1.4 there was a huge problem, because sbt introduced a "virtual file" concept Play could not handle. That was resolved with Play 2.8.2 or Play 2.8.3 (can't remember the actual version right now).
Everyone watching this thread and experiencing problems with JNA, caused by the Apple M1 chips: Please try latest sbt 1.6.0-M1 (with latest Play 2.8.8), it should resolve the problem. Please also try to remove the PlayKeys.fileWatchService
workaround which is quite slow as people mentioned here (@roohix, @bpossolo ) and please let me know if it works now. Thanks!
BTW: If you want to financially support Play, you can do that now via https://opencollective.com/playframework - that would allow contributors like me to spend more time working on it. Thanks!
I struggled with same issue in my play 2.7.x application. Updating sbt to 1.6.1 and play framework to the latest release of 2.7.x (currently 2.7.9) fixed the issue.
Still experience the same issue while running Play (2.7.9)
Configuration
`[info] p.c.s.AkkaHttpServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Enter to stop and go back to the console...)
[error] java.lang.NoSuchMethodError: 'scala.tools.nsc.settings.AbsSettings$AbsSetting scala.tools.nsc.Settings.bootclasspath()'
[error] at play.twirl.compiler.TwirlCompiler$TemplateAsFunctionCompiler$CompilerInstance.compiler$lzycompute(TwirlCompiler.scala:503)
[error] at play.twirl.compiler.TwirlCompiler$TemplateAsFunctionCompiler$CompilerInstance.compiler(TwirlCompiler.scala:481)
[error] at play.twirl.compiler.TwirlCompiler$TemplateAsFunctionCompiler$PresentationCompiler$.
@AleksFLeapFin Please use sbt 1.7.2 when possible, also use scala 2.12.16. Also please upgrade to Play 2.8.x asap.
Works with downgrading sbt
to 1.3.12
steps
Installed sbt 1.5.0-RC1 Update build.properties with 1.5.0-RC1
Attempt to compile PLAY application.
problem
Application does not compile, gives following error;
expectation
Should compile without failing.
notes
with 1.5.0-RC1 installed - but 1.4.9 in build.properties - the application compiles / tests fine.