Skip to content
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

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

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

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

OnurGumus opened this issue Sep 4, 2019 · 48 comments
Assignees
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?

@OnurGumus
Copy link
Author

@rjmholt
Thanks for the effort. I was not using -ConfigurationName. When I tried below

Enter-PSSession -ComputerName 192.168.63.25 -Credential gatesdev -ConfigurationName 'Powershell.7'

Enter-PSSession: Connecting to remote server 192.168.63.25 failed with the following error message : The WS-Management service cannot process the request. Cannot find the Powershell.7 session configuration in the WSMan: drive on the 192.168.63.25 computer. For more information, see the about_Remote_Troubleshooting Help topic.

@OnurGumus
Copy link
Author

@rjmholt could it be because I set the remoting long time ago against powershell 6?

@rjmholt
Copy link
Collaborator

rjmholt commented Jan 16, 2020

@rjmholt could it be because I set the remoting long time ago against powershell 6?

Very possible. It depends on whether you've enabled WSMan-based remoting on PowerShell installation.

To set up WSMan-based remoting in PowerShell 6/7, you can follow this document.

If you set it up for PowerShell 6, the configuration name you want might be powershell.6.0.0. But the easiest way to make sure is to just set up remoting again from the PowerShell you want to remote into using the steps in the document linked above.

None of that explains why you're unable to save the file though. The issue you linked in the original description is quite old, but the code referenced is in the client here:

vscode.workspace.onDidSaveTextDocument((doc) => {
if (this.languageClient && this.isDocumentRemote(doc)) {
this.languageClient.sendNotification(
DidSaveTextDocumentNotificationType,
{
textDocument: TextDocumentIdentifier.create(doc.uri.toString()),
});
}
});
}

If you open a remote file for editing again, would you be able to share the path of the local temp file it creates? I wonder if this is a URI internationalisation issue...

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

@OnurGumus yesterday we published an update which fixed some of the URI issues we had been seeing, are you able to test this on the latest version of the PowerShell Preview extension (2020.1.0)

@centreboard
Copy link

@rjmholt Thanks for looking through,

@centreboard looking through your logs I see the following notifications (in chronological order) about test.txt:

There doesn't seem to be a textDocument/saveFile notification for test.txt in the logs, only test.ps1. That notification is something that VSCode (not the PowerShell extension) sends when you save a file.

Given that information, it might be worth making sure your VSCode version is up to date and trying to reproduce the issue with the following steps (or let me know if you used different steps):

  • Open the Integrated Console
  • Enter a PSSession on the remote machine
  • Create a file with PowerShell (like New-Item ./test.txt -Value 'Test')
  • Edit the file in VSCode with psedit
  • Save the file from VSCode (as you would an ordinary local file)
  • Check the content of the file from PowerShell (e.g. with Get-Content ./test.txt)

If the problem persists, please upload your logs again so we can take a look. If you could also capture a GIF of what's happening, that would be ideal.

Those steps are correct. I can still reproduce with test.ps1 being saved to the server and test.txt not.
I've checked VSCode is on 1.41.1 using ms-vscode.powershell 2020.1.0
I'm running Windows 10 (1809) using Powershell 7-rc2

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

I'm using Enter-PSSession -ComputerName $computer -Credential $credential to Windows Server 2016 running Powershell 5.1.14393.3383

OS Name: Microsoft Windows Server 2016 Standard
OS Version: 10.0.14393 N/A Build 14393

Any tips on recording a GIF on an enterprise machine? I'll generate some more logs next week

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

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
Collaborator

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
Collaborator

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
Collaborator

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
Collaborator

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
Collaborator

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
Collaborator

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.

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

No branches or pull requests

9 participants