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

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:

» 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?

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

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 :slight_smile:

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

If I run hab studio build . it works!

Many thanks.

Now onto the next step.

1 Like

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

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.

✓ 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.
✗✗✗

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.

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?

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

Can you confirm your builder has core/bash ?

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

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

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:

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

I have HAB_BLDR environment variable set

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

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

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

1 Like

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.

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?

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

And also, what hab version?

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).