Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ohai always detects the embedded Ruby in the languages plugin since Chef 16 #1684

Open
ziggythehamster opened this issue Jul 31, 2021 · 1 comment
Labels
Status: Untriaged An issue that has yet to be triaged. Type: Bug Does not work as expected.

Comments

@ziggythehamster
Copy link
Contributor

ziggythehamster commented Jul 31, 2021

Description

There seems to have been a change in Chef 16 that makes it prepend the embedded Ruby directories to PATH when using shell_out: https://github.com/chef/chef/blob/chef-16/chef-utils/lib/chef-utils/dsl/default_paths.rb

For the Ruby Ohai plugin, I can't think of a single situation where you would want this. You want plugins to pretend the embedded Chef Ruby doesn't exist when they're examining the system.

Ohai Version

16.13.0, but I see the same code path in master

Platform Version

Debian 10, CentOS 8

Ohai Output

Here's the node['languages']['ruby'] that I get since this change:

{
  "platform": "x86_64-linux",
  "version": "2.7.3",
  "release_date": "2021-04-05",
  "target": "x86_64-pc-linux-gnu",
  "target_cpu": "x86_64",
  "target_vendor": "pc",
  "target_os": "linux",
  "host": "x86_64-pc-linux-gnu",
  "host_cpu": "x86_64",
  "host_os": "linux",
  "host_vendor": "pc",
  "bin_dir": "/opt/cinc/embedded/bin",
  "ruby_bin": "/opt/cinc/embedded/bin/ruby",
  "gem_bin": "/opt/cinc/embedded/bin/gem",
  "gems_dir": "/opt/cinc/embedded/lib/ruby/gems/2.7.0"
}

This is what I should be getting:

{
  "platform": "x86_64-linux",
  "version": "2.6.2",
  "release_date": "2019-03-13",
  "target": "x86_64-pc-linux-gnu",
  "target_cpu": "x86_64",
  "target_vendor": "pc",
  "target_os": "linux",
  "host": "x86_64-pc-linux-gnu",
  "host_cpu": "x86_64",
  "host_os": "linux-gnu",
  "host_vendor": "pc",
  "bin_dir": "/usr/local/bin",
  "ruby_bin": "/usr/local/bin/ruby",
  "gem_bin": "/usr/local/bin/gem",
  "gems_dir": "/usr/local/lib/ruby/gems/2.6.0"
}

Workaround

sed -i 's/so = shell_out(cmd)/so = shell_out(cmd, default_env: false)/' /opt/$CHEF_OR_CINC/embedded/lib/ruby/gems/*/gems/ohai-*/lib/ohai/plugins/ruby.rb

I am not familiar enough with the internals here to know if the above is the right solution or not... but it does work :)

@ziggythehamster ziggythehamster added Status: Untriaged An issue that has yet to be triaged. Type: Bug Does not work as expected. labels Jul 31, 2021
@lamont-granquist
Copy link
Contributor

that's probably easy enough to fix with internal: false

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Untriaged An issue that has yet to be triaged. Type: Bug Does not work as expected.
Projects
None yet
Development

No branches or pull requests

2 participants