Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions habitat/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ do_setup_environment() {
build_line "Setting GEM_PATH=$GEM_HOME"
export GEM_PATH="$GEM_HOME"
}

do_prepare() {
ln -sf "$(pkg_interpreter_for core/ruby3_1 bin/ruby)" "$(pkg_interpreter_for core/coreutils bin/env)"
}
pkg_version() {
cat "$SRC_PATH/VERSION"
}
Expand All @@ -43,6 +45,7 @@ do_build() {
bundle config --local silence_root_warning 1
bundle install
gem build chef-cli.gemspec
gem install rspec-core -v '~> 3.12.3'
ruby ./post-bundle-install.rb
}
do_install() {
Expand All @@ -53,6 +56,9 @@ do_install() {
gem install chef-cli-*.gem --no-document
set_runtime_env "GEM_PATH" "${pkg_prefix}/vendor"
wrap_ruby_bin
rm -rf $GEM_PATH/cache/
rm -rf $GEM_PATH/bundler
rm -rf $GEM_PATH/doc
}
wrap_ruby_bin() {
local bin="$pkg_prefix/bin/$pkg_name"
Expand All @@ -63,7 +69,7 @@ wrap_ruby_bin() {
set -e

# Set binary path that allows InSpec to use non-Hab pkg binaries
export PATH="/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:\$PATH"
export PATH="/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:$pkg_prefix/vendor/bin:\$PATH"

# Set Ruby paths defined from 'do_setup_environment()'
export GEM_HOME="$pkg_prefix/vendor"
Expand Down
1 change: 1 addition & 0 deletions lib/chef-cli/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def habitat_env(show_warning: false)
# Construct PATH
path = [
File.join(bin_pkg_prefix, "bin"),
File.join(vendor_dir, "bin"),
ENV["PATH"].split(File::PATH_SEPARATOR), # Preserve existing PATH
].flatten.uniq

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
let(:chef_dke_path) { "/hab/pkgs/chef/chef-development-kit-enterprise/1.0.0/123" }
let(:cli_hab_path) { "/hab/pkgs/chef/chef-cli/1.0.0/123" }
let(:expected_gem_root) { Gem.default_dir }
let(:expected_path) { [File.join(chef_dke_path, "bin"), "/usr/bin:/bin"].flatten }
let(:expected_path) { [File.join(chef_dke_path, "bin"), File.join(cli_hab_path, "vendor", "bin"), "/usr/bin:/bin"].flatten }
let(:expected_env) do
{
"PATH" => expected_path.join(File::PATH_SEPARATOR),
Expand Down