title: Symlink Linking Folder
body: <p>I am trying to symlink the public folder to my rails application to the public_html folder on my server and I can't seem to get it right.</p>
  
  <p>I have a task in my deploy.rb file called <code>:link_release_to_public</code>:  </p>
  
  <pre><code>namespace :deploy do 
    task :link_release_to_public do
      run "cd ~"
      run "rm -rf ~/public_html"
      run "ln -sf ~/#{current_path}/public ~/public_html"
    end
  end
  </code></pre>
  
  <p>In it, I remove the existing "public_html" folder and then create the symlink using the command: </p>
  
  <pre><code>ln -sf ~/rails_app/releases/current/public ~/public_html
  </code></pre>
  
  <p>The goal is to replace ~/public_html with a symlink to the public folder of the current release.</p>
  
  <p>Running <code>cap deploy:link_release_to_public</code> completes successfully, however, rather than getting the files linked directly into the ~/public_html folder, it creates the "public_html" folder and then symlinks "public" inside ~/public_html so that: <code>~/public_html/public</code>.</p>
  
  <p>If I do the exact same steps in the task directly on the server (via SSH) it works perfectly.  I don't understand what I'm doing wrong.</p>