29
votes

I am unable to get a scala worksheet to find any of my project classes when using Intellij. I have added the new scala worksheet to the src directory of my project as instructed here. However whenever I try to run the worksheet I get the following error

Error:(5, 27) not found: type Order
    trait LimitOrder extends Order {
                     ^

The Order trait is defined in a file included in src/main/scala. I even tried putting the scala worksheet in the src/main/scala and it still fails to find the Order trait.

It appears that the problem goes away if either:

  1. I open an external sbt-console in my project directory. Opening the sbt-console automatically compiles the project sources. Then return to Intellij and re-run the worksheet.
  2. I manually compile the source inside Intellij prior to trying to run the worksheet.

I was under the impression that the worksheet was being compiled on the fly every time I re-run it and thus manually compiling it should be un-necessary. Is this incorrect?

1
don't think Scala worksheet is supposed to work that wayWarFox
As I mentioned I am a scala newbie. How exactly is the scala worksheet supposed to work?davidrpugh
Are you able to look up the Order class with ctrl-n (search for class)? WarFox: It works that way on my machinethoredge
Yes I can find the classes via search as you describe. The worksheet doesn't show any errors (i.e., has green box in top right-hand corner) until I try to run the worksheet at which point I get the above compile-error.davidrpugh

1 Answers

54
votes

As mentioned in this discussion thread, in order for a worksheet to find changes to your source classes you need to manually check the "Make project" box which will force a recompile of sources prior to running the worksheet.