code: def robust_abspath(p: str | Path) -> str:
      """A helper which would not fail if p is relative and we are in non-existing directory
  
      It will rely on getpwd, which would rely on $PWD env variable to report
      the path.  Desired for improved resilience during e.g. reporting as in
      https://github.com/datalad/datalad/issues/2787
      """
      try:
          return abspath(p)
      except OSError:
          if not isabs(p):
              try:
                  os.getcwd()
              except Exception:
                  return normpath(join(getpwd(), p))
          # if no exception raised it was not the reason, raise original
          raise
  
file_path: datalad/datalad/support/path.py
imports: from __future__ import annotations
  import os
  import os.path
  from collections import defaultdict
  from collections.abc import Iterable, Iterator
  from functools import wraps
  from itertools import dropwhile
  from pathlib import Path, PurePosixPath
  from ..utils import ensure_bytes, getpwd
label_desc: Use image node_id 2 for calling a global function with example usage: robust_abspath(p) and returns: abspath, normpath