NetLogo / NetLogo

turtles, patches, and links for kids, teachers, and scientists
http://ccl.northwestern.edu/netlogo/
1.01k stars 242 forks source link

Permission denied while building array extension #2189

Closed kodingkoning closed 10 months ago

kodingkoning commented 10 months ago

I am trying to build NetLogo, but I am getting a "Permission Denied" error at the "extensions/array" directory. What might be causing this? I tried a clean checkout and got the same error the second time. I also confirmed that I had updated the submodules, as the instructions said.

[info] compiling 158 Scala sources to /u/ekoning2/NetLogo/NetLogo/netlogo-gui/target/test-classes ...
[warn] multiple main classes detected: run 'show discoveredMainClasses' to see the list
[info] building extension: array
[info] Main Scala API documentation to /u/ekoning2/NetLogo/NetLogo/netlogo-gui/docs/scaladoc...
model contains 1208 documentable templates
[info] Main Scala API documentation successful.
[error] java.io.IOException: Cannot run program "sbt" (in directory "/u/ekoning2/NetLogo/NetLogo/extensions/array"): error=13, Permission denied
[error]     at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
[error]     at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
[error]     at scala.sys.process.ProcessBuilderImpl$Simple.run(ProcessBuilderImpl.scala:75)
[error]     at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.run(ProcessBuilderImpl.scala:104)
[error]     at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang(ProcessBuilderImpl.scala:118)
[error]     at Extensions$.sbtExec(Extensions.scala:108)
[error]     at Extensions$.buildExtension(Extensions.scala:98)
[error]     at Extensions$.$anonfun$settings$17(Extensions.scala:82)
[error]     at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:293)
[error]     at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
[error]     at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
[error]     at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:38)
[error]     at scala.collection.TraversableLike.flatMap(TraversableLike.scala:293)
[error]     at scala.collection.TraversableLike.flatMap$(TraversableLike.scala:290)
[error]     at scala.collection.AbstractTraversable.flatMap(Traversable.scala:108)
[error]     at Extensions$.$anonfun$settings$15(Extensions.scala:79)
[error]     at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error]     at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error]     at sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error]     at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error]     at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error]     at sbt.Execute.work(Execute.scala:292)
[error]     at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error]     at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error]     at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error]     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]     at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error]     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error]     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error]     at java.base/java.lang.Thread.run(Thread.java:842)
[error] Caused by: java.io.IOException: error=13, Permission denied
[error]     at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
[error]     at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:314)
[error]     at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244)
[error]     at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
[error]     at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
[error]     at scala.sys.process.ProcessBuilderImpl$Simple.run(ProcessBuilderImpl.scala:75)
[error]     at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.run(ProcessBuilderImpl.scala:104)
[error]     at scala.sys.process.ProcessBuilderImpl$AbstractBuilder.$bang(ProcessBuilderImpl.scala:118)
[error]     at Extensions$.sbtExec(Extensions.scala:108)
[error]     at Extensions$.buildExtension(Extensions.scala:98)
[error]     at Extensions$.$anonfun$settings$17(Extensions.scala:82)
[error]     at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:293)
[error]     at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36)
[error]     at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33)
[error]     at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:38)
[error]     at scala.collection.TraversableLike.flatMap(TraversableLike.scala:293)
[error]     at scala.collection.TraversableLike.flatMap$(TraversableLike.scala:290)
[error]     at scala.collection.AbstractTraversable.flatMap(Traversable.scala:108)
[error]     at Extensions$.$anonfun$settings$15(Extensions.scala:79)
[error]     at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error]     at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error]     at sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error]     at sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error]     at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error]     at sbt.Execute.work(Execute.scala:292)
[error]     at sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error]     at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error]     at sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error]     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]     at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error]     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]     at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error]     at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error]     at java.base/java.lang.Thread.run(Thread.java:842)
[error] (netlogo / extensions) java.io.IOException: Cannot run program "sbt" (in directory "/u/ekoning2/NetLogo/NetLogo/extensions/array"): error=13, Permission denied
[error] Total time: 220 s (03:40), completed Oct 31, 2023, 10:20:28 AM
kodingkoning commented 10 months ago

