sketchPath returns the wrong sketch path

Hello. Windows user here. The sketchPath and dataPath methods seem to return the wrong sketch locations:

String sketchpath = sketchPath("");
println(sketchpath);

returns:
C:\Users\[my.username]\Documents\Processing\processing-3.5.3\ which is where Processing.exe is located but is NOT where the sketch is located.

Is this a known issue, is this normal behavior?

What are my options to dynamically refer to a subfolder of the data folder? I can’t use absolute paths because this code is shared among machines and should run regardless of the username and where the sketch is located.

Thank you!

1 Like

Win 10 / Processing 3.5.3

and test

println(sketchPath(""));
println(dataPath(""));

AFTER i saved the sketch
works fine here.

please recheck File / Preferences / Sketchbook location:


also for usual coding not need it, i use like

String outfile = "data/mydata.csv";

and the sketch makes the data directory and saves the data correctly.
please also experiment with this.

2 Likes

Hey kll, thanks for you response. Again I’m looking for a way to read data from a subfolder inside the data folder, not write any data out.

Additional fact that I can’t figure out but might be helpful: any new sketch will retrieve the correct sketchPath, but this particular one always outputs the wrong path (copied in my initial post), even when I copy it to another location first or when I recreate it from scratch from a blank sketch.

-a-

String infile = "data/test/moonwalk.jpg";
PImage img = loadImage(infile);
println("load image from "+infile);


// load image from data/test/moonwalk.jpg

works as expected.


-b- so you have a bad sketch
doing bad things,
but you not post it ( or its MCVE ) here?
but leave us guessing?

actually from your original post the idea could be that processing is damaged
means delete systemdir

c:\Users\ < USER > \AppData\Roaming\Processing\

and
…/processing-3.5.3/…
dir,
download & unzip and restart.

but now??? better just delete the bad sketch.


again i look your first post:
C:\Users\[my.username]\Documents\Processing\processing-3.5.3\
is what?

and the sketchbook path is then?
C:\Users\[my.username]\Documents\Processing\

that looks somehow bad, i would never install processing this way? but i can not say it is WRONG??


void setup() {
  size(300, 200);
  sysinfo();
}

void sysinfo() {
  println( "__SYS INFO :");
  println( "System     : " + System.getProperty("os.name") + "  " + System.getProperty("os.version") + "  " + System.getProperty("os.arch") );
  println( "JAVA       : " + System.getProperty("java.home")  + " rev: " +javaVersionName);
  //println( System.getProperty("java.class.path") );
  //println( "\n" + isGL() + "\n" );
  println( "OPENGL     : VENDOR " + PGraphicsOpenGL.OPENGL_VENDOR+" RENDERER " + PGraphicsOpenGL.OPENGL_RENDERER+" VERSION " + PGraphicsOpenGL.OPENGL_VERSION+" GLSL_VERSION: " + PGraphicsOpenGL.GLSL_VERSION);
  println( "user.home  : " + System.getProperty("user.home") );
  println( "user.dir   : " + System.getProperty("user.dir") );
  println( "user.name  : " + System.getProperty("user.name") );
  println( "sketchPath : " + sketchPath() );
  println( "dataPath   : " + dataPath("") );
  println( "dataFile   : " + dataFile("") );
  println( "frameRate  :  actual "+nf(frameRate, 0, 1));
  println( "canvas     : width "+width+" height "+height+" pix "+(width*height));
}

1 Like