-
Notifications
You must be signed in to change notification settings - Fork 822
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
metadata allows us to have correct permissions, but saving a file overrides permissions back to 755 #3165
Comments
This has to do with VS Code honoring permissions therefore is a VS Code actionable which already has an issue: microsoft/vscode#49021. I recommend adding your input there to help prioritize the work. |
Thanks, I didn't notice that open issue on the VSCode side of things. |
Well you can run the Linux version of VS Code in the meantime if you like. That is, if you don't mind installing VcxSrv or Xming. If the permissions aren't a hard stop though, I'd just chmod it again after saving the changes. |
Yeah previously I ran Sublime Text through mobaxterm because prior to either 17.09 or 18.03 stable you couldn't run VSCode through WSL (along with other Electron apps). Trying to avoid that now simply because it's nice having 1 editor that works on both sides and I run all of my code through Docker so I'm not really losing anything in terms of code complete (there's no support either way currently). chmodding it afterwards is pretty brutal because in a typical web development session you might end up touching 30 files and it would be hard to keep track of that. Writing a script to chmod all files back to 644 might be dangerous too, since you could have legit executable files. Hopefully it gets fixed on the nodejs side of things and then merged into VSCode shortly after. |
Yep, that can get messy quickly. With the extended attributes, you should still be able to save to /mnt/c or whatever directory from Linux VSCode.
I'd keep anything not legit in their own directory (the same directory for all non-legit), symlink them and run a script against that directory. But web development isn't my main area so maybe that isn't practical for you. |
One pretty common approach, which predates WSL by a decade or more with Samba shares and the like, is to just ignore it; especially if you spend a lot of time on the "Windows Side". On Windows, there sits all those Other way to go is to just use native Linux VS Code in WSL like DarkSpock says. It already "works on both sides", if there is such a thing. I'm betting your |
I did have to configure VSCode to use You are right in that I could choose to ignore them. My main gripe isn't so much getting smacked in the face with a bunch of green text, it's every file I commit to version control ends up being tagged as executable. All of my recent repos on Github are filled with executable files that shouldn't be. I extensively researched this and wasn't able to find any git setting that would get around that. I don't use Windows git, or really develop anything Windows specific. 99% of the time when I edit a file it's by running The only semi-nice thing about having a VSCode Windows installation is having the right click context menu for editing a single file but I rarely use it. One perk of going native WSL VSCode that I see so far is that you can now edit files like your By the way if anyone is curious, the native WSL VSCode does respect permissions. The test case presented in this issue produces the expected result. Kind of seems like a win for native WSL VSCode at this point? Permissions are correct, and you can edit native WSL files. Performance through X server feels as good as native Windows. I'm really picky about these things but I'm not noticing any extra input lag on key strokes. |
Yeah, in this "approach" you ignore that too. Consider, Microsoft has about 3.5 million lines of C/C++ code committed to their internal git repo with the exec bit set and CRLF EOL, and none of their 4000 programmers care. To be clear, it isn't how I roll. It isn't how you roll. I'm not saying go that way. But that doesn't change the nonpartisan observation that it doesn't matter.
Exactly. Because of course it does. 👍 |
Fair enough. Do you think we should close this, or could this eventually make its way into WSL so that editing files within Windows won't mess with the metadata? |
There's no WSL actionable. It would be like asking Linus Torvalds if it will make its way into the Linux kernel running in Docker with a |
Are you ok with keeping it open for a bit to see if anyone else has an opinion, since it's labeled as discussion? If it dies out, I'll close it in a few days. Thanks for the back / forth btw. |
Sure. Plenty others where this one came from. Eventually they get closed (on no particular schedule) when the discussion dies out; or close it yourself whenever you want. |
FWIW, the downside to doing everything in WSL is file performance. VS Code is slow to start up for this reason. Find in files and such also crawls. |
Most projects I work on are under 50,000 lines of code and at most hundreds of files. Typical Ruby / Python / Elixir based web applications with a lot of HTML, CSS and JS mixed in. Startup time in a project with 17,000 lines of code was about 500ms slower with native WSL if I just eyeball the speed. There's a noticeable delay before the window becomes visible but it's not a deal breaker. That is good to know tho, I'm sure others work on much larger projects. One of my main focuses is readability. I do notice the font looking a bit worse on native WSL VSCode (it's quite thin, a little blurry and looks like the AA is jacked up). Readability is important because I record video tutorials for developers. That's one more potential downside to native WSL VSCode. |
You might try VcXsrv and make sure your have "native opengl" off (sic) and |
@therealkenc I always wondered if MS could just add additional metadata caching directly to the read and write file functions in the Windows SDK. Right now, programs like sublime do cache the Windows permission bits, and I assume that is automatic, so I would also assume that they could also cache and rewrite the new LX data. Why couldn't this work (so all programs compiled on the latest SDK would work)? |
You can read and write that metadata with NtQueryEaFile and NtSetEaFile. |
@fpqc - "Caching" has nothing to do with it. The problem is VS Code, via Electron, via Electron's NodeJS, via libuv has no idea how to set WSL's file and directory mode bits. If you look at the libuv code, it (obviously) doesn't set the mode bits on file creation. Because, there was no API to do so. The API is now, presumably, Libuv could be updated to call So you say, just have |
Pretty "ran course" at this point. |
Team of PHP developers using PHP Storm here. This is a huge problem for us - it's really hard to understand what the problem is, because we didn't use to have this problem with previous versions of WSL. I use the Git integration in PHP Storm on Windows - and for that to work, I have to run a Windows version of Git for Storm, as well as a Linux version of Git for general use in the Linux console. This combo worked just fine in early versions of WSL. Then came this update where we had to manually enable metadata in the WSL config file - at this point, things started to break, but enabling metadata in the config file seemed to fix it. Some time after that, another update must have been rolled out, because everything went to sh*t - I make a rule of always checking out in the Linux console, and usually, after that, there's been no problem, but since one of the last update, everything is completely messed up. I'm either seeing all files as modified with Many developers don't notice the file permission changes and end up committing and pushing those - and I clone them on Windows, and half the files immediately appear to be changed, and there's no way to get them to appear as not changed. I'm getting desperate. I have my entire work environment set up with WSL, as this was working beautifully for a long time. Suddenly there's an update and my whole work environment is trash. I'm not Linux savvy, at all - I'm a programmer, not a sysadmin. If there's any way to set up a WSL that worked as it did originally, please, can somebody provide step-by-step instructions? Or should I just quit Windows and put up with an actual Ubuntu installation? 😭 |
|
what is the conclusion here? Either we need an way to tell windows create file in 0644 mode , or we need to fix every IDE to properly detect metadata on NTFS files and know to preserve that when doing "write" |
@mindplay-dk wrote:
Same here, i used to have something working nicely by editing in Windows and pushing to real Linux systems but now it's become a complete chaos with the file permissions. It seems it worked fine when everything was owned by root in WSL but i can't really remember how the permissions were set. In any case it has become worse now (from this?) and even if i mount the windows drives without metadata the problem is not solved 😭 |
Possible. From this article:
Perhaps the mistake was enabling the metadata feature? As I recall, I started having problems before the metadata feature was introduced - and it seemed like enabling metadata solved those problems for a while, and then later it all went south. I'd be fine with a single owner of everything - I'm obviously only using the Linux thing for local development and don't plan on running a public Linux web-server from under Windows. (Does anyone?) |
Bit of a dead thread to post I know but since it doesn't look like there was a great answer for people working with git projects under WSL, I would suggest |
Sadly, this needs to be done for every repository manually, which is a pain. Also, |
You can add a git alias for
Just use |
Your Windows build number: Version 10.0.17134.1 (Windows 10 Pro, Spring 2018 edition)
What you're doing and what's happening:
/etc/wsl.conf
touch hi.txt
chmod 644 hi.txt
stat -c "%a %n" hi.txt
=> 644 hi.txthi.txt
in VSCode, make changes to the file and save it.I would expect that
hi.txt
still has 644 permissions but if you runstat -c "%a %n" hi.txt
you'll see that it returns 755 now instead.It's like the metadata permissions are being stripped away.
Someone on Reddit says this is because VSCode forces safe writes which means a new file gets copied to a tmp directory which is to help prevent data loss.
However, VSCode has no option to disable this, so metadata is essentially not available since every file you edit will end up having it removed.
Is this something that can be fixed and patched into the stable version of Windows without having to wait 6+ months for the next big release?
The text was updated successfully, but these errors were encountered: