Trying to get fsc working

Hi,

Can anyone give me some clear instructions on how to get fsc working?

I am using Idea IU-95.66 with Scala plugin nightly build 1456 on Ubuntu 10.04 with a 64-bit JVM.  I have an Idea project with two modules, one Scala only and the other mixed - both have Scala modules using 2.8.0.RC2 supplied with the plugin.

I have seen two approaches on this forum:
* run the CompileServer from the command line
* create an application server profile for "Scala Compilation Server" and run it

However, neither approach has worked for me.

When I tried running fsc from the Scala Compilation Server profile, it starts up on a different port each time, which seemed to require re-configuring the Scala Compiler in Idea each time I run it to use whatever port fsc has chosen (?).

Clicking Make causes an error:
Internal error (Plugin: org.intellij.scala): org.jetbrains.plugins.scala.lang.psi.stubs.impl.ScPrimaryConstructorStubImpl cannot be cast to com.intellij.psi.stubs.PsiFileStub

Well then, that seemed like a dead end.

Note: Since you have to tell the Scala compiler which port fsc is on, I tried to see if I could specify the port number by adding "-Didea.launcher.port=7534" to the VM options in the application profile.  This doesn't work - the application profile just appends another -Didea.launcher.port option further on down the line.


So then I tried running fsc from the command line like this:

/usr/lib/jvm/java-6-sun-1.6.0.20/bin/java -verbose -Denv.classpath="%CLASSPATH%" -Denv.emacs="%EMACS%" -Didea.launcher.port=7534 -Didea.launcher.bin.path=/home/prasinous/idea-IU-95.66/bin -Dfile.encoding=UTF-8 -classpath /home/prasinous/.m2/repository/org/scala-lang/scala-library/2.8.0.RC2/scala-library-2.8.0.RC2.jar:/home/prasinous/.m2/repository/org/scala-lang/scala-compiler/2.8.0.RC2/scala-compiler-2.8.0.RC2.jar:/home/prasinous/idea-IU-95.66/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain scala.tools.nsc.CompileServer

fsc starts up, lsof shows it bound to port 7534, ps doesn't show multiple CompileServer processes running, and fsc verbose output shows libraries being loaded.  Then it sits there waiting.

So then I went to Idea and configured the Scala Compiler to use fsc on server port 7534, but when I try to make I get this error:

fatal error: object scala not found.
one error found

I know it connected to fsc though, because verbose output showed  the same Scala and Java libs being reloaded.  If I hit the make button again, make complains that "-server:7534" is not available and hangs indefinitely with the progress bar showing 50%.  All attempts to stop make fail, and I have to actually kill Idea.

So, I am looking for two pieces of advice:
* what am I doing wrong?
* will getting fsc working improve performance editing Scala files in Idea, which unfortunately has been very problematic for me?

7 comments
Comment actions Permalink

Hi.

I don't know what your particular problems are but I can tell you how I use FSC.

I'm using Ubuntu 9.10 (64bit), Java 6 update 20 64 bit. Idea 9.0.2, always the latest "released" scala plugin. I've only done this on fully scala project (although in the past I think this has worked with mixed projects).

Ensure that FSC or compile server isn't already running (which could happen with various failed attempts at getting it to work).

Goto edit configurations, click add button and select "Scala Compilation Server".

Give it whatever name you want. I use FSC. I add these to the VM Options so you should to: -Xmx512m -verbose

Ensure that "Before launch" -> "Make" is unselected.

Click OK.

Then go to project settings and select Scala Compiler (from under Compiler). Select "Use fsc (fast scalac)"

Click OK.

Now select FSC from the run configuration and run. Try and make a project. Sometimes this fails. Stop FSC and restart it (just click to stop button and then the play button). Try and make again. You will see the classes being loaded in FSC output.

Hope this helps.

Nick.

0
Comment actions Permalink

Has anyone been able to follow these instructions. I get the following when I try to "make":

Scalac internal error: class java.lang.reflect.InvocationTargetException [sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method), sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39), sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25), java.lang.reflect.Method.invoke(Method.java:597), org.jetbrains.plugins.scala.compiler.rt.FastScalacRunner.main(FastScalacRunner.java:61)][scala.tools.nsc.CompileSocket.fatal(CompileSocket.scala:50), scala.tools.nsc.CompileSocket.startNewServer(CompileSocket.scala:89), scala.tools.nsc.CompileSocket.getPort(CompileSocket.scala:113), scala.tools.nsc.CompileSocket.getsock$1(CompileSocket.scala:152), scala.tools.nsc.CompileSocket.getOrCreateSocket(CompileSocket.scala:170), scala.tools.nsc.StandardCompileClient.main0(CompileClient.scala:85), scala.tools.nsc.CompileClient.main0(CompileClient.scala), sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method), sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39), sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25), java.lang.reflect.Method.invoke(Method.java:597), org.jetbrains.plugins.scala.compiler.rt.FastScalacRunner.main(FastScalacRunner.java:61)]

0
Comment actions Permalink

Hmm, well after killing fsc and (re)making I get fsc to compile.

0
Comment actions Permalink

Hi Barry.

You are seeing what I described above.

It usually fails the first time I try to make with the error you posted, however, it always works on the second time. Once it has worked though, as long as it keeps running you can compile as often as you like. The only problem is the compile server stops about twice a day for me so I have to restart.

Even using FSC, idea's compiling is quite slow. I quite often just use SBT to compile which seems to be a lot faster.

I also get the problem on my main project that if I compile and it works, and then I compile again, it compiles a few files again. On smaller projects it correctly says something like, "nothing to compile" and doesn't compile. I wonder what is making idea think that my big project needs certain files recompiled?

Anyway, good work is going on with this plugin so I'm sure all problems will be solved eventually

Nick.

0
Comment actions Permalink

Thanks Nick. I've been running on FSC for about a week now. It does crash now and again, especially if left idle for some time. Compiling single files is blazingly fast. (I still do manual dependency management and compile single files most of the time.) Doing a project build doesn't seem to be any faster than the standard idea build though.

0
Comment actions Permalink

I've also been trying FSC for a few days now.  I also have the problem that it quits if left idle too long (not sure how long is too long).  I've also had a problem that even when no files are changed, scalac takes some time 6.5+ seconds to recompile.  FSC takes about that long on the first try, but on subsequent runs, FSC finishes in <1.5 seconds, which is much nicer.

Thanks for providing FSC support, is very helpful.
Sam Reid

0
Comment actions Permalink

Hi, maybe I can help you

prasinous wrote:

fsc starts up, lsof shows it bound to port 7534, ps doesn't show multiple CompileServer processes running, and fsc verbose output shows libraries being loaded.  Then it sits there waiting.

fsc is not listening on port 7534 - that's port opened by idea launcher. When starting CompileServer takes random port number. Additionally it creates a file named as the port number in your temporary directory. CompileClient reads that file and knows where it should connect to. That's easy. Probably there are some rubbish "port" files in that directory. That confuses CompileServer. Straitforward solution is to cleanup that directory before starting fsc. More info on my blog at http://www.krzysztofbialek.com/2010/07/tech-tip-how-to-use-fast-scala-compiler.html

0

Please sign in to leave a comment.