Access to path denied when building Windows Package

When I build a windows package in a windows docker container, it fails to build due to permissions issues. I’m using Matt Wrock’s windows-service-example.

   hab-studio: Creating Studio at C:\
? Importing origin key from standard input
? Imported public origin key mhedgpeth-20181213041908.
? Importing origin key from standard input
? Imported secret origin key mhedgpeth-20181213041908.
   hab-studio: Entering Studio at C:\
** The Habitat Supervisor has been started in the background.
** Use 'hab svc start' and 'hab svc stop' to start and stop services.
** Use the 'Get-SupervisorLog' command to stream the Supervisor log.
** Use the 'Stop-Supervisor' to terminate the Supervisor.

[HAB-STUDIO] Habitat:\src> build
   : Loading C:\src\plan.ps1
   windows-service-sample: Plan loaded
   windows-service-sample: Validating plan metadata
   windows-service-sample: hab-plan-build.ps1 setup
   windows-service-sample: Using HAB_BIN=C:\hab\pkgs\core\hab-studio\0.70.0\20181205200050\bin\hab\hab.exe for installs,
 signing, and hashing
   windows-service-sample: Resolving scaffolding dependencies
   windows-service-sample: Setting up environment
   windows-service-sample: Populating runtime environment from dependencies
   windows-service-sample: Populating buildtime environment from dependencies
   windows-service-sample: Layering runtime environment on top of system environment
   windows-service-sample: Layering buildtime environment on top of system environment
   windows-service-sample: Setting env:PATH=C:\hab\pkgs\mhedgpeth\windows-service-sample\0.2.0\20181213090252\bin;C:\hab
\pkgs\core\hab-studio\0.70.0\20181205200050\bin\powershell;C:\hab\pkgs\core\hab-studio\0.70.0\20181205200050\bin\hab;C:\
hab\pkgs\core\hab-studio\0.70.0\20181205200050\bin\7zip;C:\hab\pkgs\core\hab-studio\0.70.0\20181205200050\bin;C:\Windows
\system32;C:\Windows;C:\hab\bin
   windows-service-sample: Clean the cache
   windows-service-sample: Setting env:LIB=
   windows-service-sample: Setting env:INCLUDE=
   windows-service-sample: Preparing to build
   windows-service-sample: Building
Copy-Item : Access to the path 'C:\Documents and Settings' is denied.
At C:\src\plan.ps1:10 char:3
+   Copy-Item $PLAN_CONTEXT/../* $HAB_CACHE_SRC_PATH/$pkg_dirname -recu ...
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Copy-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.CopyItemCommand

Hi Michael!

I’m betting that when you entered the studio, you entered from the habitat directory and not the root of the windows-service-sample repo. That would mean that the actual C# project is not mounted and when the first line of the build function attempts to copy the project into the build cache, its actually trying to copy c:\* which can cause all kinds of issues including what you are seeing. Make sure to run hab studio enter -D from the git repo root and then see if that works for you.

1 Like

That’s right Matt, thanks!