Is there an example of running a simple application by using the Habitat CLI for Windows

Because of my lack of experience with Habitat , so I would like to ask if you have any examples of running a simple application using the Habitat CLI for Windows. Like Node.js,Nginx and so on. Please show me. Grateful

Hi @Fishbone

Have you had a look at the learning stream for Windows?

Let me know if thats what you were looking for, or if you need something else.

1 Like

Yes.I have tried this. I just followed the steps and copied the codes,but when I was building there were something wrong and I didn’t how to deal with them.(I called ‘hab studio enter -w’ and then ‘build’)

The logs:
[HAB-STUDIO] Habitat:\src> build
: Loading C:\hab\studios\ContosoUniversity\src\habitat\plan.ps1
contosouniversity: Plan loaded
contosouniversity: Validating plan metadata
contosouniversity: hab-plan-build.ps1 setup
contosouniversity: Using HAB_BIN=C:\hab\pkgs\core\hab-studio\0.73.0\20190115010701\bin\hab\hab.exe for installs, signing, and hashing
contosouniversity: Resolving scaffolding dependencies
» Installing core/nuget
:cloud::cloud: Determining latest version of core/nuget in the ‘stable’ channel
→→ Using core/nuget/4.6.2/20180529182956
★★ Install of core/nuget/4.6.2/20180529182956 complete with 0 new packages installed.
** contosouniversity: Resolved build dependency ‘core/nuget’ to C:\hab\studios\ContosoUniversity\hab\pkgs\core\nuget\4.6.2\20180529182956**
» Installing core/dsc-core
:cloud::cloud: Determining latest version of core/dsc-core in the ‘stable’ channel
→→ Using core/dsc-core/0.2.1/20180919112142
★★ Install of core/dsc-core/0.2.1/20180919112142 complete with 0 new packages installed.
** contosouniversity: Resolved dependency ‘core/dsc-core’ to C:\hab\studios\ContosoUniversity\hab\pkgs\core\dsc-core\0.2.1\20180919112142**
** contosouniversity: Setting up environment**
** contosouniversity: Populating runtime environment from dependencies**
** contosouniversity: Populating buildtime environment from dependencies**
** contosouniversity: Layering runtime environment on top of system environment**
** contosouniversity: Value of PSModulePath is \hab\pkgs\core\dsc-core\0.2.1\20180919112142\Modules**
** contosouniversity: Layering buildtime environment on top of system environment**
** contosouniversity: Setting env:PATH=C:\hab\studios\ContosoUniversity\hab\pkgs\core\nuget\4.6.2\20180529182956\bin;C:\hab\pkgs\core\hab-studio\0.73.0\20190115010701\bin\powershell;C:\hab\pkgs\core\hab-studio\0.73.0\20190115010701\bin\hab;C:\hab\pkgs\core\hab-studio\0.73.0\20190115010701\bin\7zip;C:\hab\pkgs\core\hab-studio\0.73.0\20190115010701\bin;C:\Windows\system32;C:\Windows;C:\hab\studios\ContosoUniversity\hab\bin**
** contosouniversity: Clean the cache**
** contosouniversity: Setting env:LIB=**
** contosouniversity: Setting env:INCLUDE=**
** contosouniversity: Preparing to build**
** contosouniversity: Building**
The input file does not exist:
Feeds used:
** C:\Users\xlk.nuget\packages**

