title: shell-init: error retrieving current directory: getcwd -- The usual fixes do not wor
body: <p>I have a simple script:</p>
  
  <pre><code>#!/bin/bash
  for server in $(~/.ansible/ansible_hosts)
  do
      ssh $server "hostname; readlink /opt/mydir/mylink;"
  done
  </code></pre>
  
  <p>It works fine - the program returns the correct hostname and link - except that I get the following error on some but not all of the servers:</p>
  
  <p><strong>shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory</strong></p>
  
  <p>All the directories exist. One of the most common suggestions has been to add a cd, a cd -, or a cd /. All that happens when that step is added is an additional:</p>
  
  <p><strong>chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory</strong></p>
  
  <p>I tried kickstarting the nfs daemon on the off chance that there was some confusion about my homedir and substituted /etc/init.d in case the problem was with /opt. No difference</p>
  
  <p>This would simply be an annoyance except that when I try to use an ansible playbook instead of a simple ssh command it fails for that server.</p>
  
  <p>Any insights would appreciated.</p>