diff --git a/habitat/plan.sh b/habitat/plan.sh index 5969b09f..42501169 100644 --- a/habitat/plan.sh +++ b/habitat/plan.sh @@ -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" } @@ -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() { @@ -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" @@ -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" diff --git a/lib/chef-cli/helpers.rb b/lib/chef-cli/helpers.rb index 2221cc8a..d6786e7b 100644 --- a/lib/chef-cli/helpers.rb +++ b/lib/chef-cli/helpers.rb @@ -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 diff --git a/spec/unit/helpers_spec.rb b/spec/unit/helpers_spec.rb index bd8c9a4a..e9976be0 100644 --- a/spec/unit/helpers_spec.rb +++ b/spec/unit/helpers_spec.rb @@ -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),