Problem with shell in RStudio IDE 1.1.456 (Windows)

terminal

#1

I run into a persistent problem with the shell (Tools >> Shell...). If I open the shell everything works fine. However, if I close it and then open it again. Things stop working. I was able to pin this down to a problem with the HOME environment variable

$ echo $HOME
/c/Users/mbojanowski

but after closing the session in opening it again I see

$ echo $HOME
/c/Users/mbojanowski/Documents/=

so clearly somehting is wrong with startup/environment. I have no idea how to debug it further.

Please help as it is very annoying -- I need to restart RStudio session if I accidentally close and re-open the shell window.