# Cannot find profile files error

**URL:** <https://discourse.chef.io/t/cannot-find-profile-files-error/12993>\
**Category:** Chef InSpec\
**Created:** [May 2, 2018, 11:16am UTC](https://discourse.chef.io/t/cannot-find-profile-files-error/12993 "2018-05-02T11:16:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruud.goossens](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@ruud.goossens](https://discourse.chef.io/u/ruud.goossens)\
**Post date:** [May 2, 2018, 11:16am UTC](https://discourse.chef.io/t/cannot-find-profile-files-error/12993/1 "2018-05-02T11:16:08Z")

</div>

I’m trying out the [example using profile files](https://www.inspec.io/docs/reference/profiles/#profile-files) but when I run it I get the following error:

```
Cannot find file services.yml in profile.

```

Or when I run inspec check

```
/home/user/.gem/gems/inspec-2.1.59/lib/inspec/runtime_profile.rb:23:in `file': Cannot find file services.yml in profile. (RuntimeError)
	from controls/example-file.rb:6:in `load_with_context'
	from /home/user/.gem/gems/inspec-2.1.59/lib/inspec/profile_context.rb:158:in `instance_eval'
	from /home/user/.gem/gems/inspec-2.1.59/lib/inspec/profile_context.rb:158:in `load_with_context'
	from /home/user/.gem/gems/inspec-2.1.59/lib/inspec/profile_context.rb:142:in `load_control_file'
	from /home/user/.gem/gems/inspec-2.1.59/lib/inspec/profile.rb:170:in `block in collect_tests'
	from /home/user/.gem/gems/inspec-2.1.59/lib/inspec/profile.rb:167:in `each'
	from /home/user/.gem/gems/inspec-2.1.59/lib/inspec/profile.rb:167:in `collect_tests'
	from /home/user/.gem/gems/inspec-2.1.59/lib/inspec/profile.rb:473:in `load_checks_params'
	from /home/user/.gem/gems/inspec-2.1.59/lib/inspec/profile.rb:466:in `load_params'
	from /home/user/.gem/gems/inspec-2.1.59/lib/inspec/profile.rb:160:in `params'
	from /home/user/.gem/gems/inspec-2.1.59/lib/inspec/profile.rb:326:in `controls_count'
	from /home/user/.gem/gems/inspec-2.1.59/lib/inspec/profile.rb:297:in `check'
	from /home/user/.gem/gems/inspec-2.1.59/lib/inspec/cli.rb:76:in `check'
	from /home/user/.gem/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
	from /home/user/.gem/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
	from /home/user/.gem/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
	from /home/user/.gem/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
	from /home/user/.gem/gems/inspec-2.1.59/bin/inspec:12:in `<top (required)>'
	from /home/user/.gem/bin/inspec:23:in `load'
	from /home/user/.gem/bin/inspec:23:in `<main>'

% inspec --version
2.1.59
% ruby --version
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux]

```

I’ve tried to load in all manners I could fine online:

1. 

`my_services = yaml(content: inspec.profile.file('services.yml')).params`

1. 

`my_services = YAML.load(inspec.profile.file('services.yml'))`

1. 

`content = inspec.profile.file("services.yml")`  
`my_services = YAML.parse(content)`

---

<div class="post-metadata">

**Author:** ![simark](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/simark/32/2099_2.png) [@simark](https://discourse.chef.io/u/simark)\
**Post date:** [May 2, 2018, 11:42am UTC](https://discourse.chef.io/t/cannot-find-profile-files-error/12993/2 "2018-05-02T11:42:19Z")

</div>

Hi @ruud.goossens

I usually do it this way

- `./controls/default.rb`

```ruby
_default = YAML.load_file(File.join(File.dirname( __FILE__ ), '../attributes/default.yml'))

```

This is the following structure I use in this case

```auto
.
├── attributes
│ └── default.yml
├── controls
│ └── default.rb
├── inspec.yml
└── README.md

```

---

<div class="post-metadata">

**Author:** ![ruud.goossens](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@ruud.goossens](https://discourse.chef.io/u/ruud.goossens)\
**Post date:** [May 2, 2018, 7:23pm UTC](https://discourse.chef.io/t/cannot-find-profile-files-error/12993/3 "2018-05-02T19:23:15Z")

</div>

Thanks, that works. It seems that the inspec.profile.file method contains some kind of bug?

---

<div class="post-metadata">

**Author:** ![simark](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/simark/32/2099_2.png) [@simark](https://discourse.chef.io/u/simark)\
**Post date:** [May 2, 2018, 8:30pm UTC](https://discourse.chef.io/t/cannot-find-profile-files-error/12993/4 "2018-05-02T20:30:25Z")

</div>

It should work... were your files placed in the `./files/` folder within your profile?  
Here is the github issue where they discussed the implementation of this feature:  
[https://github.com/chef/inspec/issues/1396](https://github.com/chef/inspec/issues/1396)

---

<div class="post-metadata">

**Author:** ![ruud.goossens](https://avatars.discourse-cdn.com/v4/letter/r/919ad9/32.png) [@ruud.goossens](https://discourse.chef.io/u/ruud.goossens)\
**Post date:** [May 3, 2018, 7:51am UTC](https://discourse.chef.io/t/cannot-find-profile-files-error/12993/5 "2018-05-03T07:51:18Z")

</div>

Yes, files are placed in ./files directory in the profile dir.

I’ve retested with use of the docker workstation container that was created as part of the [Inspec tutorial](https://learn.chef.io/modules/try-inspec#/). Same issue, so I’m really starting to think this is a bug. How can I create a bug report?

```
% docker exec -it workstation bash
root@3b13b29b652b:/# cd /root
root@3b13b29b652b:~# inspec init profile example
Create new profile at /root/example
 * Create file README.md
 * Create directory controls
 * Create file controls/example.rb
 * Create file inspec.yml
 * Create directory libraries
root@3b13b29b652b:~# mkdir -p example/files         
root@3b13b29b652b:~# vi example/files/services.yml
root@3b13b29b652b:~# vi example/controls/example.rb 
root@3b13b29b652b:~# inspec exec example/controls/example.rb 
Cannot find file services.yml in profile.

root@3b13b29b652b:~# tree example/
example/
|-- README.md
|-- controls
| `-- example.rb
|-- files
| `-- services.yml
|-- inspec.yml
`-- libraries

3 directories, 4 files

```

**example/controls/example.rb**

```
# encoding: utf-8
# copyright: 2018, The Authors

title 'sample section'

my_services = yaml(content: inspec.profile.file('services.yml')).params

my_services.each do |s|
  describe service(s['service_name']) do
    it { should be_running }
  end

  describe port(s['port']) do
    it { should be_listening }
  end
end

```

**example/files/services.yml**

```
- service_name: httpd-alpha
  port: 80
- service_name: httpd-beta
  port: 8080
```
