title: Expand a file name with a tilde to its fullpath (Common Lisp)
body: <p>I have a directory name (as string) with a tilde: <code>~/projects</code>.</p>
  
  <p>I want to get its fullpath: <code>/home/user/projects</code>. How do I do that ?</p>
  
  <p>The goal is to pass it to <code>uiop:run-program</code>, that doesn't seem to do the right thing©.</p>
  
  <hr>
  
  <p>With this answer: <a href="https://stackoverflow.com/questions/16656079/how-to-translate-make-pathname-directory-absolute-home-directoryiwant-i">How to translate (make-pathname :directory &#39;(:absolute :home &quot;directoryiwant&quot;) into absolute path</a></p>
  
  <pre><code>(merge-pathnames 
            (make-pathname
             :directory '(:relative "~/projects"))
            (user-homedir-pathname))
  #P"/home/me/~/projects/"
  </code></pre>
  
  <p>=> WRONG</p>
  
  <p>Thank you.</p>
  
  <hr>
  
  <p><strong>edit</strong> I'll share more context.</p>
  
  <p>I wanted to run a program through <code>uiop:launch-program</code>. I had a user-defined list of directories such as <code>~/projects</code>. Using it as is created the <code>./~/projects</code> directory instead of <code>/home/user/projects</code>.</p>
  
  <p><code>truename</code> doesn't work if the directory doesn't exist.</p>
  
  <p>On SBCL, <code>(namestring "~/doesntexist")</code> returns also its tilde.</p>
  
  <p><code>merge-pathnames</code> didn't work, still the tilde problem.</p>
  
  <p>Feeding <code>ensure-directories-exist</code> with this result created a directory named <code>~</code>.</p>
  
  <p>Given the answers, I had no choice but to adapt the logic to expand the directory name of a directory we actually want to exist.</p>
  
  <pre><code>;; Create a directory
  ;; Ensure its name (string) ends with a slash.
  (setf mydir
          (str:concat (string-right-trim (list #\/) mydir)
                      "/"))
  (ensure-directories-exist base)
  </code></pre>
  
  <p>Then I could use its <code>truename</code>.</p>