title: Compile time vs. run time in Chef recipes
body: <p>I have the following (simplified) recipe called java, to install Java of course.</p>
  
  <p>File recipes/default.rb</p>
  
  <pre><code>include_recipe "install_java"
  </code></pre>
  
  <p>File recipes/install_java.rb</p>
  
  <pre><code># Install RPM from yum repo via yum_install library function
  yum_install("jdk1.7.0_51")
  
  # List the directories in /usr/java
  jdk_dir = `ls -ld /usr/java/jdk1.* | sort | tail -1`
  if jdk_dir.empty?
    raise "Missing JDK installation"
  end
  </code></pre>
  
  <p>When I run the recipe by "chef-client -o recipe[java]"</p>
  
  <pre><code>Synchronizing Cookbooks:
    - java
  Compiling Cookbooks...
  ls: /usr/java/jdk1.*: No such file or directory
  </code></pre>
  
  <p>===========================================================================
      Recipe Compile Error in /var/chef/cache/cookbooks/java/recipes/default.rb ===========================================================================</p>
  
  <pre><code>RuntimeError
  ------------
  Missing JDK installation
  </code></pre>
  
  <p>It seems like the yum_install() function is NOT being called. However, if I modify the install_java.rb recipe to just have</p>
  
  <pre><code># Install RPM from yum repo via yum_install library function
  yum_install("jdk1.7.0_51")
  </code></pre>
  
  <p>it works.</p>
  
  <p>Why is this?</p>