-
Notifications
You must be signed in to change notification settings - Fork 834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ubuntu filesystem files may disappear (become not visible in bash) after editing in Windows (e.g. Sublime) #659
Comments
If you read about VolFs and DrvFs here https://blogs.msdn.microsoft.com/wsl/2016/06/15/wsl-file-system-support/ you will see why this happens. You should use Sublimetext Linux version. Together with Xming you can open it from WSL even if it's a graphic application. I have a shortcut with this content in the windows Desktop I use to open linux Sublimetext. (just make sure Xming is already running before running the shortcut) |
Do you envision some other workarounds possible as an options? Many will look like crutches, but why not.
Also, unfortunately I can't verify following approach as WSL just broke and won't run after trying edit sources in VS Code instead of Sublime. But should it be possible to work with Windows files inside bash (through mnt and thus using DrvFs) and launch e.g. rails server based on files from windows? Should running applications (ruby in this case) be fully satisfied with such files? |
Also, if this limitation is fixable (no Interoperability with Windows for VoIF) y implementation of WSL, will you point me to the right request on that on User Voice portal? |
The official workaround is using DrvFs (/mnt/*) folders and do git clone there. You can also edit with windows applications like VSCode and files won't disappear or break bash. It should work for most scenarios but for some like compiling Android ROMs is known to have problems. To start anew and delete everything open cmd and type lxrun /uninstall /full and install bash again with lxrun /install I'm just a WSL user like you but let's see what Microsoft thinks about your suggestions. The most similar request for the problem would be https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/13341279-a-file-created-in-c-users-user-appdata-local-lx |
Indeed, I found an explanation in another issue #87 - #87 (comment) Long story short:
It's a pity that original #45 was simply closed with statement "functions as designed". |
Also, the lucky part for me that simple clearing of "\lxss\temp" folder in Windows fixed bash collapse for me. It starts again. |
symlinks work in VolFS. So for a single file make a symlink from the file in lxss land (VolFS) that you want to edit (e.g. .bashrc) to a location in Windows land (DriveFS). Edit with an editor that knows how to handle Linux line endings. I doubt it would work on ..ssh\authorized_keys or other files where permissions matter, but it might work on enough places to make this workaround useful. If the project doesn't require linux filesystem semantics (e.g. case sensitive filenames, or lots of hard or symbolic links) then do the work in a folder in DriveFS. One other workaround: I was able to get my Windows editor to stop making a backup of the file (probably moving the original to .bak, and creating a new one, haven't investigated), but rather to edit the file "in place". Apparently this did not mess up the extended attributes, because the file didn't disappear from the lxss environment when bash was restarted. Maybe Sublime has a setting that will allow it to do the same thing? (I'm using build 14390) It also looked to me as if it is only the last edit that matters, so you might try editing with Sublime while the lxss environment is still open, then opening the file in lxss with vim or something, confirm that the changes are there, and save, perhaps after making a trivial change to allow a real save. When I did that the file was still there when I closed and reopened the lxss environment. (Consider this a one-time test, not a suggestion to give up Sublime and use vim all the time...) If that works consistently, perhaps a simple bash script could write a LF to the end of each text file (and perhaps delete it again) to make sure it is written in the lxss environment after you finish with Sublime but before exiting the lxss environment. If it works for you, I'd conclude that writing the file in the lxss environment probably puts the extended attributes back. And of course there is getting X-windows working and using a GUI editor on files in VolFS. That should work. I know, they're workarounds. But they might allow some people to get work done until the situation changes. On my build, lxss/temp is completely removed when I exit from the lxss environment. Sounds like a good thing. |
As I need to edit whole project source code (multiple files), setting up individual symlinks won't work. Same time, keeping files in Windows file system and using them in bash via /mnt/ (DriveFS) seems to work. I can successfully run rails server from files laying on my d drive (NTFS). I can then use any Windows editor, e.g. Sublime or VS Code. Luckily, ruby works OK with edited files in Windows, i.e. with windows style line endings. I'm also using windows git therefore to work with the github repository. I have core.autocrlf option set to true (default). Again, this seems to be working and ruby inside WSL runs the server OK.
(offtopic) As a result, whole solution works together:
|
I ended up starting ssh daemon in bash and then mounting my |
I've found a workaround to restore the files to the Linux side of the house after a slight (err, shall we say, resulted in deleting AppData/Roaming on the windows side -- don't ever do that, it is a bitch to get all the functionality back) Anyway, that wasn't the cause of a bulk of my missing files (many like /etc/vim/vimrc and ~/.vimrc were due to editing in notepad++ on the windows side which resulted in the loss of the additional attributes) To restore them, simply copying them (on the windows side) to some temporary location (like C:\Users\you\temp) then deleting the original (e.g. on the windows side (e.g. del C:\Users\you\AppData\Local\lxss\rootfs\path\to\filename) and finally restoring them from within bash (e.g. cp /mnt/c/Users/you/temp/filename /path/to/filename && chmod 0644 /path/to/filename) did the trick. (note: files that are part of the /home partition will be under C:\Users\you\AppData\Local\lxss\home\you on the windows side) Hopefully this helps. Again, never "shift+delete" your Roaming directory --- stupid windows focus handling... |
@pavelbulanov: Please read this post: "Do not change Linux files using Windows apps and tools" If you want to edit files using Windows editors like sublime, VSCode, Visual Studio, etc., but build/run your code in Bash, then store your files in a Windows folder, and access that folder via, |
@bitcrazed does that mean I'd need to git clone from a windows CLI as well? Or is the location sufficient? |
Really need this to work, or will be moving over to Mac. Having lack of Linux/Windows interoperability doesn't cut it for application development using node/npm as, even if you git clone to a Windows directory via /mnt/c/... and edit from here using an IDE, still need to run tests/install packages via npm on Linux. Else, what really is point of Linux being available on Windows. |
@joetidee -- running node/npm from a git checkout in /mnt/c/... works great for me. When you try to do that, what doesn't properly for you? |
Is this /mnt/c from within bash, or from within C:\Users[USER]\AppData\Local\lxss ? |
Looks like if I create a project in /mnt/c from within bash, I cannot then chown to the ubuntu user (?) |
yes, the /mnt/ filesystem uses windows-side users |
@joetidee -- are Linux users important to your development workflow? Again: What, specifically, are you doing that you actually need to do and that breaks? Don't stop just because something looks wrong -- because /mnt/c is integrated with Windows, its permissions system is just plain different from ordinary Linux, so it's going to be a little different than you expect. (Not saying it doesn't have bugs too :-) ) |
I suppose it's just good to be able to ensure that things work as expected as closely as possible to the live environment (which in my case is Ubuntu), where you wouldn't be using |
Well, you shouldn't actually have to use root. The files should be listed as being owned by root, but in practice that's because they're being controlled by Windows permissions. So it should be fine to use your regular WSL Linux user account, or any new WSL user account that you might create to mimic your production environment. If (for example) your environment sets file permissions and verifies that they work as expected within your application, then, yeah, that is a test that's useful that you can't do in DrvFs right now. If that's your use case, it'd be good to know -- the WSL team could help with it in any of several ways, including adding Linux-permissions support for DrvFs or adding Windows-application support for VolFs. (Either way, it's mix'n'matching Windows and Linux permissions.) |
@bitcrazed That would work provided regular files in |
@gpakosz Are you aware of the You can set it for the current repository using Don't know if it will be enough for your use case, but there you have it. |
Ah, this is annoying, is there a way I could mount my actual Ubuntu home directory to windows bash? In that way, editing files should preserve the attributes because it's going to be different filesystem |
@aurimus -- no, that is not currently possible, in part precisely because of permissions: Most text editors implement "save" as "create a new file and delete the old one." (Very few programs actually update files in place these days. Long story.) So as you edited your files, they would lose their permissions anyway. |
@aseering @bitcrazed an idea, why can't WSL sit on ext4 partition by itself and use Ubuntu own drivers to run things around. While installing WSL it could just create the necessary partition and make it hidden. Thanks. WSL running slow on file access and this issue is really annoying.. |
After editing files from ubuntu file system (originally created there by git clone) by Windows tool (e.g. Sublime) they disappear in bash (become not visible i.e. by ls or git) after some time. (update - see point 7 below, it might be bash restart that cause the issue).
Not sure how to get "lost" files back to bash or verify why the are not visible to bash. They still exist and accessible using windows.
Expected results - files can be edited in windows app and continue to be visible in bash.
Actual results (with terminal output if applicable) - files are completely missing in e.g. "ls -a" output. Git status says that file was deleted (i.e. don't find it).
Windows build number - 14372 (slow ring)
Steps / commands required to reproduce the error:
Download git repository inside bash by "git clone". Files are visible in bash and fully functioning, for example I can run "rails s" and it's working.
Open source codes from the repository in Windows, e.g. Sublime. The file path is "c:\Users\AppData\Local\lxss\home\pavel\sources\Gemfile". File is perfectly visible and editable under Windows (its content is text, not binary). Do some changes (or no changes at all) and save it.
Right after edit the changed file is still visible under bash. I can restart rails server in bash and it uses updated Gemfile (take changes from there). Git status also says the file was modified (therefore can see the file).
=> 4) After some time (not further edits or actions outside of bash needed! - I know it sounds very strange) the file "disappears" from bash. "ls -a" doesn't show it, "git status" says the file was deleted (i.e. also doesn't see it). Windows continue to see the file, I can further edit and save it there (it won't reappear in bash though).
If I run "sudo vim Gemfile" it will open the empty file stating "new file" in status bar (it opened the file before w/o problem). I can overwrite the file by saving it in vim without any warnings (and the old gets lost). Same thing if I "git checkout" same file, it gets overwritten w/o any warnings. Sublime then immediately reloads new content (typed in vim or from git checkout) on switching to its window.
Notice - today I was able to see "interim" state - 'git status' suddenly said (file was not even opened in Sublime or anywhere)
Calling git status right away (no further saving or any other actions outside bash at all!) gave
And now the file is gone.
Once I run "ls" or "ll" in bash, the listing immediately doesn't show Gemfile at all (not listed). Re-running vim now will says "New File" and can override it, same as git checkout (after each rewritten file is visible inside bash). After rewrite I can further open the file in Sublime and continue editing, with changes visible to bash. Restarting bash cause the issue (regular and reproducible), and it seemed to be that some waiting (or maybe some operations in bash that cause file directory scanning? - not easily reproducible) will also cause it.
Aspects
-rw-rw-rw- 1 pavel pavel 1685 Jul 15 12:52 Gemfile
Windows permissions also doesn't seem to be affected as expected (checked properties dialog of a file before and after edit).
The text was updated successfully, but these errors were encountered: