Skip to content

Remote editing only works for .ps1 files but not others #2166

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

Open
OnurGumus opened this issue Sep 4, 2019 · 50 comments
Open

Remote editing only works for .ps1 files but not others #2166

OnurGumus opened this issue Sep 4, 2019 · 50 comments
Labels

Comments

@OnurGumus
Copy link

When I follow this documentation
https://docs.microsoft.com/en-us/powershell/scripting/components/vscode/using-vscode-for-remote-editing-and-debugging?view=powershell-6

I noticed remote editing only works for .ps1 files. For other extensions, you can save the file but it won't sync back to the server. I am using PowerShell v7 preview 3 for both host and server and both host and server are windows machines along with Latest VSCode and Powershell extension

A relevant issue has been earlier reported but closed:
#1040

@ghost ghost added the Needs: Triage Maintainer attention needed! label Sep 4, 2019
@SydneyhSmith
Copy link
Collaborator

SydneyhSmith commented Sep 5, 2019

@OnurGumus thanks for opening this issue...It would be really helpful if you could also attach the logs--instructions for how to do that are here , please also provide repro steps, as well as a detailed description of the behavior you are experiencing...thanks!

@SydneyhSmith SydneyhSmith added Needs-Repro-Info and removed Needs: Triage Maintainer attention needed! labels Sep 5, 2019
@OnurGumus
Copy link
Author

@SydneyhSmith all repo steps has been clearly stated in the opening issue. If you actually spend 2 minutes and read what I wrote, you will understand the problem. I am not intended to provide further info regarding how to reproduce and loggings as the issue and repro steps are crystal clear.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 6, 2019
@TylerLeonhardt
Copy link
Member

@OnurGumus I just followed the steps, and the file saves as expected.

before:
image

after I added a line in the editor:
image

We need the logs because something might be specific to your system. Please provide those and also what OS's you're using.

Also, do you have access to the file you're trying to save?

@TylerLeonhardt TylerLeonhardt removed the Needs: Maintainer Attention Maintainer attention needed! label Sep 6, 2019
@OnurGumus
Copy link
Author

@TylerLeonhardt, if you read the issue carefully, it clearly states both server and client are windows machines. In your case you are using Linux.

To be specific client is latest windows 10 pro rtm X64 and server is windows server 2019 standard edition 1809.

I am creating the file with new item. Saving only works when the extension is ps1. Also you use a different command than the linked tutorial as new-editor-file whereas I am using psedit, not sure if it makes any difference.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 6, 2019
@OnurGumus
Copy link
Author

I will provide the logs once I have access to my computer.

@TylerLeonhardt
Copy link
Member

Missed the part about Windows. My bad. Just for future reference, we have an issue template so that we don't miss these details the first time around. It just streamlines the process.

New-EditorFile creates a file and opens it in vscode. It's the equivalent to New-Item and then psedit (which is an alias of Open-EditorFile).

I still need to know - what communication protocol are you using? ssh or winrm?

@OnurGumus
Copy link
Author

It's winrm. I agree that my writing style makes those details less visible. But I thought your template was really overwhelming since it was easy to repro from my point of view.

@SydneyhSmith
Copy link
Collaborator

@OnurGumus we will try to stand up an environment similar to yours and repro this...in the meantime it would still be helpful to see your logs--thanks!

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Sep 10, 2019
@centreboard
Copy link

Hi, I'm having the same issue from Windows 10 PC to Windows Server
Reproduced both with 6.2 and 7-preview3

My prompt and logs attached

[npe-file-01]: PS C:\Users\majohnson_admin\Documents> "Test" > test.ps1
[npe-file-01]: PS C:\Users\majohnson_admin\Documents> Get-Content test.ps1
Test
[npe-file-01]: PS C:\Users\majohnson_admin\Documents> psedit test.ps1
[npe-file-01]: PS C:\Users\majohnson_admin\Documents> Get-Content test.ps1
Edited
[npe-file-01]: PS C:\Users\majohnson_admin\Documents> "Test" > test.txt
[npe-file-01]: PS C:\Users\majohnson_admin\Documents> Get-Content test.txt
Test
[npe-file-01]: PS C:\Users\majohnson_admin\Documents> psedit test.txt
[npe-file-01]: PS C:\Users\majohnson_admin\Documents> Get-Content test.txt
Test
[npe-file-01]: PS C:\Users\majohnson_admin\Documents>

1568362690-2cf65ee5-9dce-4f0e-b10e-421124476b0e1568360608478.zip

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Sep 13, 2019
@ghost
Copy link

ghost commented Sep 18, 2019

This issue is being closed as inactive, if this issue is still occurring it will be re-opened

@ghost ghost added the Resolution-Inactive Will close automatically. label Sep 18, 2019
@ghost ghost closed this as completed Sep 18, 2019
@centreboard
Copy link

@SydneyhSmith I'm still having this issue. Let me know if you need any further information

@TylerLeonhardt TylerLeonhardt added Issue-Bug A bug to squash. and removed Resolution-Inactive Will close automatically. Needs: Maintainer Attention Maintainer attention needed! labels Sep 18, 2019
@mkarpuk
Copy link

mkarpuk commented Oct 25, 2019

Faced the same issue today (Windows 10 with Powershell 5).
Is any additional information required? (This issue is still labelled as 'Needs-Repro-Info')

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Oct 25, 2019
@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Oct 28, 2019
@OnurGumus
Copy link
Author

@SydneyhSmith may I ask why you remove Needs:Attention?

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jan 17, 2020
@rjmholt
Copy link
Contributor

rjmholt commented Jan 17, 2020

Any tips on recording a GIF on an enterprise machine

