How to install a package with binlink within a habitat package

Hi ,

How Do I install a core package like rsync as part of another habitat package ?

Adding it as a dependency will install it but not binlink it .

Does adding the below in the plan take care of it ? Please guide.

do_install() {
hab pkg install core/rsync -b
}

or Should I just run the command hab pkg install core/rsync -b in one of the hooks ?

How Do I install a core package like rsync as part of another habitat package ?

By declaring the package as a dependency of your package.

Adding it as a dependency will install it but not binlink it .

Do you mean that when installing your package with binlinks (e.g. hab pkg install -b yourpackage) that you wish for core/rsync to be binlinked as well?

Does adding the below in the plan take care of it ? Please guide.
do_install() {
hab pkg install core/rsync -b
}

do_install is executed during package build, so this would not have the effect you are picturing. You should never need to run any variation of hab pkg install in a plan.

Should I just run the command hab pkg install core/rsync -b in one of the hooks ?

No. If core/rsync is a dependency of your package, it will already be installed after you have installed your package. If you were to call anything in your hooks, it would be hab pkg binlink core/rsync to create links for the package that is already present.

After installing your package, is your desire for the rsync command to be available to humans typing on a command prompt or for the hooks in your package to have the rsync command available on their PATH? In other words, why do you want binlinks for a dependency?

Until this issue is addressed, if you run your package from a binlink it's dependencies will NOT be in its path unfortunately:

For now, instead of using a binlink create a script like this for running your packaged command:

#!/bin/bash
exec hab pkg exec your/pkg yourcmd $@

When you run your command via hab pkg exec, the commands exposed by all it's dependencies will automatically be in its PATH without needing to be binlinked. You only want to use binlinks to expose commands to a user in their normal shell, not for fulfilling dependencies between packages

After installing the package, it is my desire for the rsync command to be available to humans typing on a command prompt

yes that is my intent . I want to expose rsync commands to a user in their normal shell

Ideally you should just install/binlink the rsync package directly, habitat packages aren't really designed to create environments for users but for one application. When I do something like it sounds like you are, I have a script outside of hab install my have package and then create each binlink I want in the user environment