# Java cookbook error on OSX

**URL:** <https://discourse.chef.io/t/java-cookbook-error-on-osx/5910>\
**Category:** Chef Infra (archive)\
**Created:** [November 10, 2014, 12:06pm UTC](https://discourse.chef.io/t/java-cookbook-error-on-osx/5910 "2014-11-10T12:06:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mukta\_A](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/mukta_a/32/194_2.png) [@Mukta\_A](https://discourse.chef.io/u/Mukta_A)\
**Post date:** [November 10, 2014, 12:06pm UTC](https://discourse.chef.io/t/java-cookbook-error-on-osx/5910/1 "2014-11-10T12:06:46Z")

</div>

Hi

I am getting this error while trying to run the Java cookbook on OSX (  
[https://supermarket.getchef.com/cookbooks/java](https://supermarket.getchef.com/cookbooks/java) ) -

Compiling Cookbooks…

Converging 4 resources

Recipe: java::openjdk

- package[openjdk-6-jdk] action install

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

```
Error executing action `install` on resource 'package[openjdk-6-jdk]'

```

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

```
Errno::ENOENT

-------------

No such file or directory - port

Resource Declaration:

---------------------

# In /var/chef/cache/cookbooks/java/recipes/openjdk.rb

 46: package pkg do

 47: version node['java']['openjdk_version'] if

```

node[‘java’][‘openjdk\_version’]

```
 48: end

 49: end

Compiled Resource:

------------------

# Declared in /var/chef/cache/cookbooks/java/recipes/openjdk.rb:46:in

```

`block in from\_file’

```
package("openjdk-6-jdk") do

  action :install

  retries 0

  retry_delay 2

  guard_interpreter :default

  package_name "openjdk-6-jdk"

  timeout 900

  cookbook_name "java"

  recipe_name "openjdk"

end

```

Please help.

Thanks,

Mukta.

---

<div class="post-metadata">

**Author:** ![kwilczynski](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kwilczynski/32/1713_2.png) [@kwilczynski](https://discourse.chef.io/u/kwilczynski)\
**Post date:** [November 10, 2014, 12:22pm UTC](https://discourse.chef.io/t/java-cookbook-error-on-osx/5910/2 "2014-11-10T12:22:52Z")

</div>

Hi,

On 10 November 2014 12:06, Mukta A [amukta@gmail.com](mailto:amukta@gmail.com) wrote:

[...]

> ```
> Errno::ENOENT
> 
> -------------
> 
> No such file or directory - port
> 
> ```

I believe that the `package` resource is trying to find MacPorts to  
install the package and failing at it.  
But, the underlying problem might be lack of support for OS X by the  
coobkook, as per [https://github.com/agileorbit-cookbooks/java](https://github.com/agileorbit-cookbooks/java)

Have a look at [GitHub - sous-chefs/homebrew: Development repository for the homebrew cookbook](https://github.com/opscode-cookbooks/homebrew),  
especially the additional Homebrew Casks.

Hope this helps.

Regards,  
Krzysztof

---

<div class="post-metadata">

**Author:** ![Joshua\_Timberman1](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/joshua_timberman1/32/188_2.png) [@Joshua\_Timberman1](https://discourse.chef.io/u/Joshua_Timberman1)\
**Post date:** [November 10, 2014, 6:05pm UTC](https://discourse.chef.io/t/java-cookbook-error-on-osx/5910/3 "2014-11-10T18:05:46Z")

</div>

Hello,

As Krzysztof said, the default package provider on OS X when using Chef 11  
or earlier is Macports, so the package resource is attempting to determine  
the state of the "openjdk-6-jdk" package using the "port" command. Since  
you don't have Macports installed, that fails.

However, it's worth noting that the java cookbook does not support OS X for  
Java installation at this time. Since Apple makes Java installation  
available through their own means[0](http://support.apple.com/kb/DL1572), I don't know that it would be in  
scope to attempt to support it using the "package" resource.

Also note that in Chef 12, homebrew will be the default package provider  
for OS X[1].

[1]: [http://docs.getchef.com/release/12-0/release\_notes.html#what-s-new](http://docs.getchef.com/release/12-0/release_notes.html#what-s-new) -  
"homebrew\_package"

On Mon, Nov 10, 2014 at 5:06 AM, Mukta A [amukta@gmail.com](mailto:amukta@gmail.com) wrote:

> Hi
> 
> I am getting this error while trying to run the Java cookbook on OSX (  
> [https://supermarket.getchef.com/cookbooks/java](https://supermarket.getchef.com/cookbooks/java) ) -
> 
> Compiling Cookbooks...
> 
> Converging 4 resources
> 
> Recipe: java::openjdk
> 
> - package[openjdk-6-jdk] action install
> 
> ================================================================================
> 
> ```
> Error executing action `install` on resource 'package[openjdk-6-jdk]'
> 
> ```
> 
> ================================================================================
> 
> ```
> Errno::ENOENT
> 
> -------------
> 
> No such file or directory - port
> 
> Resource Declaration:
> 
> ---------------------
> 
> # In /var/chef/cache/cookbooks/java/recipes/openjdk.rb
> 
> 46: package pkg do
> 
> 47: version node['java']['openjdk_version'] if
> 
> ```
> 
> node['java']['openjdk\_version']
> 
> ```
> 48: end
> 
> 49: end
> 
> Compiled Resource:
> 
> ------------------
> 
> # Declared in /var/chef/cache/cookbooks/java/recipes/openjdk.rb:46:in
> 
> ```
> 
> `block in from\_file'
> 
> ```
> package("openjdk-6-jdk") do
> 
> action :install
> 
> retries 0
> 
> retry_delay 2
> 
> guard_interpreter :default
> 
> package_name "openjdk-6-jdk"
> 
> timeout 900
> 
> cookbook_name "java"
> 
> recipe_name "openjdk"
> 
> end
> 
> ```
> 
> Please help.
> 
> Thanks,
> 
> Mukta.

--  
Joshua Timberman, Chef.

---

<div class="post-metadata">

**Author:** ![jdunn](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jdunn/32/1800_2.png) [@jdunn](https://discourse.chef.io/u/jdunn)\
**Post date:** [November 10, 2014, 11:48pm UTC](https://discourse.chef.io/t/java-cookbook-error-on-osx/5910/4 "2014-11-10T23:48:48Z")

</div>

On Mon, Nov 10, 2014 at 1:05 PM, Joshua Timberman [joshua@getchef.com](mailto:joshua@getchef.com) wrote:

> However, it's worth noting that the java cookbook does not support OS X for  
> Java installation at this time. Since Apple makes Java installation  
> available through their own means[0], I don't know that it would be in scope  
> to attempt to support it using the "package" resource.

That's correct, the Java cookbook does not support OS X as a platform  
because the installation mechanism is so different.

I've attempted to automate Mac Java installs in Chef before, so this  
code might be of interest to you. I can't guarantee that it still  
works as it's about a year old and Apple changes things all the time.

> <https://github.com/chef-osx/macapps/blob/master/recipes/java.rb>

- Julian

--  
[Julian C. Dunn [jdunn@aquezada.com](mailto:jdunn@aquezada.com) \* Sorry, I'm ]  
[WWW: [http://www.aquezada.com/staff/julian](http://www.aquezada.com/staff/julian) \* only Web 1.0 ]  
[gopher://sdf.org/1/users/keymaker/ \* compliant!]  
[PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9]

---

<div class="post-metadata">

**Author:** ![Mukta\_A](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/mukta_a/32/194_2.png) [@Mukta\_A](https://discourse.chef.io/u/Mukta_A)\
**Post date:** [November 11, 2014, 3:40am UTC](https://discourse.chef.io/t/java-cookbook-error-on-osx/5910/5 "2014-11-11T03:40:15Z")

</div>

Thanks.  
I will try out the cookbook suggested by Julian. I am trying to install  
IntelliJ using Chef so would have to make some more changes.

On 11 November 2014 05:18, Julian C. Dunn [jdunn@aquezada.com](mailto:jdunn@aquezada.com) wrote:

> On Mon, Nov 10, 2014 at 1:05 PM, Joshua Timberman [joshua@getchef.com](mailto:joshua@getchef.com)  
> wrote:
> 
> > However, it's worth noting that the java cookbook does not support OS X  
> > for  
> > Java installation at this time. Since Apple makes Java installation  
> > available through their own means[0], I don't know that it would be in  
> > scope  
> > to attempt to support it using the "package" resource.
> 
> That's correct, the Java cookbook does not support OS X as a platform  
> because the installation mechanism is so different.
> 
> I've attempted to automate Mac Java installs in Chef before, so this  
> code might be of interest to you. I can't guarantee that it still  
> works as it's about a year old and Apple changes things all the time.
> 
> [https://github.com/chef-osx/macapps/blob/master/recipes/java.rb](https://github.com/chef-osx/macapps/blob/master/recipes/java.rb)
> 
> - Julian
> 
> --  
> [Julian C. Dunn [jdunn@aquezada.com](mailto:jdunn@aquezada.com) \* Sorry, I'm ]  
> [WWW: [http://www.aquezada.com/staff/julian](http://www.aquezada.com/staff/julian) \* only Web 1.0 ]  
> [gopher://sdf.org/1/users/keymaker/ \* compliant!]  
> [PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9]

---

<div class="post-metadata">

**Author:** ![Tyler](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/tyler/32/205_2.png) [@Tyler](https://discourse.chef.io/u/Tyler)\
**Post date:** [November 11, 2014, 7:43pm UTC](https://discourse.chef.io/t/java-cookbook-error-on-osx/5910/6 "2014-11-11T19:43:00Z")

</div>

I haven’t tested this, but you could also try the Homebrew Cask: [https://github.com/caskroom/homebrew-cask/blob/master/Casks/intellij-idea-ce.rb](https://github.com/caskroom/homebrew-cask/blob/master/Casks/intellij-idea-ce.rb) [https://github.com/caskroom/homebrew-cask/blob/master/Casks/intellij-idea-ce.rb](https://github.com/caskroom/homebrew-cask/blob/master/Casks/intellij-idea-ce.rb)

-T

> On Nov 10, 2014, at 7:40 PM, Mukta A [amukta@gmail.com](mailto:amukta@gmail.com) wrote:
> 
> Thanks.  
> I will try out the cookbook suggested by Julian. I am trying to install IntelliJ using Chef so would have to make some more changes.
> 
> On 11 November 2014 05:18, Julian C. Dunn \<[jdunn@aquezada.com](mailto:jdunn@aquezada.com) [mailto:jdunn@aquezada.com](mailto:jdunn@aquezada.com)\> wrote:  
> On Mon, Nov 10, 2014 at 1:05 PM, Joshua Timberman \<[joshua@getchef.com](mailto:joshua@getchef.com) [mailto:joshua@getchef.com](mailto:joshua@getchef.com)\> wrote:
> 
> > However, it's worth noting that the java cookbook does not support OS X for  
> > Java installation at this time. Since Apple makes Java installation  
> > available through their own means[0], I don't know that it would be in scope  
> > to attempt to support it using the "package" resource.
> 
> That's correct, the Java cookbook does not support OS X as a platform  
> because the installation mechanism is so different.
> 
> I've attempted to automate Mac Java installs in Chef before, so this  
> code might be of interest to you. I can't guarantee that it still  
> works as it's about a year old and Apple changes things all the time.
> 
> [https://github.com/chef-osx/macapps/blob/master/recipes/java.rb](https://github.com/chef-osx/macapps/blob/master/recipes/java.rb) [https://github.com/chef-osx/macapps/blob/master/recipes/java.rb](https://github.com/chef-osx/macapps/blob/master/recipes/java.rb)
> 
> - Julian
> 
> --  
> [Julian C. Dunn \<[jdunn@aquezada.com](mailto:jdunn@aquezada.com) [mailto:jdunn@aquezada.com](mailto:jdunn@aquezada.com)\> \* Sorry, I'm ]  
> [WWW: [http://www.aquezada.com/staff/julian](http://www.aquezada.com/staff/julian) [http://www.aquezada.com/staff/julian](http://www.aquezada.com/staff/julian) \* only Web 1.0 ]  
> [gopher://sdf.org/1/users/keymaker/ [http://sdf.org/1/users/keymaker/](http://sdf.org/1/users/keymaker/) \* compliant! ]  
> [PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9]
