# Win32APIError when creating a directory on vboxsf shared folder inside Windows guest

**URL:** <https://discourse.chef.io/t/win32apierror-when-creating-a-directory-on-vboxsf-shared-folder-inside-windows-guest/11169>\
**Category:** Chef Infra (archive)\
**Created:** [July 13, 2017, 2:01pm UTC](https://discourse.chef.io/t/win32apierror-when-creating-a-directory-on-vboxsf-shared-folder-inside-windows-guest/11169 "2017-07-13T14:01:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tknerr](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/tknerr/32/21_2.png) [@tknerr](https://discourse.chef.io/u/tknerr)\
**Post date:** [July 13, 2017, 2:01pm UTC](https://discourse.chef.io/t/win32apierror-when-creating-a-directory-on-vboxsf-shared-folder-inside-windows-guest/11169/1 "2017-07-13T14:01:40Z")

</div>

Hi,

I’m desperately trying to create a directory on a vboxsf shared folder inside a windows guest.

Host: MacOS sierra  
Guest: Windows 10  
Hypervisor: VirtualBox 5.1.14  
Chef versions: 12 & 13

Example recipe:

```auto
directory "\\\\vboxsrv\\vagrant\\foo" do
  action :create
end

```

When I run this via `chef-apply my_recipe.rb` I get the following error:

```auto
C:\repos\system\tools\chef>C:\opscode\chefdk\bin\chef-apply test.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
  * directory[\\vboxsrv\vagrant\foo] action create

    ================================================================================
    Error executing action `create` on resource 'directory[\\vboxsrv\vagrant\foo]'
    ================================================================================

    Chef::Exceptions::Win32APIError
    -------------------------------
    Incorrect function.
    ---- Begin Win32 API output ----
    System Error Code: 1
    System Error Message: Incorrect function.
    ---- End Win32 API output ----

    Resource Declaration:
    ---------------------
    # In test.rb

      2: directory "\\\\vboxsrv\\vagrant\\foo" do
      3: action :create
      4: end

    Compiled Resource:
    ------------------
    # Declared in test.rb:2:in `run_chef_recipe'

    directory("\\vboxsrv\vagrant\foo") do
      action [:create]
      default_guard_interpreter :default
      path "\\\\vboxsrv\\vagrant\\foo"
      declared_type :directory
      cookbook_name "(chef-apply cookbook)"
      recipe_name "(chef-apply recipe)"
      group nil
      mode nil
      owner nil
    end

    System Info:
    ------------
    chef_version=13.2.20
    platform=windows
    platform_version=10.0.14393
    ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [i386-mingw32]
    program_name=C:/opscode/chefdk/bin/chef-apply
    executable=C:/opscode/chefdk/bin/chef-apply

[2017-07-13T15:36:25+02:00] FATAL: Stacktrace dumped to C:/Users/vagrant/.chef/cache/chef-stacktrace.out
[2017-07-13T15:36:25+02:00] FATAL: Stacktrace dumped to C:/Users/vagrant/.chef/cache/chef-stacktrace.out
[2017-07-13T15:36:25+02:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-07-13T15:36:25+02:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-07-13T15:36:25+02:00] FATAL: Chef::Exceptions::Win32APIError: directory[\\vboxsrv\vagrant\foo] ((chef-apply cookbook)::(chef-apply recipe) line 2) had an error: Chef::Exceptions::Win32APIError: Incorrect function.
---- Begin Win32 API output ----
System Error Code: 1
System Error Message: Incorrect function.
---- End Win32 API output ----

[2017-07-13T15:36:25+02:00] FATAL: Chef::Exceptions::Win32APIError: directory[\\vboxsrv\vagrant\foo] ((chef-apply cookbook)::(chef-apply recipe) line 2) had an error: Chef::Exceptions::Win32APIError: Incorrect function.
---- Begin Win32 API output ----
System Error Code: 1
System Error Message: Incorrect function.
---- End Win32 API output ----

```

Creating that directory via cmd works perfectly fine.

Any ideas what’s going wrong here?

Cheers,  
Torben

---

<div class="post-metadata">

**Author:** ![tknerr](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/tknerr/32/21_2.png) [@tknerr](https://discourse.chef.io/u/tknerr)\
**Post date:** [July 13, 2017, 2:07pm UTC](https://discourse.chef.io/t/win32apierror-when-creating-a-directory-on-vboxsf-shared-folder-inside-windows-guest/11169/2 "2017-07-13T14:07:46Z")

</div>

Btw I originally tried to create the directory on the mapped network drive `C:\vagrant`, i.e.:

```auto
directory "C:\\vagrant\\foo" do
  action :create
end

```

In that case I additional got this error message: `"get_named_security_info(C:\vagrant\foo, SE_FILE_OBJECT, 7)"`

Full output:

```auto
C:\repos\system\tools\chef>C:\opscode\chefdk\bin\chef-apply test.rb
Recipe: (chef-apply cookbook)::(chef-apply recipe)
  * directory[C:\vagrant\foo] action create

    ================================================================================
    Error executing action `create` on resource 'directory[C:\vagrant\foo]'
    ================================================================================

    Chef::Exceptions::Win32APIError
    -------------------------------
    Incorrect function.
    get_named_security_info(C:\vagrant\foo, SE_FILE_OBJECT, 7)---- Begin Win32 API output ----
    System Error Code: 1
    System Error Message: Incorrect function.
    ---- End Win32 API output ----

    Resource Declaration:
    ---------------------
    # In test.rb

      2: directory "C:\\vagrant\\foo" do
      3: action :create
      4: end

    Compiled Resource:
    ------------------
    # Declared in test.rb:2:in `run_chef_recipe'

    directory("C:\vagrant\foo") do
      action [:create]
      default_guard_interpreter :default
      path "C:\\vagrant\\foo"
      declared_type :directory
      cookbook_name "(chef-apply cookbook)"
      recipe_name "(chef-apply recipe)"
      mode nil
      group nil
      owner nil
    end

    System Info:
    ------------
    chef_version=13.2.20
    platform=windows
    platform_version=10.0.14393
    ruby=ruby 2.4.1p111 (2017-03-22 revision 58053) [i386-mingw32]
    program_name=C:/opscode/chefdk/bin/chef-apply
    executable=C:/opscode/chefdk/bin/chef-apply

[2017-07-13T16:05:26+02:00] FATAL: Stacktrace dumped to C:/Users/vagrant/.chef/cache/chef-stacktrace.out
[2017-07-13T16:05:26+02:00] FATAL: Stacktrace dumped to C:/Users/vagrant/.chef/cache/chef-stacktrace.out
[2017-07-13T16:05:26+02:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-07-13T16:05:26+02:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-07-13T16:05:26+02:00] FATAL: Chef::Exceptions::Win32APIError: directory[C:\vagrant\foo] ((chef-apply cookbook)::(chef-apply recipe) line 2) had an error: Chef::Exceptions::Win32APIError: Incorrect function.
get_named_security_info(C:\vagrant\foo, SE_FILE_OBJECT, 7)---- Begin Win32 API output ----
System Error Code: 1
System Error Message: Incorrect function.
---- End Win32 API output ----

[2017-07-13T16:05:26+02:00] FATAL: Chef::Exceptions::Win32APIError: directory[C:\vagrant\foo] ((chef-apply cookbook)::(chef-apply recipe) line 2) had an error: Chef::Exceptions::Win32APIError: Incorrect function.
get_named_security_info(C:\vagrant\foo, SE_FILE_OBJECT, 7)---- Begin Win32 API output ----
System Error Code: 1
System Error Message: Incorrect function.
---- End Win32 API output ----

```

Does that help?

---

<div class="post-metadata">

**Author:** ![tknerr](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/tknerr/32/21_2.png) [@tknerr](https://discourse.chef.io/u/tknerr)\
**Post date:** [July 13, 2017, 2:12pm UTC](https://discourse.chef.io/t/win32apierror-when-creating-a-directory-on-vboxsf-shared-folder-inside-windows-guest/11169/3 "2017-07-13T14:12:56Z")

</div>

The code in question is probably around here:

> <https://github.com/chef/chef/blob/master/lib/chef/win32/security/securable_object.rb#L61>

Still I have no idea…

---

<div class="post-metadata">

**Author:** ![Dan-Joe](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/dan-joe/32/1806_2.png) [@Dan-Joe](https://discourse.chef.io/u/Dan-Joe)\
**Post date:** [July 14, 2017, 3:34am UTC](https://discourse.chef.io/t/win32apierror-when-creating-a-directory-on-vboxsf-shared-folder-inside-windows-guest/11169/4 "2017-07-14T03:34:02Z")

</div>

I might be out of date on the docs, but I thought that the directory resource was for folders on the local system.

Maybe you could write a resource to check if the network dir exists, and if not, create it?

Regards,  
Dan-Joe Lopez

---

<div class="post-metadata">

**Author:** ![thommay](https://avatars.discourse-cdn.com/v4/letter/t/f08c70/32.png) [@thommay](https://discourse.chef.io/u/thommay)\
**Post date:** [July 14, 2017, 7:01am UTC](https://discourse.chef.io/t/win32apierror-when-creating-a-directory-on-vboxsf-shared-folder-inside-windows-guest/11169/5 "2017-07-14T07:01:33Z")

</div>

Please put the stacktrace from `C:/Users/vagrant/.chef/cache/chef-stacktrace.out` in a gist and post it to this thread.

---

<div class="post-metadata">

**Author:** ![darkn3rd](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/darkn3rd/32/4500_2.png) [@darkn3rd](https://discourse.chef.io/u/darkn3rd)\
**Post date:** [August 19, 2026, 10:11pm UTC](https://discourse.chef.io/t/win32apierror-when-creating-a-directory-on-vboxsf-shared-folder-inside-windows-guest/11169/6 "2026-08-19T22:11:52Z")

</div>

This is a actual bug, as the output to the user should not be a stacktrace. When `ChefUtils.windows?` is true, chef-zero's own local-mode data store (`chef/chef_fs/file_system/repository/nodes_dir.rb#create_child`) unconditionally tries to set an owner/DACL on every node file it creates. There's no flag to turn this off, so you'll get a crash.

I wrote the bug up as:

\* [Local mode Windows stacktrace: node file DACL write fails · Issue #16309 · chef/chef · GitHub](https://github.com/chef/chef/issues/16309)