Attempting to gather dependency information for package ‘MSBuild.Microsoft.VisualStudio.Web.targets.’ with respect to project ‘C:\hab\studios\ContosoUniversity\hab\cache\src/contosouniversity-0.1.0/’, targeting 'Any,Version=v0.0’
Gathering dependency information took 1.56 sec
Attempting to resolve dependencies for package ‘MSBuild.Microsoft.VisualStudio.Web.targets.’ with DependencyBehavior 'Lowest’
Resolving dependency information took 0 ms
Resolving actions to install package 'MSBuild.Microsoft.VisualStudio.Web.targets.’
Resolved actions to install package 'MSBuild.Microsoft.VisualStudio.Web.targets.’
Retrieving package ‘MSBuild.Microsoft.VisualStudio.Web.targets’ from ‘C:\Users\xlk.nuget\packages’.
Adding package ‘MSBuild.Microsoft.VisualStudio.Web.targets.’ to folder 'C:\hab\studios\ContosoUniversity\hab\cache\src\contosouniversity-0.1.0’
Added package ‘MSBuild.Microsoft.VisualStudio.Web.targets.’ to folder 'C:\hab\studios\ContosoUniversity\hab\cache\src\contosouniversity-0.1.0’
Successfully installed ‘MSBuild.Microsoft.VisualStudio.Web.targets’ to C:\hab\studios\ContosoUniversity\hab\cache\src/contosouniversity-0.1.0/
Executing nuget actions took 261.22 ms
Microsoft ® Build Engine version 4.6.1038.0
[Microsoft .NET Framework、、version4.0.30319.42000]
Copyright © Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1009: Project file does not exist
Invoke-Build : dotnet build failed!
At C:\hab\pkgs\core\hab-studio\0.73.0\20190115010701\bin\hab-plan-build.ps1:1189 char:11
+ try { Invoke-Build } finally { Pop-Location }
**+ ~~~~~~~~~~~~**
+ CategoryInfo : NotSpecified: ( [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-Build

I also have a question.(This question is unrelated to the above)

How to deal with this when it happen:

The red part means "Access denied".

Hi i need some help regarding habitat application deployment, where to define target machine ip address for with out exporting docker manual commands through chef habitat.

plz give some suggestions

It sounds like the build is not finding the app source code. The best thing to do when things go wrong in this tutorial is to clone the finished plan at and compare that to the directory structure you have been building in the tutorial.

Regarding the “Access denied” errors, I would guess that the current user might not have write access into your hab directory. I’d suggest opening your console as an admin user.

@mwrock I am also facing this access denied error quite frequently when trying to load a service or installing a package. I do have admin access and opened powershell as admin.
Here is the debug trace:

[HAB-STUDIO] Habitat:\src> hab pkg install C:\studio\hab\cache\artifacts\core-sqlserver-14.0.1000-20190711154958-x86_64-windows.hart

[2019-10-04T05:37:44Z DEBUG habitat_common::ui] UI { shell: Shell { input: InputStream { isatty: true }, out: OutputStream { coloring: Auto, isatty: true }, err: OutputStream { coloring: Auto, isatty: true } } }
[2019-10-04T05:37:44Z DEBUG hab] clap cli args: ["C:\hab\pkgs\core\hab-studio\0.85.0\20190916221803\bin\hab\hab.exe", "pkg", "install", "C:\studio\hab\cache\artifacts\core-sqlserver-14.0.1000-20190711154958-x86_64-windows.hart"]
[2019-10-04T05:37:44Z DEBUG hab] remaining cli args:
[2019-10-04T05:37:44Z DEBUG hab::config] No CLI config found, loading defaults
[2019-10-04T05:37:48Z DEBUG habitat_common::command::package::install] install key_cache_path: C:\studio\hab/cache/keys
[2019-10-04T05:37:48Z DEBUG habitat_http_client::api_client] Client socket timeout: 300 secs
[2019-10-04T05:37:48Z DEBUG habitat_http_client::api_client] Skip cert verification: false
[2019-10-04T05:37:48Z DEBUG habitat_http_client::api_client] User-Agent: hab/0.85.0/20190916215313 (x86_64-windows; 10.0.14915)
[2019-10-04T05:37:48Z DEBUG habitat_http_client::api_client] No proxy configured for url: ""
[2019-10-04T05:37:48Z DEBUG habitat_http_client::api_client] No installed Habitat core/cacerts package found
[2019-10-04T05:37:48Z DEBUG habitat_http_client::api_client] Processing cert file: C:\studio\hab/cache/ssl\cert.pem
» Installing C:\studio\hab\cache\artifacts\core-sqlserver-14.0.1000-20190711154958-x86_64-windows.hart
[2019-10-04T05:37:48Z DEBUG habitat_common::command::package::install] skipping artifact copy, it is being referenced directly from cache, artifact_path=\?\C:\studio\hab\cache\artifacts\core-sqlserver-14.0.1000-20190711154958-x86_64-windows.hart, cache_path=\?\C:\studio\hab\cache\artifacts\core-sqlserver-14.0.1000-20190711154958-x86_64-windows.hart
[2019-10-04T05:37:48Z DEBUG habitat_common::command::package::install] Found core/sqlserver/14.0.1000/20190711154958 in artifact cache, skipping remote download
→ Verifying core/sqlserver/14.0.1000/20190711154958
[2019-10-04T05:37:52Z DEBUG habitat_core::crypto::keys::sig_key_pair] Can't find secret key for name_with_rev core-20180119235000: The system cannot find the file specified. (os error 2)
[2019-10-04T05:37:53Z DEBUG habitat_common::command::package::install] Verified core/sqlserver/14.0.1000/20190711154958 signed by core-20180119235000
→ Using core/dsc-core/0.3.0/20190711154859
[2019-10-04T05:37:53Z DEBUG habitat_common::templating::hooks] install not found at C:\studio\hab\pkgs\core\dsc-core\0.3.0\20190711154859\hooks\install, not loading
[2019-10-04T05:38:01Z DEBUG habitat_common::command::package::install] rename failed with Os { code: 5, kind: PermissionDenied, message: "Access is denied." }, checking for installed package
XXX Access is denied. (os error 5)
[HAB-STUDIO] Habitat:\src>

Couple of things I validated:

  • the core/sqlserver and its dependent package dsc both are available in my local cache.
  • the secret key - core-20180119235000 is also available in C:\studio\hab\cache\keys
  • I tried deleting this key and it gets regenerated next time I try to fetch some packaged from builder.
  • I also tried loading the package via hab svc load command which also results in same error.


Hmm. That is strange. This failure would occur after the install process has succesfully downloaded the hart and expanded it to a temporary folder under hab/pkgs/<origin>/<name>/<version>. The error is occuring when renaming that directory to hab/pkgs/<origin>/<name>/<version>/<release>. I would check to see if there is already a release directory present from a interrupted install. If so deleted. This seems unlikely but it is worth looking for.