path_expand()
Differs from path.expand()
in the interpretation of the
home directory of Windows. In particular path_expand()
uses the path set
in USERPROFILE
, if unset then HOMEDRIVE
/HOMEPATH
is used.
In contrast path.expand()
first checks for R_USER
then HOME
, which in the default
configuration of R on Windows are both set to the users document directory, e.g.
C:\Users\username\Documents
. path.expand()
also does not support
~otheruser
syntax on Windows, whereas path_expand()
does support this
syntax on all systems.
This definition makes fs more consistent with the definition of home directory used
on Windows in other languages, such as
python
and rust.
This is also more compatible with external tools such as git and ssh, both of
which put user-level files in USERPROFILE
by default. It also allows you
to write portable paths, such as ~/Desktop
that points to the Desktop
location on Windows, MacOS and (most) Linux systems.
Users can set the R_FS_HOME
environment variable to override the
definitions on any platform.