Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to compile Play application with 1.5.0-RC1 #6400

Closed
gavinbaumanis opened this issue Mar 16, 2021 · 35 comments
Closed

Unable to compile Play application with 1.5.0-RC1 #6400

gavinbaumanis opened this issue Mar 16, 2021 · 35 comments
Labels

Comments

@gavinbaumanis
Copy link

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;

[error] stack trace is suppressed; run last Compile / twirlCompileTemplates for the full output
[error] (Compile / twirlCompileTemplates) java.lang.NoSuchMethodError: scala.tools.nsc.Settings.bootclasspath()Lscala/tools/nsc/settings/AbsSettings$AbsSetting;
[error] Total time: 0 s, completed 16 Mar. 2021, 4:19:00 pm

expectation

Should compile without failing.

notes

with 1.5.0-RC1 installed - but 1.4.9 in build.properties - the application compiles / tests fine.

@bpossolo
Copy link

bpossolo commented Mar 16, 2021

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

@mkurz
Copy link
Member

mkurz commented Mar 16, 2021

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?

@gavinbaumanis
Copy link
Author

gavinbaumanis commented Mar 16, 2021 via email

@eed3si9n
Copy link
Member

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).

@bpossolo
Copy link

bpossolo commented Mar 17, 2021

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.

@mkurz
Copy link
Member

mkurz commented Mar 17, 2021

...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.

@bpossolo
Copy link

bpossolo commented Mar 17, 2021

@mkurz oh it was a comment you wrote in another issue
playframework/playframework#10372 (comment)

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

@mkurz
Copy link
Member

mkurz commented Mar 17, 2021

@bpossolo Replacing directory-watcher/play-file-watcher did not happen yet, there is just this open issue: playframework/playframework#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 java-native-access/jna#1323 which you may want to follow. Others experience the same problem: Philippus/sbt-dotenv#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.

@mkurz
Copy link
Member

mkurz commented Mar 17, 2021

@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.

@mkurz
Copy link
Member

mkurz commented Mar 17, 2021

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 playframework/playframework#10760 says afterwards.

@bpossolo
Copy link

@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.

@bpossolo
Copy link

@mkurz the jdk7 file watcher works! thank you very much!

@adpi2
Copy link
Member

adpi2 commented Mar 18, 2021

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.

@adpi2 adpi2 closed this as completed Mar 18, 2021
@mkurz
Copy link
Member

mkurz commented Mar 19, 2021

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.

@roohix
Copy link

roohix commented Mar 23, 2021

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 ?

@mkurz
Copy link
Member

mkurz commented Mar 23, 2021

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.

@roohix
Copy link

roohix commented Mar 23, 2021

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

@mkurz
Copy link
Member

mkurz commented Mar 23, 2021

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.

tototoshi added a commit to tototoshi/hello-play-28.g8 that referenced this issue Apr 5, 2021
tototoshi added a commit to tototoshi/play-reverse-router-extension that referenced this issue Apr 5, 2021
tototoshi added a commit to tototoshi/sbt-slick-codegen-example that referenced this issue Apr 5, 2021
@SethTisue
Copy link
Member

Play 2.8.8 is out now

@roohix
Copy link

roohix commented Apr 22, 2021

I tried new version and I got same error, It seems the problem still not fixed

@SethTisue
Copy link
Member

@roohix do you have a MCVE demonstrating the failure?

@mkurz
Copy link
Member

mkurz commented Apr 23, 2021

@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
Copy link

roohix commented Apr 23, 2021

@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

@counter2015
Copy link

I meet the same problem, it solved after bump sbt to 1.5.1 and play to 2.8.8.

@tnielens
Copy link

I reproduce this with sbt 1.5.1 and play 2.6.25.

@mkurz
Copy link
Member

mkurz commented Apr 28, 2021

@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...

@vishalsatya-sharecare
Copy link

vishalsatya-sharecare commented Sep 22, 2021

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] java.lang.NoSuchMethodError: scala.tools.nsc.Settings.bootclasspath()Lscala/tools/nsc/settings/AbsSettings$AbsSetting;

[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

@SethTisue
Copy link
Member

@vishalsatya-sharecare You should either downgrade sbt or upgrade Play

@autodidacticon
Copy link

Where are the play / sbt versions documented?

@mkurz
Copy link
Member

mkurz commented Nov 12, 2021

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).

@mkurz
Copy link
Member

mkurz commented Nov 12, 2021

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!

JarrodBaker added a commit to opentargets/platform-api that referenced this issue Dec 3, 2021
This is the highest compatible version with Play. See [sbt bug report]
(sbt/sbt#6400)
@teimuraz
Copy link

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.

jonathonherbert added a commit to guardian/pan-domain-authentication that referenced this issue Mar 15, 2023
jonathonherbert added a commit to guardian/pan-domain-authentication that referenced this issue Mar 15, 2023
@ghost
Copy link

ghost commented Apr 9, 2023

Still experience the same issue while running Play (2.7.9)

Configuration

  1. Apple M1 Big Sur
  2. Scala 2.12.13
  3. sbt 1.6.1
  4. Play 2.7.9
  5. Java OpenJDK Runtime Environment Corretto-11.0.18.10.1 (build 11.0.18+10-LTS)

`[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$.(TwirlCompiler.scala:549)
`

@mkurz
Copy link
Member

mkurz commented Apr 11, 2023

@AleksFLeapFin Please use sbt 1.7.2 when possible, also use scala 2.12.16.
Also please upgrade to Play 2.8.x asap.

@ghost
Copy link

ghost commented Apr 12, 2023

Works with downgrading sbt to 1.3.12

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests