title: Unable to read file from within rake task
body: <p>I have this rake task which reads a file.</p>
  
  <pre><code>desc "Dump with images."
  task :dump_with_images =&gt; :environment do
    yaml_path = Rails.root + 'db/data.yml'
  
    # output: "" -- empty string
    puts File.open(yaml_path).read.inspect
    [...]
  end
  end
  </code></pre>
  
  <p>If I read and inspect the file from outside of the task,</p>
  
  <pre><code>yaml_path = Rails.root + 'db/data.yml'
  puts File.open(yaml_path).read.inspect
  
  desc "Dump with images."
  task :dump_with_images =&gt; :environment do
  </code></pre>
  
  <p>It gives me some data:</p>
  
  <pre><code>zeromodulus@kosuna:~/projects/recipes$ rake dump_with_images
  "\n---\nphotos:\n  columns:\n  - id\n  - created_at\n  - updated_at\n  - recipe_id\n  - image_file_name\
  </code></pre>
  
  <p>I don't understand why I can read the exact same file just outside of the task, but not in the task.</p>
  
  <p>When I inspect yaml_path, they're both the same, and the file definitely has data in it.</p>