# "A strange and unexplainable error occurred while trying to create a new sketch"

**URL:** <https://discourse.processing.org/t/a-strange-and-unexplainable-error-occurred-while-trying-to-create-a-new-sketch/41733>\
**Category:** Processing\
**Created:** [April 15, 2023, 1:07pm UTC](https://discourse.processing.org/t/a-strange-and-unexplainable-error-occurred-while-trying-to-create-a-new-sketch/41733 "2023-04-15T13:07:51Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [April 15, 2023, 1:07pm UTC](https://discourse.processing.org/t/a-strange-and-unexplainable-error-occurred-while-trying-to-create-a-new-sketch/41733/1 "2023-04-15T13:07:51Z")

</div>

I’ve just installed v4.2 and now I’m getting the error below when I try to start Processing. However, I I choose “Run as administrator” (I’m running under Windows 10), it starts normally. So I assume it has something to do with permissions, but I don’t have this problem with the older version, v4.0.1, that I still have installed. Would v4.2 and v4.0.1 be writing to different folders?

I found another post about this error ([https://discourse.processing.org/t/on-startup-thats-new-to-me-a-strange-and-unexplainable-error-occurred/40899](https://discourse.processing.org/t/on-startup-thats-new-to-me-a-strange-and-unexplainable-error-occurred/40899)), but this person was running under Linux, so the solution isn’t applicable in my case.

I can try to remember to run it “as administrator” every time, but I know I’ll forget sometimes, and it’s a little annoying having to do that. Did anyone else have this problem under Windows? Any suggestions?

 ![Image1](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/a/9/a9313dac588887443ad0f77a09f25cc0975f9130.jpeg)

---

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [April 15, 2023, 1:10pm UTC](https://discourse.processing.org/t/a-strange-and-unexplainable-error-occurred-while-trying-to-create-a-new-sketch/41733/2 "2023-04-15T13:10:27Z")

</div>

BTW, I love the error message. I always thought there was an explanation whenever software fails, but I guess this is unexplainable.

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [April 17, 2023, 9:05am UTC](https://discourse.processing.org/t/a-strange-and-unexplainable-error-occurred-while-trying-to-create-a-new-sketch/41733/3 "2023-04-17T09:05:22Z")

</div>

Hi @David,

This is probably a permission error on Windows. Does this happen every time you try to create a sketch?

btw: it says it’s unexplainable but the exception is described just below: `Could not create directory ...` 😉

---

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [April 17, 2023, 12:15pm UTC](https://discourse.processing.org/t/a-strange-and-unexplainable-error-occurred-while-trying-to-create-a-new-sketch/41733/4 "2023-04-17T12:15:55Z")

</div>

> [@josephh](#):
>
> This is probably a permission error on Windows. Does this happen every time you try to create a sketch?

Right, that’s what I said. It happens every time I open the Processing IDE (unless I run it “as administrator”). The strange thing is that it doesn’t happen with the earlier version I had installed. That makes no sense, unless they’re writing to different directories.

Edit: Oh, BTW, I have no problem creating a sub-directory in that directory using WIndows Explorer, while logged in as the same user. Which makes no sense either.

> [@josephh](#):
>
> btw: it says it’s unexplainable but the exception is described just below: `Could not create directory`

It was meant as a joke, but if you want to take it seriously, then the message is self-contradictory. It says it’s unexplainable, but then gives an explanation.

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [April 17, 2023, 1:26pm UTC](https://discourse.processing.org/t/a-strange-and-unexplainable-error-occurred-while-trying-to-create-a-new-sketch/41733/5 "2023-04-17T13:26:19Z")

</div>

You can see the source code here:

> <https://github.com/processing/processing4/blob/8b8c53df4dec9c1d1b65ae631e9fedc9ffd38ca0/app/src/processing/app/Base.java#L1100>

The `handleNew` method is used to create a new untitled document and the `Could not create directory` `IOException` is raised when creating the folder and it’s parents:

> **[File mkdirs() method in Java with examples - GeeksforGeeks](https://www.geeksforgeeks.org/file-mkdirs-method-in-java-with-examples/)**
>
> A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.

You can try to do it yourself:

```java
import java.io.*;

File f = new File("C:/Users/user/AppData/Local/Temp/processing/....");

if (!f.mkdirs()) {
  println("Failed creating the folder(s)");
}

```

---

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [April 17, 2023, 4:55pm UTC](https://discourse.processing.org/t/a-strange-and-unexplainable-error-occurred-while-trying-to-create-a-new-sketch/41733/6 "2023-04-17T16:55:31Z")

</div>

That doesn’t explain why I’m getting the error, when I don’t get the error with the earlier version of Processing (v4.0.1). I see now that v4.2 is using a different version of Java, but I don’t see what difference that would make.

Here’s your test (modified to run as a stand-alone Java Program), run under the version of Java that was installed with v4.0.1 of Processing. It doesn’t get the error.

 ![Image1](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/4/0/40394b51c90f21b1f918b1964d50800b378b084b.jpeg)

Here’s the same program, run under the same user id., under the version of Java that was installed with v4.2 of Processing. It does get the error.

 ![Image2](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/4/8/48e5ceb4ab5ba86d4759e9c7b27f463f82e5dd21.jpeg)

Does that make any sense to you?

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [April 18, 2023, 6:01am UTC](https://discourse.processing.org/t/a-strange-and-unexplainable-error-occurred-while-trying-to-create-a-new-sketch/41733/7 "2023-04-18T06:01:14Z")

</div>

Hi @David,

Have you deleted the whatever in between the two calls above? Mkdirs returns true only if the directory is created by the call. Also means it return false if the directory already exists …

Other thing which came to my mind on this, is a scenario on which the first call of processing is done by administrator, so the parent directory (…Temp\processing) would be created under administrator permissions. After that a call as regular user maybe can’t create a sub directory (Temp/processing/whatever) anymore, as long as an administrative user not allowed it, resp. set the permission to allow to write for anybody to the (…/Temp/processing) directory.  
In this case just delete the (…/Temp/processing) directory and start processing as a regular user to let the directory created again under the regular user. In that case regular and administrative user can write to it, resp. create sub directories…

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [April 18, 2023, 11:22am UTC](https://discourse.processing.org/t/a-strange-and-unexplainable-error-occurred-while-trying-to-create-a-new-sketch/41733/8 "2023-04-18T11:22:44Z")

</div>

I ran the test that failed first, so there was nothing to delete. And I ran both tests as a regular user, because the problem doesn’t occur when I run Processing as administrator.

I’ll try deleting the parent directory and see if that fixes the problem.

Edit: No, it didn’t. I’m still getting the same error.

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [April 18, 2023, 12:31pm UTC](https://discourse.processing.org/t/a-strange-and-unexplainable-error-occurred-while-trying-to-create-a-new-sketch/41733/9 "2023-04-18T12:31:58Z")

</div>

Hi,

maybe you can change your example to use: [java.nio.file.Files.createDirectories](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/file/Files.html#createDirectories(java.nio.file.Path,java.nio.file.attribute.FileAttribute...))  
and see if there is a similar behaviour as on `Files.mkdirs`

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [April 18, 2023, 12:55pm UTC](https://discourse.processing.org/t/a-strange-and-unexplainable-error-occurred-while-trying-to-create-a-new-sketch/41733/10 "2023-04-18T12:55:29Z")

</div>

OK, but why? Doesn’t Processing use Files.mkdirs()? At least, that’s what @josephh seems to be saying?

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [April 18, 2023, 1:12pm UTC](https://discourse.processing.org/t/a-strange-and-unexplainable-error-occurred-while-trying-to-create-a-new-sketch/41733/11 "2023-04-18T13:12:06Z")

</div>

Hi,

Just to test if there is a general issue creating the files by jdk 17.0.6 you are using for processing 4.2.  
I think it depends on your environment, otherwise we would have much more posts of this topic (also find nothing on github issue page for this problem).  
The nio function also have a bit more specific exception handling under the hood so it maybe can lead to any hints to solve the issue …

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [April 18, 2023, 1:29pm UTC](https://discourse.processing.org/t/a-strange-and-unexplainable-error-occurred-while-trying-to-create-a-new-sketch/41733/12 "2023-04-18T13:29:35Z")

</div>

I’m using the jdk that was installed automatically with Processing 4.2 (I just downloaded the zip file for Windows, extracted the contents and moved it to another location). I don’t have any other jdk installed, except for the one that was installed in Processing 4.0.1. Neither of which are in the Windows path variable (you can see which version of the jdk is being found in the screen prints above).

Just out of curiosity, though, I’ll give it a try later (have to go out soon).

---

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [April 19, 2023, 12:36pm UTC](https://discourse.processing.org/t/a-strange-and-unexplainable-error-occurred-while-trying-to-create-a-new-sketch/41733/13 "2023-04-19T12:36:15Z")

</div>

Same result.

With jdk that was bundled with Processing 4.0.1:

 ![Image1](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/6/d/6de5e81e9c2580ea102def7ee361fb317b1e9616.jpeg)

With jdk that was bundled with Processing 4.2:

 ![Image2](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/5/a/5a07ce69c9a17314490fcf2973ad17898417e068.jpeg)

---

<div class="post-metadata">

**Author:** ![David](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/david/32/8853_2.png) [@David](https://discourse.processing.org/u/David)\
**Post date:** [April 19, 2023, 12:57pm UTC](https://discourse.processing.org/t/a-strange-and-unexplainable-error-occurred-while-trying-to-create-a-new-sketch/41733/14 "2023-04-19T12:57:18Z")

</div>

And FWIW, I have no trouble creating a folder in that location with Python, or creating one  
“manually” with Windows Explorer.

 ![Image3](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/b/d/bd75341644bce48839d4843e67dd03445e7ada28.jpeg)
