title: CodeIgniter CLI giving system_path error "path does not appear to be set correctly."
body: <p>I have a cron task setup to run the following:</p>
  
  <pre><code>php /var/www/vhosts/examplesite.com/index.php cron processCategoryItemCount
  </code></pre>
  
  <p>When i run this on my production server (hosted via MediaTemple dv4) the following error flashes on the ssh window:</p>
  
  <blockquote>
    <p>Your system folder path does not appear to be set correctly. Please
    open the following file and correct this: index.php</p>
  </blockquote>
  
  <p>When i run the php CLI command on my development mac, i dont get any errors at all.</p>
  
  <p>As far as i can tell my system_path is set properly.. here is the snippet.</p>
  
  <pre><code>/*
   *---------------------------------------------------------------
   * SYSTEM FOLDER NAME
   *---------------------------------------------------------------
   *
   * This variable must contain the name of your "system" folder.
   * Include the path if the folder is not in the same  directory
   * as this file.
   *
   */
      $system_path = 'system';
  </code></pre>
  
  <h2>Manual Testing</h2>
  
  <p>I did some testing to go through the code that CI uses to determine <code>system_path</code> and <code>application_path</code>. From what i can tell its working properly..</p>
  
  <p><strong>CodeIgniter Uses The Following Code For path validation</strong></p>
  
  <pre><code>// Set the current directory correctly for CLI requests
  if (defined('STDIN'))
  {
      chdir(dirname(__FILE__));
  }
  
  if (realpath($system_path) !== FALSE)
  {
      $system_path = realpath($system_path).'/';
  }
  
  // ensure there's a trailing slash
  $system_path = rtrim($system_path, '/').'/';
  
  // Is the system path correct?
  if ( ! is_dir($system_path))
  {
      exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
  }
  </code></pre>
  
  <p>As a result I made a test.php file and stuck it in my <strong>httproot</strong>..</p>
  
  <pre><code>&lt;?php
  $system_path = 'system';
  echo "index.php dir is: ".dirname(__FILE__)."\n";
  chdir(dirname(__FILE__));
  echo "System Dir is: ".realpath($system_path)."\n";
  if ( ! is_dir($system_path)){
          exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
  }else{
      echo "System Path Set Properly\n";
  }
  sleep(30);
  </code></pre>
  
  <p>I ran this via command line with this command:</p>
  
  <pre><code>/usr/bin/php /var/www/vhosts/examplesite.com/client/stage/test.php`
  </code></pre>
  
  <h3>This is what i get back:</h3>
  
  <pre><code>index.php dir is: /var/www/vhosts/examplesite.com/client/stage
  System Dir is: /var/www/vhosts/examplesite.com/client/stage/system
  System Path Set Properly
  </code></pre>
  
  <h2>So, a bit more testing and i discover the problem is in this part:</h2>
  
  <pre><code>if ( ! is_dir($system_path))
  {
      exit("Your system folder path does not appear to be set correctly. Please open the following file and correct this: ".pathinfo(__FILE__, PATHINFO_BASENAME));
  }
  </code></pre>