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

Error: Facter: Error while resolving custom fact fact='root_home', resolution='<anonymous>': undefined method `dir' for nil:NilClass #1293

Closed
hboetes opened this issue Feb 6, 2023 · 4 comments · Fixed by #1295

Comments

@hboetes
Copy link

hboetes commented Feb 6, 2023

Reading this code it looks like it takes windows into account.

# frozen_string_literal: true

Facter.add(:root_home) do
  setcode do
    require 'etc'
  rescue LoadError
  # Unavailable on platforms like Windows
  else
    Etc.getpwnam('root').dir
  end
end

But I always get this error, whilst running on windows.

Error: Facter: Error while resolving custom fact fact='root_home', resolution='<anonymous>': undefined method `dir' for nil:NilClass
@ekohl
Copy link
Collaborator

ekohl commented Feb 15, 2023

That's interesting. From reading the source I figured etc would never be available on Windows, but it may be. Could you try out #1295 and approve if it works for you? I don't have a Windows setup to verify it.

@hboetes
Copy link
Author

hboetes commented Feb 16, 2023

I don't have the approve button available, but I did drop a line of approval.

@ekohl
Copy link
Collaborator

ekohl commented Feb 16, 2023

Technically everyone can approve a PR. You need to go to the files tab. There's a big green "Review changes" button where you can approve. If you have permissions, the checkmark is green, otherwise it'll be grey. But a text is also fine. We're not that formal.

@LukasAud
Copy link
Contributor

LukasAud commented Mar 9, 2023

PR merged. Issue closed automatically. Hopefully that bugfix resolves your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants