RStudio Startup Missing libPaths()

On Windows 10, when I open RStudio via a command line start myproj.Rproj, my .libPaths() is missing my local, home directory, package location. If I double click the project file or open RStudio from the Start menu, .libPaths() is populated as expected. Regardless of the startup path, my .Renviron and .Rprofile are being parsed and applied.

While I'm running RStudio Desktop 1.1.463, I've had this problem under several different versions. Has anyone come across this issue?

I wasn't able to reproduce -- library paths as set in a .Rprofile appear to persist when RStudio is launched with e.g. start renv.Rproj.

What are the contents of your .Rprofile and .Renviron? Can you confirm that the library paths are being set as expected within the .Rprofile (e.g. with some debug printing)? Any other information that you could provide that would help with reproducing the issue?

Thanks for the check, Kevin!

I've tested this out on two Windows 10 systems and have narrowed the problem down to whether or not I'm loading the posh-git module. The darndest thing as a diff of environment variables before and after importing that PowerShell module shows no differences.

I'm not explicitly setting this home directory for inclusion in .libPaths() as part of my startup. Can you clarify for me what part of the R & RStudio startup process this gets set? I'd like to further investigate and engage with the posh-git maintainers.

Appreciate the help!

One possibility: does posh-git mutate the notion of the home directory? I know that R likes to use the user's Documents directory as home, whereas other applications would just use %USERPROFILE%.

What is the output of path.expand("~/") in your case in R / RStudio, both with and without the posh-git module loaded?

Another great suggestion! :slightly_smiling_face:

It turns out that posh-git is setting a HOME environment variable to the bare C:\users\davidski directory. This environment variable is normally unset (Windows uses HOMEDRIVE and HOMEPATH). When set, this causes tilde expansion in R to go to C:\users\davidski instead of C:\users\davidski\Documents, the later of which is what I get for tilde expansion when starting RStudio "normally." Interestingly, bare tilde expansion directly in cmd.exe or powershell.exe CLIs with $HOME unset gives me the C:\users\davidski path and not the Documents subpath.

Reading through the Startup help, I'm not certain which flavor of tilde expansion (the bare user directory or the Documents subdirectory) is considered normal for Windows users. Documents seems like an odd location for dotfiles such as .Rprofile and .Renviron, but I can't see how vanilla Windows installations would default to anything besides the user's Documents folder.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.