I use this to record gifs, although I think some other contributors have something better that records keyboard input. Alternately, I think Alt+Shift+R will record the screen on Windows, but you'll then have to convert it from mp4 to gif if you want to upload it directly to a GitHub comment.

Looking again at your logs, the path to the temp file seems like it's only got ASCII characters in it, so URI issue seems less likely. I also thought it could be a permissions issue with the temp directory used for local files, but that wouldn't account for ps1 files working.

I'll see if I can dig through the codebase to find something that might explain the symptoms.

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Jan 17, 2020
@centreboard
Copy link

@rjmholt I've attached a gif of trying psedit test.txt The logs should also show the successful psedit test.ps1
psedit_txt
1580118535-4bfb4a3d-47b1-4a15-a6a2-3fb446c2e98d1580118522765.zip

(I've also double checked that running "Edit" > test.txt in the remote session does change the content of test.txt)

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Jan 27, 2020
@TylerLeonhardt
Copy link
Member

That path has a negative number... very curious... that gif is SUPER helpful, thanks @centreboard!!

@rjmholt
Copy link
Contributor

rjmholt commented Jan 27, 2020

That path has a negative number

Reading the previous logs though, that doesn't seem to be a common factor

@TylerLeonhardt
Copy link
Member

@centreboard after you save the file the first time in VS Code, can you Get-Content the temp file path? I'm curious if the temp file is being saved correctly. You can see the temp file path just below the tab in VS Code.

@rjmholt
Copy link
Contributor

rjmholt commented Jan 27, 2020

I'm also still wondering why VSCode wouldn't send us a didSave notification. Given that @centreboard is on 1.41.1, it seems unlikely that it's a bug in that VSCode version.

It could be a configuration thing maybe, so maybe we should take a look at the configuration settings?

Otherwise, it might be worth seeing if we can trace a save in VSCode. That should be possible by starting VSCode with trace logging and inspecting the logs here.

From there we'd expect to see log entries beginning with [text file model].

@centreboard
Copy link

@TylerLeonhardt I can confirm that test.ps1 as an identical folder path with a negative id to test.txt when opended with psedit
@rjmholt I've run code --log trace and reproduced again:
20200128T094922.zip

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Jan 28, 2020
@rjmholt
Copy link
Contributor

rjmholt commented Jan 30, 2020

The VSCode logs I was hoping for aren't in that zip it seems. Their documentation on logging might be lacking.

I'm going to try firing up an RS3 VM to see if I can get a reproduction in a more faithful environment.

@rjmholt
Copy link
Contributor

rjmholt commented Jan 31, 2020

Ok I haven't been able to reproduce remoting from:

OS Name:                   Microsoft Windows 10 Enterprise
OS Version:                10.0.17763 N/A Build 17763

to:

OS Name:                   Microsoft Windows Server 2016 Datacenter
OS Version:                10.0.14393 N/A Build 1439

At this point, if I find time, I'll see if I can read through the code and see where code paths for PS and non-PS files diverge for some clues.

@keithallenjackson
Copy link

keithallenjackson commented May 14, 2020

I am having this same issue. It also appears the autocomplete is unaware that I am in a remote session and continually autocompletes to the folder I was previously in before entering a remote session. I am on the latest version of VSCode and the powershell extension. My system uses Powershell 5.1. I am using WinRM with Enter-PSSession cmdlet.

Client:
VSCode 1.45
Powershell Extension 2020.4.0
OS: Windows 10 x64 1809

Server:
Windows Server 2012 R2

My initial though after reading through this thread: Perhaps the extension is only receiving saveFile notifications on file extensions associated with the powershell vscode extension (ps1, psm1, psd1, etc)?

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label May 14, 2020
@keithallenjackson
Copy link

Looks like the file is being saved in a temporary location, but then never sent to the remote system.

image

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label May 14, 2020
@rjmholt
Copy link
Contributor

rjmholt commented May 14, 2020

@keithallenjackson

Perhaps the extension is only receiving saveFile notifications on file extensions associated with the powershell vscode extension (ps1, psm1, psd1, etc)?

That's what it seemed to look like in #2166 (comment).

However if the file you're seeing in #2166 (comment) is up to date, then that suggests that the save notification isn't the issue. Instead, it may occur somewhere around here.

@rjmholt
Copy link
Contributor

rjmholt commented May 14, 2020

I think some important factors in this so far are:

  • It doesn't reproduce for everyone, so there's some environmental factor at play
  • It seems to only be on Windows, but quite recent Windows versions
  • ps1 files are saved, so there must be some branch that non-PowerShell files follow where the problem lies; the issue is not that no files are saved
  • It seems to be independent of remoting target

@ghost
Copy link

ghost commented Aug 19, 2021

This issue was closed automatically as repro info was indicated as needed, but there has been no activity in over a week. Please feel free to reopen with any available information!

@ghost ghost closed this as completed Aug 19, 2021
@andyleejordan
Copy link
Member

This seems like it actually did have repro info (and indeed, is a very long issue). Re-opening and removing that label.

@p-rogalski
Copy link

p-rogalski commented Jun 14, 2024

Any news on this bug? It's really annoying to rename every file to *.ps1 just to edit it.

This get's more important every day, since PowerShell ISE is deprecated and the PowerShell VS Code extension is advertised as a fully featured replacement!

@andyleejordan
Copy link
Member

For what it's worth, I think the problem likely lies right here: https://github.com/PowerShell/PowerShellEditorServices/blob/af34540acb65a8b1b0e86110436e326fe46ea91d/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs#L131

Since the WorkspaceService is allow-listed only to PowerShell files, and the remote editing feature in the client still uses this outdated DidSave notification. But I spent a while trying to test this and unfortunately have no good way of using PSRP remoting in my dev environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

10 participants