clij / clijx-assistant

A user interface for GPU-accelerated image processing using CLIJ2
https://clij.github.io/assistant
BSD 3-Clause "New" or "Revised" License
4 stars 4 forks source link

Fix for: Jupyter lab does not start when generating a notebook on mac OX and linux #61

Open thawn opened 1 year ago

thawn commented 1 year ago

When I generate a notebook on my M1 mac with clij in fiji, jupyter lab does not open and I get the following error on the console.

error message cd /Users/korten/Applications/Fiji.app jupyter nbconvert --execute --to notebook /var/folders/8s/7jr95f1d28vflnwm1cfqv7t40000gr/T/temp1685006993158/new1.ipynb jupyter notebook /var/folders/8s/7jr95f1d28vflnwm1cfqv7t40000gr/T/temp1685006993158/new1.nbconvert.ipynb Attempt 1 java.lang.RuntimeException: java.io.IOException: Cannot run program "/Users/korten/Applications/Fiji.app/temp.bat" (in directory "/Users/korten/Applications/Fiji.app"): error=13, Permission denied at org.scijava.util.ProcessUtils.exec(ProcessUtils.java:135) at org.scijava.util.ProcessUtils.exec(ProcessUtils.java:69) at net.haesleinhuepf.clijx.assistant.utilities.AssistantUtilities$6.run(AssistantUtilities.java:1404) at java.lang.Thread.run(Thread.java:750) Caused by: java.io.IOException: Cannot run program "/Users/korten/Applications/Fiji.app/temp.bat" (in directory "/Users/korten/Applications/Fiji.app"): error=13, Permission denied at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at java.lang.Runtime.exec(Runtime.java:622) at org.scijava.util.ProcessUtils.exec(ProcessUtils.java:96) ... 3 more Caused by: java.io.IOException: error=13, Permission denied at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.(UNIXProcess.java:247) at java.lang.ProcessImpl.start(ProcessImpl.java:134) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 5 more Attempt 2 java.lang.RuntimeException: java.io.IOException: Cannot run program "/Users/korten/Applications/Fiji.app/temp.bat" (in directory "/Users/korten/Applications/Fiji.app"): error=13, Permission denied at org.scijava.util.ProcessUtils.exec(ProcessUtils.java:135) at org.scijava.util.ProcessUtils.exec(ProcessUtils.java:69) at net.haesleinhuepf.clijx.assistant.utilities.AssistantUtilities$6.run(AssistantUtilities.java:1422) at java.lang.Thread.run(Thread.java:750) Caused by: java.io.IOException: Cannot run program "/Users/korten/Applications/Fiji.app/temp.bat" (in directory "/Users/korten/Applications/Fiji.app"): error=13, Permission denied at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at java.lang.Runtime.exec(Runtime.java:622) at org.scijava.util.ProcessUtils.exec(ProcessUtils.java:96) ... 3 more Caused by: java.io.IOException: error=13, Permission denied at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.(UNIXProcess.java:247) at java.lang.ProcessImpl.start(ProcessImpl.java:134) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) ... 5 more

Fix

  1. the file temp.bat is not executable (i.e. ls -l temp.bat shows -rw--r--r for the permissions), on unix OSes you need to make it executable with chmod a+x temp.bat
  2. conda is notoriously difficult to activate from inside shell scripts However, adding the following lines to the beginning of temp.bat fixed the issue for me:
    #!/usr/bin/env bash
    eval "$(conda shell.bash hook)"

    I would have loved to submit a pull request, but the code that creates temp.bat appears at two positions and I was not sure where to fix it.

thawn commented 1 year ago

p.s. the conda bug is hilarious to read

  1. The conda developers first closed the bug because it is a non-issue since conda commands are not expected to work in scripts (sic!)
  2. Someone posted a fix that is just 4 lines of code in the conda shell scripts
  3. The developers refused to implement the fix, because The shell scripts are devilishly complicated, and we don't have time to get into them right now. What looks like a "simple change" may break a terrible number of seemingly unrelated stuff. And then the developers marked the issue as "a good first issue" and ask for community pull requests 🤣
thawn commented 1 year ago

I guess this is the reason that the TUD HPC team discourages the use of conda and recommends virtualenv instead.

haesleinhuepf commented 1 year ago

Hi Till @thawn ,

I just uploaded clijx-assistant version 0.6.2.0 to the ImageJ update site. What's new: It asks where to save the notebook. This should allow mac-users to open the notebook themselves in their Jupyter lab. Would you mind trying out if it works on your Mac?

Thanks!

Best, Robert

thawn commented 1 year ago

Hi @haesleinhuepf,

thanks a lot for the quick fix. Saving a notebook works now. There are two (more cosmetic) issues remaining:

  1. the default filename is null.ipynb which sounds like a variable is not set
  2. I still get the following messages in the console window:
console error message
/Users/korten/Applications/Fiji.app/
conda activate dbnapari-arm64
cd /Users/korten/Applications/Fiji.app
jupyter nbconvert --execute --to notebook /Users/korten/Desktop/null.ipynb
jupyter notebook /Users/korten/Desktop/null.nbconvert.ipynb
Attempt 1
java.lang.RuntimeException: java.io.IOException: Cannot run program "/Users/korten/Applications/Fiji.app/temp.bat" (in directory "/Users/korten/Applications/Fiji.app"): error=13, Permission denied
    at org.scijava.util.ProcessUtils.exec(ProcessUtils.java:135)
    at org.scijava.util.ProcessUtils.exec(ProcessUtils.java:69)
    at net.haesleinhuepf.clijx.assistant.utilities.AssistantUtilities$6.run(AssistantUtilities.java:1404)
    at java.lang.Thread.run(Thread.java:750)
Caused by: java.io.IOException: Cannot run program "/Users/korten/Applications/Fiji.app/temp.bat" (in directory "/Users/korten/Applications/Fiji.app"): error=13, Permission denied
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at java.lang.Runtime.exec(Runtime.java:622)
    at org.scijava.util.ProcessUtils.exec(ProcessUtils.java:96)
    ... 3 more
Caused by: java.io.IOException: error=13, Permission denied
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.(UNIXProcess.java:247)
    at java.lang.ProcessImpl.start(ProcessImpl.java:134)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 5 more
Attempt 2
java.lang.RuntimeException: java.io.IOException: Cannot run program "/Users/korten/Applications/Fiji.app/temp.bat" (in directory "/Users/korten/Applications/Fiji.app"): error=13, Permission denied
    at org.scijava.util.ProcessUtils.exec(ProcessUtils.java:135)
    at org.scijava.util.ProcessUtils.exec(ProcessUtils.java:69)
    at net.haesleinhuepf.clijx.assistant.utilities.AssistantUtilities$6.run(AssistantUtilities.java:1422)
    at java.lang.Thread.run(Thread.java:750)
Caused by: java.io.IOException: Cannot run program "/Users/korten/Applications/Fiji.app/temp.bat" (in directory "/Users/korten/Applications/Fiji.app"): error=13, Permission denied
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
    at java.lang.Runtime.exec(Runtime.java:622)
    at org.scijava.util.ProcessUtils.exec(ProcessUtils.java:96)
    ... 3 more
Caused by: java.io.IOException: error=13, Permission denied
    at java.lang.UNIXProcess.forkAndExec(Native Method)
    at java.lang.UNIXProcess.(UNIXProcess.java:247)
    at java.lang.ProcessImpl.start(ProcessImpl.java:134)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
    ... 5 more