# Bash Resource Not Reading User/CWD Attribute in Chef 11.10

**URL:** https://discourse.chef.io/t/bash-resource-not-reading-user-cwd-attribute-in-chef-11-10/7302
**Category:** Chef Infra (archive)
**Created:** [November 12, 2015, 12:15am UTC](https://discourse.chef.io/t/bash-resource-not-reading-user-cwd-attribute-in-chef-11-10/7302 "2015-11-12T00:15:25Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jcderose](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jcderose/32/1149_2.png) [@jcderose](https://discourse.chef.io/u/jcderose)
#### Post date: [November 12, 2015, 12:15am UTC](https://discourse.chef.io/t/bash-resource-not-reading-user-cwd-attribute-in-chef-11-10/7302/1 "2015-11-12T00:15:25Z")

</div>

I’m running a local Ubuntu 14.04 VM with Chef 11.10 via Test Kitchen. I want to sync files between an AWS S3 bucket and my local directory via ‘aws s3 sync’ but “kitchen converge” keeps erroring out stating “Unable to locate credentials”. However, I’m able to su and run the command successfully via the CLI (within the VM).

Here is the code in question (in my recipe):

bash ‘Sync WordPress content from S3 bucket’ do  
user 'anyperk’  
cwd '/home/anyperk/'  
code \<\<-EOH  
aws s3 sync --region us-west-1 s3://path/to/bucket/ .  
EOH  
end

And here is the error output:

> <https://gist.github.com/jcderose/4dfa9864d60dca9851da>

---

<div class="post-metadata">

### Author: ![coderanger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/coderanger/32/5_2.png) [@coderanger](https://discourse.chef.io/u/coderanger)
#### Post date: [November 12, 2015, 12:23am UTC](https://discourse.chef.io/t/bash-resource-not-reading-user-cwd-attribute-in-chef-11-10/7302/2 "2015-11-12T00:23:27Z")

</div>

Good money says you need to set $HOME in the environment as well. Newer versions of chef do this for you, but you’ll just have to do it manually in the resource:

```ruby
bash 'Sync WordPress content from S3 bucket' do
  user 'anyperk'
  cwd '/home/anyperk/'
  environment 'HOME' => '/home/anyperk'
  code 'aws s3 sync --region us-west-1 s3://path/to/bucket/ .'
end

```

---

<div class="post-metadata">

### Author: ![jcderose](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jcderose/32/1149_2.png) [@jcderose](https://discourse.chef.io/u/jcderose)
#### Post date: [November 12, 2015, 12:41am UTC](https://discourse.chef.io/t/bash-resource-not-reading-user-cwd-attribute-in-chef-11-10/7302/3 "2015-11-12T00:41:42Z")

</div>

Thanks, @coderanger! Setting the $HOME environment variable resolved my problem.
