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

NoMethodError: undefined method `path' for Chef::Resource::Execute #2545

Closed
jtimberman opened this issue Dec 5, 2014 · 10 comments
Closed

NoMethodError: undefined method `path' for Chef::Resource::Execute #2545

jtimberman opened this issue Dec 5, 2014 · 10 comments
Labels
documentation How do we use this project? Type: Bug Does not work as expected.
Milestone

Comments

@jtimberman
Copy link
Contributor

In Chef 12, using an execute resource with a path attribute results in a NoMethodError exception.

More details coming, wanted to get this created.

@jjasghar
Copy link
Contributor

jjasghar commented Dec 5, 2014

We saw this in the rabbitmq cookbook: rabbitmq/chef-cookbook#175

@jtimberman
Copy link
Contributor Author

This is missing because path was removed from the execute resource in commit 28fd0c9. Per the commit message, there was no implementation of this in underlying providers. If cookbooks worked prior to Chef 12, then it may be only by accident - it's hard to know without a case-by-case evaluation (and we certainly can't do that for everything). The right thing to do is to use the environment attribute to set the path. As an implementation example:

execute "mycommand" do
  environment "PATH" => "/my/path/to/bin:#{ENV["PATH"]}"
end

Note that environment overwrites the entire $PATH here, as it is not additive, hence the string interpolation w/ ENV['PATH'] (the $PATH that chef was executed under).

@jtimberman
Copy link
Contributor Author

Per @sersut:

In Chef 11 we had a path attribute for the execute resource but it was not honored by the provider and was not being used. For cleanup we've removed this in Chef 12. This change made client to raise an error rather than accepting and not using it when path attribute is used in execute resource. Workaround is to use environment attribute to set PATH in the execute resource.

We'll note this as a known issue in the release blog post for Chef 12, and ensure the appropriate documentation is updated.

@kwilczynski
Copy link
Contributor

I would propose adding a deprecation warning there (to the Chef client, not to cookbook). A big fat one. Primarily to ease customers into the transition where we introduce braking change in the API. There is a big difference between path doing nothing and path not being there. My humble opinion on the subject.

@lamont-granquist
Copy link
Contributor

Yeah we probably should have had a deprecation warning first in a world with perfect process, but I think this has shipped in a dot-0 major release and the breakage is acceptable and the new behavior is correct, and we should not revert.

@hulu1522
Copy link

hulu1522 commented Dec 6, 2014

Just a note, it is also affecting the postgresql::ruby recipe here:

https://github.com/hw-cookbooks/postgresql/blob/develop/recipes/ruby.rb#L88

@jtimberman
Copy link
Contributor Author

@hulu1522 That isn't related to this issue, which addresses removal of the path attribute from the execute resource, which means this no longer works:

execute "mycommand" do
  path "/home/mystuff/bin:#{ENV['PATH']}"
end

The issue with the postgresql::ruby cookbook is separate and any failure there should be filed as an issue against that cookbook (if one doesn't exist).

@jtimberman
Copy link
Contributor Author

I see you found the issue 🍰. I'll reply there.

@adamhjk
Copy link
Contributor

adamhjk commented Dec 8, 2014

We should put this back in. It's a tiny fix that doesn't cause any problems to anyone, and hopefully cut a release. Feel free to put a deprecation warning back in.

@sersut
Copy link
Contributor

sersut commented Dec 9, 2014

Fixed with #2571

@sersut sersut closed this as completed Dec 9, 2014
jamescott pushed a commit to chef-boneyard/chef-web-docs-2016 that referenced this issue Dec 9, 2014
@thommay thommay added Type: Bug Does not work as expected. Type: Documentation and removed Bug labels Jan 25, 2017
@chef chef locked and limited conversation to collaborators Nov 16, 2017
@tas50 tas50 added documentation How do we use this project? and removed Aspect: Documentation labels May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation How do we use this project? Type: Bug Does not work as expected.
Projects
None yet
Development

No branches or pull requests

9 participants