0

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

  • I ended up just creating a new home directory on my C: so that it can be used as /mnt/c/home. I'm now using it as my home directory instead of ~. This seems to bring the least inconvenience and provides a solid workaround for the issue. – SergeyOvchinnik Nov 14 '16 at 13:55
  • MS have been working on that. There are many workarounds and solutions in the corresponding issue report – Jaime Jul 29 '18 at 5:53
1

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.