# Hab studio build fails with \`Usage: record \<SESSION\> \[CMD \[ARG ..\]\]\`

**URL:** https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321
**Category:** Habitat Help
**Created:** [June 14, 2018, 6:26am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321 "2018-06-14T06:26:10Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![thaddeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/thaddeus/32/2966_2.png) [@thaddeus](https://discourse.chef.io/u/thaddeus)
#### Post date: [June 14, 2018, 6:26am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/1 "2018-06-14T06:26:10Z")

</div>

Hi all,

Just exploring Habitat and trying to get an on-premise builder working.

- Installed on-premise habitat builder sucessfully
- Integrated OAUTH with BitBucket successfully

So, I read somewhere that auto-build on commit of repo was not supported for any repositories other than GitHub.

So, I wanted to build a Bamboo pipeline to test the workflow of code commit -\> build/package -\> upload to builder/depot -\> and auto-update a running application using bitbucket as a source control repository.

So trying to build my package with `hab studio build` and it fails with the following:

```auto
» Binlinking sh from core/bash into /hab/studios/src/bin
★ Binlinked sh from core/bash/4.3.42/20170513213519 to /hab/studios/src/bin/sh
   hab-studio: Building '' in Studio at /hab/studios/src (default)
   hab-studio: Exported: HAB_AUTH_TOKEN=[redacted]
   hab-studio: Exported: HAB_ORIGIN=[redacted]
   hab-studio: Exported: HAB_BLDR_URL=[redacted]
Usage: record <SESSION> [CMD [ARG ..]]

```

Any ideas what is wrong? Seems like `hab studio build` has issues.

How do you build habitat packages from an external script? Does anyone have any samples that you are willing to share?

---

<div class="post-metadata">

### Author: ![predominant](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/predominant/32/1151_2.png) [@predominant](https://discourse.chef.io/u/predominant)
#### Post date: [June 14, 2018, 6:46am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/2 "2018-06-14T06:46:26Z")

</div>

When doing a build outside the studio, provide the path to the application:

```auto
hab studio build /path/to/app

```

That directory/path you specify should either contain:

- A habitat/ directory with a plan.sh, or
- a plan.sh

I hope that helps 🙂

---

<div class="post-metadata">

### Author: ![thaddeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/thaddeus/32/2966_2.png) [@thaddeus](https://discourse.chef.io/u/thaddeus)
#### Post date: [June 14, 2018, 6:49am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/3 "2018-06-14T06:49:25Z")

</div>

> [@On another topic](https://discourse.chef.io/t/574/2):
>
> hab studio build

Thanks! I thought it took ${PWD} as the default.

If I run `hab studio build .` it works!

Many thanks.

Now onto the next step.

---

<div class="post-metadata">

### Author: ![predominant](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/predominant/32/1151_2.png) [@predominant](https://discourse.chef.io/u/predominant)
#### Post date: [June 14, 2018, 6:50am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/4 "2018-06-14T06:50:07Z")

</div>

I agree that the output in that case was not helpful.  
❤ I’m glad you’re past that!

---

<div class="post-metadata">

### Author: ![thaddeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/thaddeus/32/2966_2.png) [@thaddeus](https://discourse.chef.io/u/thaddeus)
#### Post date: [June 14, 2018, 7:00am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/5 "2018-06-14T07:00:59Z")

</div>

Now the next step, how do you upload a package when you are not in studio? IT cant find the dependent packages when not in studio.

```auto
✓ Signed artifact with myorigin-20180611050039.pub
» Uploading public origin key myorigin-20180611050039.pub
    80 B / 80 B | [===========================================================================] 100.00 % 123 B/s  
→ Using existing public origin key myorigin-20180611050039.pub
» Uploading ./results/myorigin-sample-node-app-1.1.7-20180614065656-x86_64-linux.hart
∵ Missing artifact core-bash-4.3.42-20170513213519-x86_64-linux.hart. It was not found in ./results
∵ Missing artifact core-bash-4.3.42-20170513213519-x86_64-linux.hart. It was not found in ./results
∵ Missing artifact core-bash-4.3.42-20170513213519-x86_64-linux.hart. It was not found in ./results
∵ Missing artifact core-bash-4.3.42-20170513213519-x86_64-linux.hart. It was not found in ./results
∵ Missing artifact core-bash-4.3.42-20170513213519-x86_64-linux.hart. It was not found in ./results
✗✗✗
✗✗✗ Upload failed: We tried 5 times but could not upload core/bash/4.3.42/20170513213519. Giving up.
✗✗✗

```

---

<div class="post-metadata">

### Author: ![predominant](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/predominant/32/1151_2.png) [@predominant](https://discourse.chef.io/u/predominant)
#### Post date: [June 14, 2018, 7:10am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/6 "2018-06-14T07:10:31Z")

</div>

I think you’ll need to ensure that the dependent packages are already on your builder instance.

A new builder installation has no core packages on it

To do this, you can (from a hab-sup that is linked to your builder) simply install the required packages. This will do an initial sync of the package you want to install, and all its dependencies.

---

<div class="post-metadata">

### Author: ![thaddeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/thaddeus/32/2966_2.png) [@thaddeus](https://discourse.chef.io/u/thaddeus)
#### Post date: [June 14, 2018, 7:15am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/7 "2018-06-14T07:15:19Z")

</div>

Got it. I kicked off the build on my workstation/bamboo instance rather than the builder instance. I have loaded the core packages already on the instance so they are there. I guess the build will need to run on the bldr instance itself?

---

<div class="post-metadata">

### Author: ![predominant](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/predominant/32/1151_2.png) [@predominant](https://discourse.chef.io/u/predominant)
#### Post date: [June 14, 2018, 7:16am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/8 "2018-06-14T07:16:50Z")

</div>

No, they should not have to run on the builder instance itself… Hmm.

Can you confirm your builder has `core/bash` ?

---

<div class="post-metadata">

### Author: ![thaddeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/thaddeus/32/2966_2.png) [@thaddeus](https://discourse.chef.io/u/thaddeus)
#### Post date: [June 14, 2018, 7:19am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/9 "2018-06-14T07:19:28Z")

</div>

If I run it from command line or build ok. If I exit studio and try and run hab packageu upload it fails. If I run hab package upload from within studio it works

---

<div class="post-metadata">

### Author: ![thaddeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/thaddeus/32/2966_2.png) [@thaddeus](https://discourse.chef.io/u/thaddeus)
#### Post date: [June 14, 2018, 7:20am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/10 "2018-06-14T07:20:30Z")

</div>

And it looks for the packages in /src exists when within studio, but does not outside of it

---

<div class="post-metadata">

### Author: ![predominant](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/predominant/32/1151_2.png) [@predominant](https://discourse.chef.io/u/predominant)
#### Post date: [June 14, 2018, 7:22am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/11 "2018-06-14T07:22:50Z")

</div>

When you run the build from the command line, its more than likely pulling your dependencies from the public builder, not your on-premise-builder.

Once I have `core/` mirrored, essentially, I am able to:

```auto
hab pkg upload --auth AUTH_TOKEN --url http://10.48.236.70 results/name.hart

```

---

<div class="post-metadata">

### Author: ![thaddeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/thaddeus/32/2966_2.png) [@thaddeus](https://discourse.chef.io/u/thaddeus)
#### Post date: [June 14, 2018, 7:24am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/12 "2018-06-14T07:24:10Z")

</div>

I have HAB\_BLDR environment variable set

---

<div class="post-metadata">

### Author: ![thaddeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/thaddeus/32/2966_2.png) [@thaddeus](https://discourse.chef.io/u/thaddeus)
#### Post date: [June 14, 2018, 7:25am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/13 "2018-06-14T07:25:22Z")

</div>

Are you running that from within studio ie after you run hab studio enter?

---

<div class="post-metadata">

### Author: ![thaddeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/thaddeus/32/2966_2.png) [@thaddeus](https://discourse.chef.io/u/thaddeus)
#### Post date: [June 14, 2018, 7:42am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/14 "2018-06-14T07:42:34Z")

</div>

I wonder whether the environment variables are not honoured when not in studio. I’m away from my machine now but will try explicitly setting url from command line and see if that makes a difference

---

<div class="post-metadata">

### Author: ![eeyun1](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/eeyun1/32/2658_2.png) [@eeyun1](https://discourse.chef.io/u/eeyun1)
#### Post date: [June 14, 2018, 2:10pm UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/15 "2018-06-14T14:10:33Z")

</div>

There are environment variables that _do_ get carried into the studio but I can’t recall if it’s all of them or not. If you’re using an on-prem builder the envvar you need is `HAB_BLDR_URL` . For a quick reference of our supported envvars you can check this page out [https://www.habitat.sh/docs/reference/#environment-variables](https://www.habitat.sh/docs/reference/#environment-variables)

---

<div class="post-metadata">

### Author: ![thaddeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/thaddeus/32/2966_2.png) [@thaddeus](https://discourse.chef.io/u/thaddeus)
#### Post date: [June 14, 2018, 11:18pm UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/16 "2018-06-14T23:18:47Z")

</div>

Yeah that’s the variable I have set. I just couldn’t remember it as I was away from my computer at the time of posting. Will test again later today.

---

<div class="post-metadata">

### Author: ![thaddeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/thaddeus/32/2966_2.png) [@thaddeus](https://discourse.chef.io/u/thaddeus)
#### Post date: [June 15, 2018, 12:37am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/17 "2018-06-15T00:37:47Z")

</div>

This does not seem to work when outside of studio. Only when I run `hab studio enter` am I able to upload an artifact.

When outside the studio, I get errors about missing core packages (`∵ Missing artifact core-bash-4.3.42-20170513213519-x86_64-linux.hart. It was not found in ./results`), however these are in my hab cache in $HOME/.hab/cache folder.

If I enter the studio `hab studio enter`, and then run hab pkg upload, then it works ok.

How are people building and uploading packages from an external script (in a pipeline)? Or are people just using the SaaS builder and integrating with GitHub for automated builds?

---

<div class="post-metadata">

### Author: ![predominant](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/predominant/32/1151_2.png) [@predominant](https://discourse.chef.io/u/predominant)
#### Post date: [June 15, 2018, 2:48am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/18 "2018-06-15T02:48:20Z")

</div>

Out of interest, what OS is on the machine you’re running `hab studio build` from ?

---

<div class="post-metadata">

### Author: ![predominant](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/predominant/32/1151_2.png) [@predominant](https://discourse.chef.io/u/predominant)
#### Post date: [June 15, 2018, 2:48am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/19 "2018-06-15T02:48:59Z")

</div>

And also, what hab version?

---

<div class="post-metadata">

### Author: ![thaddeus](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/thaddeus/32/2966_2.png) [@thaddeus](https://discourse.chef.io/u/thaddeus)
#### Post date: [June 15, 2018, 7:41am UTC](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321/20 "2018-06-15T07:41:50Z")

</div>

OSX (Mac laptop)

hab --version  
hab 0.56.0/20180530234342

BTW, just tested hab pkg upload from outside the studio when on the builder itself (Centos 7) but not from a Mac.

So, essentially hab pkg upload works ok on Linux but not on Mac (unless within the studio).

[Next page](https://discourse.chef.io/t/hab-studio-build-fails-with-usage-record-session-cmd-arg/19321.md?page=2)
