summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@opscode.com>2021-03-18 10:37:54 -0700
committerGitHub <noreply@github.com>2021-03-18 10:37:54 -0700
commitb0dc9f01fa11bbad5bc5672248aba6ddc453d9f6 (patch)
tree64985e53dff35e888f0558685c50bd0b94d923dd
parent6b3f349314aff36d80c2b3d653477fa6280a4f31 (diff)
parent2d88d96b2cfeabd9eaa5350a1f8b90e54632923c (diff)
downloadchef-b0dc9f01fa11bbad5bc5672248aba6ddc453d9f6.tar.gz
Merge pull request #10922 from chef/lcg/ruby-3.0
Ruby 3.0 fixes and post-bundle-install hook
-rw-r--r--.expeditor/verify.pipeline.yml104
-rw-r--r--Gemfile6
-rw-r--r--Gemfile.lock25
-rw-r--r--azure-pipelines.yml3
-rw-r--r--chef.gemspec2
-rw-r--r--habitat/plan.sh8
-rw-r--r--kitchen-tests/kitchen.yml6
-rw-r--r--lib/chef/application/base.rb2
-rw-r--r--lib/chef/client.rb4
-rw-r--r--lib/chef/node/attribute.rb6
-rw-r--r--lib/chef/provider/package/rubygems.rb3
-rw-r--r--post-bundle-install.rb27
-rw-r--r--spec/data/rubygems.org/nonexistent_gem-info1
-rw-r--r--spec/data/rubygems.org/sexp_processor-info49
-rw-r--r--spec/functional/resource/chocolatey_package_spec.rb13
-rw-r--r--spec/unit/application/solo_spec.rb2
-rw-r--r--spec/unit/data_bag_item_spec.rb7
-rw-r--r--spec/unit/node/attribute_spec.rb2
-rw-r--r--spec/unit/provider/package/rubygems_spec.rb28
19 files changed, 190 insertions, 108 deletions
diff --git a/.expeditor/verify.pipeline.yml b/.expeditor/verify.pipeline.yml
index 041a5c3269..b2f19efa8b 100644
--- a/.expeditor/verify.pipeline.yml
+++ b/.expeditor/verify.pipeline.yml
@@ -38,10 +38,10 @@ steps:
image: rubydistros/ubuntu-18.04:2.6
#########################################################################
- # Tests Ruby 2.7
+ # Tests Ruby 3.0
#########################################################################
-- label: "Chefstyle :ruby: 2.7"
+- label: "Chefstyle :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package ruby_prof
@@ -49,9 +49,9 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-18.04:2.7
+ image: rubydistros/ubuntu-18.04:3.0
-- label: "Integration Ubuntu 18.04 :ruby: 2.7"
+- label: "Integration Ubuntu 18.04 :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- cd /workdir; bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package
@@ -59,10 +59,10 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-18.04:2.7
+ image: rubydistros/ubuntu-18.04:3.0
privileged: true
-- label: "Functional Ubuntu 18.04 :ruby: 2.7"
+- label: "Functional Ubuntu 18.04 :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- apt-get update -y
@@ -72,10 +72,10 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-18.04:2.7
+ image: rubydistros/ubuntu-18.04:3.0
privileged: true
-- label: "Unit Ubuntu 18.04 :ruby: 2.7"
+- label: "Unit Ubuntu 18.04 :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package ruby_prof
@@ -84,9 +84,9 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-18.04:2.7
+ image: rubydistros/ubuntu-18.04:3.0
-- label: "Integration Ubuntu 20.04 :ruby: 2.7"
+- label: "Integration Ubuntu 20.04 :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- cd /workdir; bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package
@@ -94,10 +94,10 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-20.04:2.7
+ image: rubydistros/ubuntu-20.04:3.0
privileged: true
-- label: "Functional Ubuntu 20.04 :ruby: 2.7"
+- label: "Functional Ubuntu 20.04 :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- apt-get update -y
@@ -107,10 +107,10 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-20.04:2.7
+ image: rubydistros/ubuntu-20.04:3.0
privileged: true
-- label: "Unit Ubuntu 20.04 :ruby: 2.7"
+- label: "Unit Ubuntu 20.04 :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package ruby_prof
@@ -119,9 +119,9 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-20.04:2.7
+ image: rubydistros/ubuntu-20.04:3.0
-- label: "Integration CentOS 7 :ruby: 2.7"
+- label: "Integration CentOS 7 :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- cd /workdir; bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package
@@ -129,10 +129,10 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/centos-7:2.7
+ image: rubydistros/centos-7:3.0
privileged: true
-- label: "Functional CentOS 7 :ruby: 2.7"
+- label: "Functional CentOS 7 :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- yum install -y crontabs e2fsprogs
@@ -141,10 +141,10 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/centos-7:2.7
+ image: rubydistros/centos-7:3.0
privileged: true
-- label: "Unit CentOS 7 :ruby: 2.7"
+- label: "Unit CentOS 7 :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package ruby_prof
@@ -153,9 +153,9 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/centos-7:2.7
+ image: rubydistros/centos-7:3.0
-- label: "Integration openSUSE 15 :ruby: 2.7"
+- label: "Integration openSUSE 15 :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- zypper install -y cron insserv-compat
@@ -164,10 +164,10 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/opensuse-15:2.7
+ image: rubydistros/opensuse-15:3.0
privileged: true
-- label: "Functional openSUSE 15 :ruby: 2.7"
+- label: "Functional openSUSE 15 :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- zypper install -y cronie insserv-compat
@@ -176,10 +176,10 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/opensuse-15:2.7
+ image: rubydistros/opensuse-15:3.0
privileged: true
-- label: "Unit openSUSE 15 :ruby: 2.7"
+- label: "Unit openSUSE 15 :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- zypper install -y cron insserv-compat
@@ -189,9 +189,9 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/opensuse-15:2.7
+ image: rubydistros/opensuse-15:3.0
-- label: "Integration Fedora :ruby: 2.7"
+- label: "Integration Fedora :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- cd /workdir; bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package
@@ -199,10 +199,10 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/fedora-latest:2.7
+ image: rubydistros/fedora-latest:3.0
privileged: true
-- label: "Functional Fedora :ruby: 2.7"
+- label: "Functional Fedora :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- dnf install -y crontabs e2fsprogs
@@ -211,13 +211,13 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/fedora-latest:2.7
+ image: rubydistros/fedora-latest:3.0
privileged: true
environment:
- FORCE_FFI_YAJL=ext
- CHEF_LICENSE=accept-no-persist
-- label: "Unit Fedora :ruby: 2.7"
+- label: "Unit Fedora :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package ruby_prof
@@ -226,9 +226,9 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/fedora-latest:2.7
+ image: rubydistros/fedora-latest:3.0
-- label: "Functional Windows :ruby: 2.7"
+- label: "Functional Windows :ruby: 3.0"
commands:
- .expeditor/scripts/bk_win_functional.ps1
expeditor:
@@ -238,37 +238,37 @@ steps:
single-use: true
shell: ["powershell", "-Command"]
-- label: "Integration Windows :ruby: 2.7"
+- label: "Integration Windows :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_win_integration.ps1
expeditor:
executor:
docker:
host_os: windows
- image: rubydistros/windows-2019:2.7
+ image: rubydistros/windows-2019:3.0
environment:
- FORCE_FFI_YAJL=ext
- CHEF_LICENSE=accept-no-persist
shell: ["powershell", "-Command"]
-- label: "Chocolatey Windows :ruby: 2.7"
+- label: "Chocolatey Windows :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_run_choco.ps1
expeditor:
executor:
docker:
host_os: windows
- image: rubydistros/windows-2019:2.7
+ image: rubydistros/windows-2019:3.0
shell: ["powershell", "-Command"]
-- label: "Unit Windows :ruby: 2.7"
+- label: "Unit Windows :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_win_unit.ps1
expeditor:
executor:
docker:
host_os: windows
- image: rubydistros/windows-2019:2.7
+ image: rubydistros/windows-2019:3.0
environment:
- FORCE_FFI_YAJL=ext
- CHEF_LICENSE=accept-no-persist
@@ -278,7 +278,7 @@ steps:
# EXTERNAL GEM TESTING
#########################################################################
-- label: "chef-sugar gem :ruby: 2.7"
+- label: "chef-sugar gem :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package
@@ -286,9 +286,9 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-18.04:2.7
+ image: rubydistros/ubuntu-18.04:3.0
-- label: "chef-zero gem :ruby: 2.7"
+- label: "chef-zero gem :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package
@@ -296,12 +296,12 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-18.04:2.7
+ image: rubydistros/ubuntu-18.04:3.0
environment:
- PEDANT_OPTS=--skip-oc_id
- CHEF_FS=true
-- label: "cheffish gem :ruby: 2.7"
+- label: "cheffish gem :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package
@@ -309,9 +309,9 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-18.04:2.7
+ image: rubydistros/ubuntu-18.04:3.0
-- label: "chefspec gem :ruby: 2.7"
+- label: "chefspec gem :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package
@@ -319,9 +319,9 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-18.04:2.7
+ image: rubydistros/ubuntu-18.04:3.0
-- label: "knife-windows gem :ruby: 2.7"
+- label: "knife-windows gem :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- bundle install --jobs=3 --retry=3 --path=vendor/bundle --without omnibus_package
@@ -329,9 +329,9 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-18.04:2.7
+ image: rubydistros/ubuntu-18.04:3.0
-- label: "berkshelf gem :ruby: 2.7"
+- label: "berkshelf gem :ruby: 3.0"
commands:
- /workdir/.expeditor/scripts/bk_container_prep.sh
- apt-get update -y
@@ -341,7 +341,7 @@ steps:
expeditor:
executor:
docker:
- image: rubydistros/ubuntu-18.04:2.7
+ image: rubydistros/ubuntu-18.04:3.0
#########################################################################
# START TEST KITCHEN ONLY
diff --git a/Gemfile b/Gemfile
index 99e7cf3c6b..3369222d57 100644
--- a/Gemfile
+++ b/Gemfile
@@ -39,13 +39,13 @@ end
# Everything except AIX
group(:ruby_prof) do
- # ruby-prof 1.3.0 does not compile on our centos6 builders/kitchen testers
- gem "ruby-prof", "< 1.3.0"
+ gem "ruby-prof"
end
# Everything except AIX and Windows
group(:ruby_shadow) do
- gem "ruby-shadow", platforms: :ruby
+ # if ruby-shadow does a release that supports ruby-3.0 this can be removed
+ gem "ruby-shadow", git: "https://github.com/chef/ruby-shadow", branch: "lcg/ruby-3.0", platforms: :ruby
end
group(:development, :test) do
diff --git a/Gemfile.lock b/Gemfile.lock
index 4908e5ae89..dd4ff6d928 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -25,6 +25,13 @@ GIT
train-core
wmi-lite (~> 1.0)
+GIT
+ remote: https://github.com/chef/ruby-shadow
+ revision: ba25b9349b649435726f1869987657997633c1fb
+ branch: lcg/ruby-3.0
+ specs:
+ ruby-shadow (2.5.0)
+
PATH
remote: .
specs:
@@ -38,7 +45,7 @@ PATH
diff-lcs (>= 1.2.4, < 1.4.0)
ed25519 (~> 1.2)
erubis (~> 2.7)
- ffi (>= 1.9.25)
+ ffi (>= 1.5.0)
ffi-libarchive (~> 1.0, >= 1.0.3)
ffi-yajl (~> 2.2)
highline (>= 1.6.9, < 3)
@@ -74,7 +81,7 @@ PATH
diff-lcs (>= 1.2.4, < 1.4.0)
ed25519 (~> 1.2)
erubis (~> 2.7)
- ffi (>= 1.9.25)
+ ffi (>= 1.5.0)
ffi-libarchive (~> 1.0, >= 1.0.3)
ffi-yajl (~> 2.2)
highline (>= 1.6.9, < 3)
@@ -201,7 +208,7 @@ GEM
highline (2.0.3)
httpclient (2.8.3)
iniparse (1.5.0)
- inspec-core (4.26.13)
+ inspec-core (4.28.0)
addressable (~> 2.4)
chef-telemetry (~> 1.0)
faraday (>= 0.9.0, < 1.4)
@@ -224,8 +231,8 @@ GEM
train-core (~> 3.0)
tty-prompt (~> 0.17)
tty-table (~> 0.10)
- inspec-core-bin (4.26.13)
- inspec-core (= 4.26.13)
+ inspec-core-bin (4.28.0)
+ inspec-core (= 4.28.0)
ipaddress (0.8.3)
iso8601 (0.13.0)
json (2.5.1)
@@ -320,9 +327,9 @@ GEM
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.4.1)
parser (>= 2.7.1.5)
- ruby-prof (1.2.0)
+ ruby-prof (1.4.3)
+ ruby-prof (1.4.3-x64-mingw32)
ruby-progressbar (1.11.0)
- ruby-shadow (2.5.0)
ruby2_keywords (0.0.4)
rubyntlm (0.6.3)
rubyzip (2.3.0)
@@ -441,8 +448,8 @@ DEPENDENCIES
rake
rb-readline
rspec
- ruby-prof (< 1.3.0)
- ruby-shadow
+ ruby-prof
+ ruby-shadow!
webmock
BUNDLED WITH
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 7128e6361c..b2f3acbf8c 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -24,6 +24,7 @@ jobs:
steps:
- script: |
+ brew install coreutils
curl -L https://omnitruck.chef.io/install.sh | sudo bash -s -- -c current
/opt/chef/bin/chef-client -v
/opt/chef/bin/ohai -v
@@ -34,7 +35,6 @@ jobs:
- script: |
OHAI_VERSION=$(sed -n '/ohai .[0-9]/{s/.*(//;s/)//;p;}' Gemfile.lock)
sudo /opt/chef/embedded/bin/gem install appbundler appbundle-updater --no-doc
- sudo /opt/chef/embedded/bin/appbundle-updater chef ohai v${OHAI_VERSION} --tarball --github chef/ohai
sudo /opt/chef/embedded/bin/appbundle-updater chef chef $BUILD_SOURCEVERSION --tarball --github chef/chef
echo "Installed Chef / Ohai release:"
/opt/chef/bin/chef-client -v
@@ -70,7 +70,6 @@ jobs:
$env:PATH = "C:\opscode\chef\bin;C:\opscode\chef\embedded\bin;" + $env:PATH
$env:OHAI_VERSION = ( Select-String -Path .\Gemfile.lock -Pattern '(?<=ohai \()\d.*(?=\))' | ForEach-Object { $_.Matches[0].Value } )
gem install appbundler appbundle-updater --no-doc
- appbundle-updater chef ohai v$env:OHAI_VERSION --tarball --github chef/ohai
appbundle-updater chef chef $env:BUILD_SOURCEVERSION --tarball --github chef/chef
Write-Output "Installed Chef / Ohai release:"
chef-client -v
diff --git a/chef.gemspec b/chef.gemspec
index 4f05de47a9..a5e2b5a8dd 100644
--- a/chef.gemspec
+++ b/chef.gemspec
@@ -38,7 +38,7 @@ Gem::Specification.new do |s|
s.add_dependency "ohai", "~> 17.0"
s.add_dependency "inspec-core", "~> 4.23"
- s.add_dependency "ffi", ">= 1.9.25"
+ s.add_dependency "ffi", ">= 1.5.0"
s.add_dependency "ffi-yajl", "~> 2.2"
s.add_dependency "net-ssh", ">= 5.1", "< 7"
s.add_dependency "net-ssh-multi", "~> 1.2", ">= 1.2.1"
diff --git a/habitat/plan.sh b/habitat/plan.sh
index 64f424dfac..50868b1a3e 100644
--- a/habitat/plan.sh
+++ b/habitat/plan.sh
@@ -94,14 +94,10 @@ do_build() {
( cd "$CACHE_PATH" || exit_with "unable to enter hab-cache directory" 1
build_line "Installing gem dependencies ..."
bundle install --jobs=3 --retry=3
+ build_line "Installing gems from git repos properly ..."
+ ruby ./post-bundle-install.rb
build_line "Installing this project's gems ..."
bundle exec rake install
- for gem in $GEM_HOME/bundler/gems/*; do
- ( cd $gem
- build_line "Installing gems from git repos properly ..."
- rake install
- )
- done
)
}
diff --git a/kitchen-tests/kitchen.yml b/kitchen-tests/kitchen.yml
index 8e894c4699..9c3a3a36cf 100644
--- a/kitchen-tests/kitchen.yml
+++ b/kitchen-tests/kitchen.yml
@@ -21,15 +21,9 @@ lifecycle:
- remote: /opt/chef/bin/chef-client -v
- remote: /opt/chef/bin/ohai -v
- remote: /opt/chef/embedded/bin/gem install appbundler appbundle-updater --no-doc
- - remote: scl enable devtoolset-8 '/opt/chef/embedded/bin/appbundle-updater chef ohai <%= File.readlines('../Gemfile.lock', File.expand_path(File.dirname(__FILE__))).find { |l| l =~ /^\s+ohai \((\d+\.\d+\.\d+)\)/ }; 'v' + $1 %> --tarball --github chef/ohai'
- includes:
- - centos-6
- remote: scl enable devtoolset-8 '/opt/chef/embedded/bin/appbundle-updater chef chef <%= ENV['BUILDKITE_COMMIT'] || %x(git rev-parse HEAD).chomp %> --tarball --github chef/chef'
includes:
- centos-6
- - remote: /opt/chef/embedded/bin/appbundle-updater chef ohai <%= File.readlines('../Gemfile.lock', File.expand_path(File.dirname(__FILE__))).find { |l| l =~ /^\s+ohai \((\d+\.\d+\.\d+)\)/ }; 'v' + $1 %> --tarball --github chef/ohai
- excludes:
- - centos-6
- remote: /opt/chef/embedded/bin/appbundle-updater chef chef <%= ENV['BUILDKITE_COMMIT'] || %x(git rev-parse HEAD).chomp %> --tarball --github chef/chef
excludes:
- centos-6
diff --git a/lib/chef/application/base.rb b/lib/chef/application/base.rb
index ad8e8b69c2..450fd7673b 100644
--- a/lib/chef/application/base.rb
+++ b/lib/chef/application/base.rb
@@ -368,7 +368,7 @@ class Chef::Application::Base < Chef::Application
FileUtils.cp(url, path)
elsif URI::DEFAULT_PARSER.make_regexp.match?(url)
File.open(path, "wb") do |f|
- open(url) do |r|
+ URI.open(url) do |r|
f.write(r.read)
end
end
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index 094b59fc35..54d2a95ba3 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -858,8 +858,8 @@ class Chef
def profiling_prereqs!
require "ruby-prof"
- rescue LoadError
- raise "You must have the ruby-prof gem installed in order to use --profile-ruby"
+ rescue LoadError => e
+ raise "You must have the ruby-prof gem installed in order to use --profile-ruby: #{e.message}"
end
def start_profiling
diff --git a/lib/chef/node/attribute.rb b/lib/chef/node/attribute.rb
index 3383b3c7e5..6a8e72004b 100644
--- a/lib/chef/node/attribute.rb
+++ b/lib/chef/node/attribute.rb
@@ -158,8 +158,10 @@ class Chef
}.freeze
ENUM_METHODS.each do |delegated_method|
- define_method(delegated_method) do |*args, &block|
- merged_attributes.send(delegated_method, *args, &block)
+ if Hash.public_method_defined?(delegated_method)
+ define_method(delegated_method) do |*args, &block|
+ merged_attributes.send(delegated_method, *args, &block)
+ end
end
end
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb
index a0b569b8e3..e427cc0d24 100644
--- a/lib/chef/provider/package/rubygems.rb
+++ b/lib/chef/provider/package/rubygems.rb
@@ -189,7 +189,8 @@ class Chef
begin
rs = dependency_installer.resolve_dependencies gem_dependency.name, gem_dependency.requirement
rs.specs.find { |s| s.name == gem_dependency.name }
- rescue Gem::UnsatisfiableDependencyError
+ # ruby-3.0.0 versions of rubygems-3.x throws NoMethodError when the dep is not found
+ rescue Gem::UnsatisfiableDependencyError, NoMethodError
nil
end
end
diff --git a/post-bundle-install.rb b/post-bundle-install.rb
new file mode 100644
index 0000000000..f0db5d50b0
--- /dev/null
+++ b/post-bundle-install.rb
@@ -0,0 +1,27 @@
+#!/usr/bin/env ruby
+
+gem_home = Gem.paths.home
+
+puts "fixing bundle installed gems in #{gem_home}"
+
+# Install gems from git repos. This makes the assumption that there is a <gem_name>.gemspec and
+# you can simply gem build + gem install the resulting gem, so nothing fancy. This does not use
+# rake install since we need --conservative --minimal-deps in order to not install duplicate gems.
+#
+Dir["#{gem_home}/bundler/gems/*"].each do |gempath|
+ matches = File.basename(gempath).match(/(.*)-[A-Fa-f0-9]{12}/)
+ next unless matches
+
+ gem_name = matches[1]
+ next unless gem_name
+
+ puts "re-installing #{gem_name}..."
+
+ # we can't use "commmand" or "bundle" or "gem" DSL methods here since those are lazy and we need to run commands immediately
+ # (this is like a shell_out inside of a ruby_block in core chef, you don't use an execute resource inside of a ruby_block or
+ # things get really weird and unexpected)
+ Dir.chdir(gempath) do
+ system("gem build #{gem_name}.gemspec") or raise "gem build failed"
+ system("gem install #{gem_name}*.gem --conservative --minimal-deps --no-document") or raise "gem install failed"
+ end
+end
diff --git a/spec/data/rubygems.org/nonexistent_gem-info b/spec/data/rubygems.org/nonexistent_gem-info
new file mode 100644
index 0000000000..7e88a0e205
--- /dev/null
+++ b/spec/data/rubygems.org/nonexistent_gem-info
@@ -0,0 +1 @@
+This gem could not be found \ No newline at end of file
diff --git a/spec/data/rubygems.org/sexp_processor-info b/spec/data/rubygems.org/sexp_processor-info
new file mode 100644
index 0000000000..78add7f2fa
--- /dev/null
+++ b/spec/data/rubygems.org/sexp_processor-info
@@ -0,0 +1,49 @@
+---
+3.0.0 |checksum:ff9abf0d904ba57b9654352b396aa28cf6ad5315af99d8bbf664f5ff6efd3a5d
+3.0.1 |checksum:d012a759dc6950dcda667a359051c2e62e4bd19790aeed698a5e47d013ef3ae7
+3.0.2 |checksum:ba85e835493e6099c2f52937b77ce518d65af39409befdd9b43927c0a604ed87
+3.0.3 |checksum:a433b01d821f5e81200fbec77fc26a1ecb186ad7d8e40d19ed34ea295287170a
+3.0.4 |checksum:5f394545863d5abe5c3f53c3b883128f58900cd792504076a765b53c9a49f10a
+3.0.5 |checksum:8e06c84ed3a0159a0f2e6f7b10bbd056954ac2d33548318ccc3088556c8a8891
+3.0.6 |checksum:e6e0f30ff14b73b28f8e5803646aa6d2ed81b3b239e76815fd8160ea4121c650
+3.0.7 |checksum:7647c24bbebea0ef57a892953fc96349091924a399ee5d98f41da5d9db484816
+3.0.8 |checksum:6c8ff89feab635e332e115356451614a16d171485e34b6b30a6dea243caaaed7
+3.0.9 |checksum:b55c35100f5e1e191ff67eac8667aea9433d1492697c9434cdb35550cf6e4dd0
+3.0.10 |checksum:e168db8d4eccfc721685d939654698f1b419f018f45e38d17ab40033102987f4
+3.1.0 |checksum:3d9dd950ba0b235c4901d04e410c7e716feb491148bf0ca7daa0f510838b3bf7
+3.2.0 |checksum:5951f8d33ede2f68686c701142c6cc1004d6f525b0aa8e8279a1bf075542b0f0
+4.0.0 |checksum:36c185f8caecacb178500cabdc3e038862df640536c2e84ab763ae134462896f
+4.0.1 |checksum:efd33857c0f41a413ec3ea20251f43c4826fe8a11b01099335f4a3b6777eb727
+4.1.0 |checksum:d26879b9a0675ea156c82e26971149349a1474aac3da4d0d2a04cc18e6df73a3
+4.1.1 |checksum:15df4e54e0fab19e225862b36dff823d5b87d57ea998f2e47c52ce01de82b3d9
+4.1.2 |checksum:7c2ed2d62d0305f2c33cba2e99b288df0f3f4343c367b8ee8cad8c735abc8568
+4.1.3 |checksum:d02f1465c7f012f77a61abdaa841a5273a2277247bc143bfa11cf139a29dbdf8
+4.1.4 |checksum:f7798b1682dcf750dab5f4f8da548fee36f30864a4e4b0d8a63295d159357c3b
+4.1.5 |checksum:741c7dfe5e392ae39e22399546d25fe00ffdfc7a55e653e6a99b6770b1c0066c
+4.2.0 |checksum:3cde88e3d440f63af3cd48edca88bd98872622403740ecda78b7d27161367486
+4.2.1 |checksum:dfc3eef6ef13c5750c3faab782c4db6c74a7bcc5d03e56e4edeec21aab034185
+4.3.0 |checksum:7accb37900d1599c6f0f40be92bc62a5db4e5a7eb64f33a858cf83e798dd1ddc
+4.4.0 |checksum:71591ddbda99b5e12e4a46d377c87513850ca7aa4b1aa800ae02792cadee6be7
+4.4.1 |checksum:8a10333552216bf3d3846476cfe78dbc9b5724864e3f5016837724622d828f16
+4.4.2 |checksum:adba9d17de5957532223a1bf0e7bdba5ab849d6576e9210439a7d99e0cfa2595
+4.4.3 |checksum:b3eb96da1fe998f1c00665a9c645878518134cca7c35d39c4bb716e866f4cc57
+4.4.4 |checksum:43cab5a67ca409d62411f869ddb7a0a4de0988b489d3f1d610d9b6e521964fd5
+4.4.5 |checksum:af8713761f1b6604865830c54324e57c33e7cc05107ebdbee4e6d458f8f8fe7c
+4.5.0 |checksum:54d94dc52cf98a51548c8f3e77031a3347508b542b8cb066100ed3ac40c03081
+4.5.1 |checksum:1456a9be103bf1de0d34ff6980b77a5a72cf3d4b35bbd2182ac62506981a234c
+4.6.0 |checksum:e2498f90c75bd4c19d1739afadde8c03af26a881c8bd775f71d2f180de65b43f
+4.6.1 |checksum:e2e96c2ee3ea81e1dc7b4b4abee23b6e552e669cfe456ee69126a29a03373cd7
+4.7.0 |checksum:963a1f5b21c95595fb3cf1e8531784bf3d8fe30302cf6f271b08aefdc63e453f
+4.8.0 |checksum:5b9325f28b5be80ba8d43b7660f60ad67c9304fe8181dee89d3a348b13d2fada
+4.9.0 |checksum:333619bc71d563ee60f26fc5f3a7f57bd89ee3191177fdce87a014dcb1b8d3b0
+4.10.0b1 |checksum:8791e2006a2ddbf8dc96cfc19633de01af8cb8687703177a85aeb3f959974d5b,rubygems:> 1.3.1
+4.10.0 |checksum:b67a289ae4a3968d93dab0803d0ef5a262b6f94138ab98072e489d2aa8af4034
+4.10.1 |checksum:63d2297712eb1d6219ab1cb9207d9a239ac9ad20463c0b58ca865f0b46deb5ec
+4.11.0 |checksum:4c90ff17c492789fdd248369fa16ce65ef05576b3d9f593a49c6a0961dbcd5ee
+4.12.0 |checksum:671110574e96377a03b328bfb7f6339540443eca0b62913bf8fe38e9ebcb4470
+4.12.1 |checksum:f87cd92457a343b4e951e1f1ac3e8183f98de4640a32f6ceb44628332d21a088
+4.13.0 |checksum:47e86c22a2d7810897e3eae9669ab9afa220f5e6cea5ac1d47164650a9b857d3
+4.14.0 |checksum:99a20cc5e7b901f6b493a8ca5e13439b73b19671eaaca68a00216c4f66765edc
+4.14.1 |checksum:0fa8731445cf4a0c01570ec29aac4b50a0451ce66b1b31ad768f5035e3af7b90,ruby:~> 2.2
+4.15.0 |checksum:a5ec27d8055ad47444cfb7ce860bad8af2365772a82892f4a8a0d97e8e9e3b34,ruby:~> 2.2
+4.15.1 |checksum:9291a0f2247f50d15068ee6965b67cd7b678b0d273e18adf3c0b2ea4a890125c,ruby:< 3.1&>= 2.1
diff --git a/spec/functional/resource/chocolatey_package_spec.rb b/spec/functional/resource/chocolatey_package_spec.rb
index e55c1a453c..b5f4c07831 100644
--- a/spec/functional/resource/chocolatey_package_spec.rb
+++ b/spec/functional/resource/chocolatey_package_spec.rb
@@ -41,6 +41,19 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do
provider
end
+ # This bit of magic ensures that we pass a mixed-case Path var in the env to chocolatey and not PATH
+ # (both ENV["PATH"] and ENV["Path"] are the same thing in ruby-on-windows, and the first created key
+ # is the one that is actually passed to a subprocess, and choco demands it be Path)
+ #
+ # This is not a no-op.
+ #
+ # I don't know how to tell what state we were in to begin with, so we cannot restore. Nothing else
+ # seems to care.
+ #
+ before(:all) do
+ ENV["Path"] = ENV.delete("Path")
+ end
+
context "installing a package" do
after { remove_package }
diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb
index f9302a0bb2..16f4a7785b 100644
--- a/spec/unit/application/solo_spec.rb
+++ b/spec/unit/application/solo_spec.rb
@@ -108,7 +108,7 @@ describe Chef::Application::Solo do
tarfile = StringIO.new("remote_tarball_content")
target_file = StringIO.new
- expect(app).to receive(:open).with("http://junglist.gen.nz/recipes.tgz").and_yield(tarfile)
+ expect(URI).to receive(:open).with("http://junglist.gen.nz/recipes.tgz").and_yield(tarfile)
expect(File).to receive(:open).with("#{Dir.tmpdir}/chef-solo/recipes.tgz", "wb").and_yield(target_file)
archive = double(Mixlib::Archive)
diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb
index 9a12804443..61e0a80444 100644
--- a/spec/unit/data_bag_item_spec.rb
+++ b/spec/unit/data_bag_item_spec.rb
@@ -148,12 +148,7 @@ describe Chef::DataBagItem do
end
it "implements all the methods of Hash" do
- methods = %i{rehash to_hash [] fetch []= store default
- default= default_proc index size length
- empty? each_value each_key each_pair each keys values
- values_at delete delete_if reject! clear
- invert update replace merge! merge has_key? has_value?
- key? value?}
+ methods = Hash.public_instance_methods
methods.each do |m|
expect(data_bag_item).to respond_to(m)
end
diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb
index 6e78725bd9..e73d449225 100644
--- a/spec/unit/node/attribute_spec.rb
+++ b/spec/unit/node/attribute_spec.rb
@@ -898,7 +898,7 @@ describe Chef::Node::Attribute do
end
end
- describe "index" do
+ describe "index", ruby: "< 3.0.0" do
# Hash#index is deprecated and triggers warnings.
def silence
old_verbose = $VERBOSE
diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb
index 58a7eccb04..7153d6be3e 100644
--- a/spec/unit/provider/package/rubygems_spec.rb
+++ b/spec/unit/provider/package/rubygems_spec.rb
@@ -113,12 +113,11 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
end
it "finds a matching gem candidate version on rubygems 2.0.0+" do
- stub_request(:head, "https://rubygems.org/api/v1/dependencies")
-
- stub_request(:get, "https://rubygems.org/api/v1/dependencies?gems=sexp_processor")
- .to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor")))
-
- stub_request(:get, "https://rubygems.org/quick/Marshal.4.8/sexp_processor-4.15.1.gemspec.rz")
+ stub_request(:head, "https://index.rubygems.org/")
+ .to_return(status: 200, body: "", headers: {})
+ stub_request(:get, "https://index.rubygems.org/info/sexp_processor")
+ .to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor-info")))
+ stub_request(:get, "https://index.rubygems.org/quick/Marshal.4.8/sexp_processor-4.15.1.gemspec.rz")
.to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor-4.15.1.gemspec.rz")))
dep = Gem::Dependency.new("sexp_processor", ">= 0")
@@ -126,21 +125,20 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do
end
it "gives the candidate version as nil if none is found" do
- stub_request(:head, "https://rubygems.org/api/v1/dependencies")
-
- stub_request(:get, "https://rubygems.org/api/v1/dependencies?gems=nonexistent_gem")
- .to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "nonexistent_gem")))
+ stub_request(:head, "https://index.rubygems.org/")
+ .to_return(status: 200, body: "", headers: {})
+ stub_request(:get, "https://index.rubygems.org/info/nonexistent_gem")
+ .to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "nonexistent_gem-info")))
dep = Gem::Dependency.new("nonexistent_gem", ">= 0")
expect(@gem_env.candidate_version_from_remote(dep)).to be_nil
end
it "finds a matching gem from a specific gemserver when explicit sources are given (to a server that doesn't respond to api requests)" do
- stub_request(:head, "https://rubygems2.org/api/v1/dependencies")
-
- stub_request(:get, "https://rubygems2.org/api/v1/dependencies?gems=sexp_processor")
- .to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor")))
-
+ stub_request(:head, "https://rubygems2.org/")
+ .to_return(status: 200, body: "", headers: {})
+ stub_request(:get, "https://rubygems2.org/info/sexp_processor")
+ .to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor-info")))
stub_request(:get, "https://rubygems2.org/quick/Marshal.4.8/sexp_processor-4.15.1.gemspec.rz")
.to_return(status: 200, body: File.binread(File.join(CHEF_SPEC_DATA, "rubygems.org", "sexp_processor-4.15.1.gemspec.rz")))