# Chef recipe error

**URL:** <https://discourse.chef.io/t/chef-recipe-error/4408>\
**Category:** Chef Infra (archive)\
**Created:** [September 3, 2013, 6:39am UTC](https://discourse.chef.io/t/chef-recipe-error/4408 "2013-09-03T06:39:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Montgomery](https://avatars.discourse-cdn.com/v4/letter/d/51bf81/32.png) [@David\_Montgomery](https://discourse.chef.io/u/David_Montgomery)\
**Post date:** [September 3, 2013, 6:39am UTC](https://discourse.chef.io/t/chef-recipe-error/4408/1 "2013-09-03T06:39:26Z")

</div>

Hi,

Rather dumfounded on why I get an error with this recipe…The file is  
there. Why does chef complain that it is not? This should be so  
simple…a template changes then source my .bashrc file.

ubuntu@ubuntu:~$ ls /home/ubuntu/.bash\_includes  
/home/ubuntu/.bash\_includes

execute “add\_include\_to\_bashrc” do  
user “ubuntu"  
command “echo ‘source /home/ubuntu/.bash\_includes’ | tee -a  
/home/ubuntu/.bashrc"  
action :run  
ignore\_failure true  
not\_if {File.exists?(”/home/ubuntu/.bash\_includes”)}  
end

execute “source\_bashrc” do  
user "ubuntu"  
command "source /home/ubuntu/.bashrc"  
action :nothing  
end

template “/home/ubuntu/.bash\_includes” do  
path "/home/ubuntu/.bash\_includes"  
source "bash\_includes.erb"  
owner "ubuntu"  
group "ubuntu"  
mode "0770"  
notifies :run, “execute[source\_bashrc]”, :immediately  
end

# ================================================================================ Error executing action `run` on resource ‘execute[source\_bashrc]’

## Errno::ENOENT

No such file or directory - source /home/ubuntu/.bashrc

## Resource Declaration:

# In /home/ubuntu/workspace/Chef/chef-repo/cookbooks/bash/recipes/local.rb

12: execute “source\_bashrc” do  
13: user "ubuntu"  
14: command "source /home/ubuntu/.bashrc"  
15: action :nothing  
16: end  
17:

## Compiled Resource:

# Declared in

/home/ubuntu/workspace/Chef/chef-repo/cookbooks/bash/recipes/local.rb:12:in  
`from\_file’

execute(“source\_bashrc”) do  
action [:nothing]  
retries 0  
retry\_delay 2  
command "source /home/ubuntu/.bashrc"  
backup 5  
returns 0  
user "ubuntu"  
cookbook\_name :bash  
recipe\_name "local"  
end

---

<div class="post-metadata">

**Author:** ![Tensibai](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/tensibai/32/29_2.png) [@Tensibai](https://discourse.chef.io/u/Tensibai)\
**Post date:** [September 3, 2013, 9:13am UTC](https://discourse.chef.io/t/chef-recipe-error/4408/2 "2013-09-03T09:13:20Z")

</div>

Le 2013-09-03 08:39, David Montgomery a écrit :

> 

================================================================================

> 

Error executing action `run` on resource 'execute[source\_bashrc]'

> 

================================================================================

> 

> ## Errno::ENOENT
> 
> No such file or directory - source  
> /home/ubuntu/.bashrc
> 
> Resource Declaration:

* * *

> # In

/home/ubuntu/workspace/Chef/chef-repo/cookbooks/bash/recipes/local.rb

> 

> 12: execute "source\_bashrc" do  
> 13: user "ubuntu"  
> 14: command  
> "source /home/ubuntu/.bashrc"  
> 15: action :nothing  
> 16: end

17:

Quite clear I think, you're trying to execute a command named  
source by a system call, source is a bult-in inside bash/tcsh/etc.

Change your resource to be bash.

Seen on [docs.opscode.com](http://docs.opscode.com) for the  
execute resource:

SOURCING A FILE

The EXECUTE resource cannot be  
used to source a file (e.g. command "source filename"). The following  
example will fail becausesource is not an executable:

execute "foo"  
do  
command "source /tmp/foo.sh"  
end

Instead, use the SCRIPT resource  
or one of the SCRIPT-based resources (BASH, CSH, PERL, PYTHON, or RUBY).  
For example:

bash "foo" do  
code "source  
/tmp/foo.sh"  
end

regards,

Tensibai

---

<div class="post-metadata">

**Author:** ![kallistec](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallistec/32/23_2.png) [@kallistec](https://discourse.chef.io/u/kallistec)\
**Post date:** [September 3, 2013, 3:34pm UTC](https://discourse.chef.io/t/chef-recipe-error/4408/3 "2013-09-03T15:34:32Z")

</div>

On Tuesday, September 3, 2013 at 2:13 AM, Tensibai wrote:

> Le 2013-09-03 08:39, David Montgomery a écrit :
> 
> > # ================================================================================ Error executing action `run` on resource 'execute[source\_bashrc]'
> > 
> > ## Errno::ENOENT
> > 
> > No such file or directory - source /home/ubuntu/.bashrc
> > 
> > ## Resource Declaration:
> > 
> > # In /home/ubuntu/workspace/Chef/chef-repo/cookbooks/bash/recipes/local.rb
> > 
> > 12: execute "source\_bashrc" do  
> > 13: user "ubuntu"  
> > 14: command "source /home/ubuntu/.bashrc"  
> > 15: action :nothing  
> > 16: end  
> > 17:
> 
> Quite clear I think, you're trying to execute a command named source by a system call, source is a bult-in inside bash/tcsh/etc.  
> Change your resource to be bash.  
> Seen on [docs.opscode.com](http://docs.opscode.com) ([http://docs.opscode.com](http://docs.opscode.com)) for the execute resource:  
> Sourcing a file  
> The execute resource cannot be used to source a file (e.g. command "source filename"). The following example will fail becausesource is not an executable:  
> execute "foo" do command "source /tmp/foo.sh ([http://foo.sh](http://foo.sh))" end
> 
> Instead, use the script resource or one of the script-based resources (bash, csh, perl, python, or ruby). For example:  
> bash "foo" do code "source /tmp/foo.sh ([http://foo.sh](http://foo.sh))" end
> 
> regards,
> 
> Tensibai

Additionally, this command isn't going to have the result you're expecting. UNIX processes inherit environment variables from their parent process, but changing environment variables in the child won't affect the parent (if this wasn't the case, changes to things like HOME and PATH would propagate all the way back up to init, and then back down to other users' shells and such).

If you need to set environment variables so that every command chef executes has access to them, then you need to set them via ruby's ENV, for example:

ENV["PATH"] = "/opt/something/bin:" + ENV["PATH"]

If you only need to set the environment for one or two commands, you can do this with the `environment` attribute of the execute resource: [http://docs.opscode.com/resource\_execute.html#attributes](http://docs.opscode.com/resource_execute.html#attributes)

## HTH,

Daniel DeLeo
