microsoft / PTVS

Python Tools for Visual Studio
https://aka.ms/PTVS
Apache License 2.0
2.53k stars 675 forks source link

Creating python solution from existing python code fails for wsl based python project #7126

Closed john-kruebbe-dxc closed 1 year ago

john-kruebbe-dxc commented 2 years ago

Describe the bug [A clear and concise description of the bug] ActivityLog.xml contains System.ArgumentException: Path was invalid Parameter name: fromDirectory ---> System.UriFormatException: Invalid URI: The hostname could not be parsed. at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) at Microsoft.PythonTools.Infrastructure.PathUtils.MakeUri(String path, Boolean isDirectory, UriKind kind, String throwParameterName) --- End of inner exception stack trace --- at Microsoft.PythonTools.Infrastructure.PathUtils.MakeUri(String path, Boolean isDirectory, UriKind kind, String throwParameterName) at Microsoft.PythonTools.Infrastructure.PathUtils.GetRelativeDirectoryPath(String fromDirectory, String toDirectory) at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.String.Join(String separator, IEnumerable1 values) at Microsoft.PythonTools.Project.ImportWizard.ImportSettings.d71.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.PythonTools.Commands.ImportWizardCommand.d2.MoveNext() Steps to Reproduce

  1. Open Visual Studio 2022
  2. Create a New Project Search for a template From existing Python code
  3. Take default Project Name PythonApplication1 Location: C:\users\jkruebbe\source\repos Solution name PythonApplication1
  4. Select Create
  5. Welcome to Create New Project from Existing Python Code Wizard
  6. Enter or browse to folder containing Python Code
  7. Click 3 dots
  8. Enter path as \wsl$\Ubuntu-20.04\home\jk\xyzcustomer_code\rate-front-end-dxc
  9. An error occured and your project was not created shows in the VS status bar.
  10. Visual Studio - Python Support popup comes with An unexpected error ArgumentException occured while creating your project. If Visual Studio is running with the /Log option, the full exception has been written to the activity log
  11. C:\Users\jkruebbe\AppData\Roaming\Microsoft\VisualStudio\17.0_562829a3\ActivityLog.xml:
  12. Log contains : System.ArgumentException: Path was invalid Parameter name: fromDirectory ---> System.UriFormatException: Invalid URI: The hostname could not be parsed. at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) at Microsoft.PythonTools.Infrastructure.PathUtils.MakeUri(String path, Boolean isDirectory, UriKind kind, String throwParameterName) --- End of inner exception stack trace --- at Microsoft.PythonTools.Infrastructure.PathUtils.MakeUri(String path, Boolean isDirectory, UriKind kind, String throwParameterName) at Microsoft.PythonTools.Infrastructure.PathUtils.GetRelativeDirectoryPath(String fromDirectory, String toDirectory) at System.Linq.Enumerable.WhereSelectArrayIterator2.MoveNext() at System.String.Join(String separator, IEnumerable1 values) at Microsoft.PythonTools.Project.ImportWizard.ImportSettings.d71.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.PythonTools.Commands.ImportWizardCommand.d2.MoveNext() Expected behavior [A clear and concise description of your expectation] The Visual Studio Python ObjBrowEx.zip project would be created and not get above exception. Additional context and screenshots [Add any other information such as screenshots, error message, or stack trace]

Sample Code

XXX

Configuration information (If you are providing a diagnostics file (see below), skip this section) VS Version: [Can be found under "Help->About Microsoft Visual Studio"] Microsoft Visual Studio Enterprise 2022 Version 17.3.0 VisualStudio.17.Release/17.3.0+32804.467 Microsoft .NET Framework Version 4.8.09037

Installed Version: Enterprise

Visual C++ 2022 00476-80000-00000-AA625 Microsoft Visual C++ 2022

ASP.NET and Web Tools 17.3.375.53775 ASP.NET and Web Tools

Azure App Service Tools v3.0.0 17.3.375.53775 Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 17.3.375.53775 Azure Functions and Web Jobs Tools

C# Tools 4.3.0-3.22401.3+41ae77386c335929113f61d6f51f2663d2780443 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Cookiecutter 17.0.22179.3 Provides tools for finding, instantiating and customizing templates in cookiecutter format.

Microsoft Azure Tools for Visual Studio 2.9 Support for Azure Cloud Services projects

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Node.js Tools 1.5.40629.1 Commit Hash:3f5cc0329815af3ffb948f08857446d206a9af36 Adds support for developing and debugging Node.js apps in Visual Studio

NuGet Package Manager 6.3.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Python - Django support 17.0.22179.3 Provides templates and integration for the Django web framework.

Python - Profiling support 17.0.22179.3 Profiling support for Python projects.

Python with Pylance 17.0.22179.3 Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.

Razor (ASP.NET Core) 17.0.0.2232702+e1d654e792aa2fe6646a6935bcca80ff0aff4387 Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools 17.0.62207.04100 Microsoft SQL Server Data Tools

TypeScript Tools 17.0.10701.2001 TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 4.3.0-3.22401.3+41ae77386c335929113f61d6f51f2663d2780443 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 17.1.0-beta.22363.4+1b94f89d4d1f41f20f9be73c76f4b229d4e49078 Microsoft Visual F# Tools

Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio. PTVS version: [Can be found under "Help->About Microsoft Visual Studio->Installed products->Python with Pylance"] Python with Pylance 17.0.22179.3 Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers. Python version: Debugger Type (if applicable): [New debugger or legacy debugger?]

Diagnostics file The diagnostics file contains information such as the Python version, environments, loaded assemblies, configuration options, etc. This file makes it easier for us to reproduce and fix bugs, so we would really appreciate it if you could provide it to us. This file can be generated by going to Tools->Options->Python->Diagnostics. You can attach the file to this issue or email it to us at ptvshelp@microsoft.com. If you email it, please add a link to this issue.

XXX
StellaHuang95 commented 1 year ago

Hi there, sound like Visual Studio is having trouble parsing the WSL path you provided. Could you please try mapping the WSL path to a Windows drive letter using the wslpath and see if that works?

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 30 days with no activity. If the issue still persists, please reopen with the information requested. Thanks.