2

I've been experiencing a problem with Bash on Ubuntu on Windows: when I edit a file located in my Bash home directory C:\Users\me\AppData\Local\lxss\home\me\ using some Windows based software(notepad++ for example), Bash doesn't see the file anymore.

So if I create a file in my home directory using Bash and then edit the same file using Windows, Bash doesn't see it anymore. Same with copy-pasting a file from Windows into home directory, Bash doesn't see it.

Is there any way to make those files visible to Bash?

P.S. Files and changes in the Windows directories are always visible from Bash through /mnt/c/... and are still visible after editing and moving files around

1 Answers1

3

Easiest solution would be to copy the files to a different directory before editing and copy them to the original location after editing.

Take a look at this question: Windows Linux Subsystem - Accessing Files outside of Ubuntu

It has reference to the GitHub Project for the BashOnWindows Project. Specifically the Issue 402 or more specifically this comment which reads:

@ducminhnguyen -- copying directly into the Linux subsystem from Windows is not supported, according to discussion on other tickets. There is a directory under AppData somewhere (I forget where) that appears to contain the files for the WSL filesystem. But if you put new files there, or modify existing files there, your changes are not reflected correctly inside WSL.

My best guess is that Linux needs to store different metadata (and more caching information, etc, since its disk-buffering model is also different) about its files than Windows does, and that this is currently implemented by storing the master copy of the structure of the Linux filesystem in a database of some sort, and just using the Windows filesystem as a convenient BLOB-store for that database.

If you really need to do this, a workaround would be to write a drag'n'drop .bat script or somesuch that does bash.exe -c "mv %1 /home/$USER/". (You'll have to do some clever work with sed and tr, probably, to translate %1 to a valid WSL path.)

Alternatively -- could you put your files in a Windows directory and, within WSL, do "cd ~; ln -s /mnt/c/path/to/my/files" to make them appear to be in your WSL homedir?

Seth
  • 9,393