Skip to content

Commit 8b8de9b

Browse files
Do not harcode ruby, use the one available in the package.
Signed-off-by: Prajakta Purohit <[email protected]>
1 parent c7f9aa6 commit 8b8de9b

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

habitat/bin/kitchen

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
origin="praj"
44
package="chef-test-kitchen-enterprise"
55
cmd="kitchen"
6-
env_version=$KITCHEN_VERSION
7-
ruby_path=$(hab pkg path core/ruby3_1)
6+
env_version=$KITCHEN_VERSION # setup in the OS env for the user running the application
87
pkg_path=$(hab pkg path $origin/$package)
9-
hab_context=$TKE_VERSION
8+
hab_context=$TKE_VERSION # setup in the plan.sh
109

1110
# When the user does not binlink the hab pkg, hab pkg exec will use this script -> in $pkg_path/bin/kitchen
1211
# $pkg_path/bin/kitchen will call $pkg_path/vendor/bin/kitchen which will in turn call $pkg_path/vendor/gems/chef-test-kitchen-enterprise-${pkg_version}/bin/kitchen
@@ -21,21 +20,26 @@ if [[ -z "$hab_context" ]]; then
2120
# This script is being executed as the binlinked script hence it is safe to call the hab pkg exec
2221
if [[ -z "$env_version" ]]; then
2322
# Execute latest installed version (not version that was last installed)
23+
echo "KITCHEN_VERSION is not set in the environment; The script is running as a binlinked script (Not in the hab context)"
2424
hab pkg exec $origin/$package $cmd "$@"
2525
else # the KITCHEN_VERSION could be in the form <semver> or <semver/date>
2626
# Do not need to export any paths since the hab pkg exec will have the GEM_PATH and PATH available
2727
# This will effectively call this same script but in the hab context, since TKE_VERSION will be available.
28-
hab pkg exec $origin/$package/$env_version "$@"
28+
echo "KITCHEN_VERSION: $env_version set in the environment; The script is running as a binlinked script (Not in the hab context)"
29+
hab pkg exec $origin/$package/$env_version $cmd "$@"
2930
fi
3031
else #in hab context
3132
# The script is being executed as hab pkg exec
3233
# The GEM_PATH and PATH will be available as setup in `hab pkg env`
34+
# env_version is available in the hab context for the same user, if running as root pass the env variables with the -E flag.
3335
if [[ -z "$env_version" ]]; then
3436
# Execute latest installed version (not version that was last installed)
35-
exec $ruby_path/bin/ruby $pkg_path/vendor/bin/$cmd "$@"
37+
echo "KITCHEN_VERSION is not set in the environment; The script is running as hab pkg exec or calling itself recursively from the binlinked script (In the hab context)"
38+
exec hab pkg exec $origin/$package ruby $pkg_path/vendor/bin/$cmd "$@"
3639
else
3740
# the KITCHEN_VERSION could be in the form <semver> or <semver/date>
3841
env_path=$(hab pkg path $origin/$package/$env_version)
39-
exec $ruby_path/bin/ruby $env_path/vendor/bin/$cmd "$@"
42+
echo "KITCHEN_VERSION: $env_version set in the environment; The script is running as hab pkg exec or calling itself recursively from the binlinked script (In the hab context)"
43+
exec hab pkg exec $origin/$package/$env_version ruby $env_path/vendor/bin/$cmd "$@"
4044
fi
4145
fi

habitat/plan.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ do_setup_environment() {
3939

4040
# these will be available at runtime; after the package is built and installed
4141
set_runtime_env "GEM_HOME" "$GEM_HOME"
42-
set_runtime_env -f "GEM_PATH" "$GEM_PATH"
42+
set_runtime_env -f "GEM_PATH" "$GEM_HOME"
4343

4444
set_runtime_env "TKE_VERSION" "$pkg_version"
4545
}

0 commit comments

Comments
 (0)