Looking at other information about sbt, it seems that it's an issue of trying to build without being root. Is there a way to manually set where to build?

I also tried building incrementally, and when I run netlogo/compile in sbt, that works fine.

LaCuneta commented 10 months ago

Hey Elizabeth, sorry you ran into this issue. It's definitely odd, if you're able to update the submodule extensions using git, you should be able to build them. Root permissions should not be required to run sbt. One way to check is to just open a terminal in the NetLogo repository, cd extensions/array, and then run sbt package to see if you can run the extension packaging standalone. If that fails then probably there is some odd file permissions issue. If it works, then the problem would have to be with how NetLogo's sbt session is creating the sub-processes to build the extensions.

Is there a way to manually set where to build?

By default sbt builds to a target/ folder for each sub-project in the repo, so, for example, array will build to extensions/array/target/ There may be a way to change that, but I've never had to before.

One thing to note, depending on why you're trying to build NetLogo you may not need the extensions. If you're just making changes to the UI or adding a new primitive or something you can just use netlogo/run to test your work, or something like netlogo/Test/language to run language tests. Building the extensions, as happens with running dist/buildNetLogo is necessary when packaging a NetLogo release and sometimes when you're testing out an extension from within the NetLogo repository.

kodingkoning commented 10 months ago

When I run sbt package it works fine. If I then go back to the top directory, I still get the same error. I could probably do without the array extension, but I would prefer having it.

When I try ./sbt netlogo/run, then I get an error about opening the X11 window server. I'm trying to run this headless. How can I do that without running ./sbt all?

LaCuneta commented 10 months ago

For running headlessly from sbt, just use netlogo/runMain org.nlogo.headless.Main and then add command line switches as per the BehaviorSpace documentation.

Example: netlogo/runMain org.nlogo.headless.Main --model "../models/IABM Textbook/chapter 4/Wolf Sheep Simple 5.nlogo" --experiment "Wolf Sheep Simple model analysis"

If you can be more specific about what changes you are making and testing to the NetLogo code, I can better advise on avoiding running the all command - again it's usually used when running the full test suite or when bundling NetLogo for distribution, so most of it isn't necessary for development.

kodingkoning commented 10 months ago

I tried with the textbook model: ./sbt netlogo/runMain org.nlogo.headless.Main --model models/IABM\ Textbook/chapter\ 4/Wolf\ Sheep\ Simple\ 5.nlogo --experiment "Wolf Sheep Simple model analysis"

But I get the error:

[error] Expected whitespace character
[error] netlogo/runMain
[error]                ^

Am I correct in running this from sbt, or is there a different executable I'm meant to use?

LaCuneta commented 10 months ago

Right, so the command I wrote assumed you'd started an interactive session with just ./sbt. If you want to start sbt and run a command: ./sbt "netlogo/runMain org.nlogo.headless.Main --model \"../models/IABM Textbook/chapter 4/Wolf Sheep Simple 5.nlogo\" --experiment \"Wolf Sheep Simple model analysis\""

LaCuneta commented 10 months ago

And just to ask the question, are you intending to do NetLogo development, as in changes to Java or Scala files to alter how NetLogo runs? If you just want to run a NetLogo model headlessly you just need to install one of the packages and follow the BehaviorSpace directions I'd linked before, no need to use git/sbt/etc.

kodingkoning commented 10 months ago

Great, that's working for me now!

I am planning to make modifications to NetLogo, mostly in optimizations for performance. I haven't implemented any changes yet -- I'm still trying to get a baseline.

LaCuneta commented 10 months ago

@kodingkoning Awesome, that sounds great. If you need any other info on working around the failing extension builds or on your optimization work, just let me know.