microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.9k stars 29.17k forks source link

dotnet core compilation with ncurses 6.1 #43539

Closed b0wter closed 6 years ago

b0wter commented 6 years ago

Steps to Reproduce:

  1. use the dotnet command to create a new project (e.g. dotnet new console -n test).
  2. open the project in vs code and try to build it

=> Build will crash immediately with the following exception:

MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
System.InvalidOperationException: The terminfo database is invalid.
   at System.TermInfo.Database..ctor(String term, Byte[] data)
   at System.TermInfo.Database.ReadDatabase(String term, String directoryPath)
   at System.TermInfo.Database.ReadDatabase(String term)
   at System.TermInfo.Database.ReadActiveDatabase()
   at System.ConsolePal.TerminalFormatStrings.<>c.<.cctor>b__27_0()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at System.ConsolePal.EnsureInitializedCore()
   at System.ConsolePal.ControlCHandlerRegistrar.Register()
   at System.Console.add_CancelKeyPress(ConsoleCancelEventHandler value)
   at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine) in E:\A\_work\17\s\src\MSBuild\XMake.cs:line 526

Unhandled Exception: System.InvalidOperationException: The terminfo database is invalid.
   at System.TermInfo.Database..ctor(String term, Byte[] data)
   at System.TermInfo.Database.ReadDatabase(String term, String directoryPath)
   at System.TermInfo.Database.ReadDatabase(String term)
   at System.TermInfo.Database.ReadActiveDatabase()
   at System.ConsolePal.TerminalFormatStrings.<>c.<.cctor>b__27_0()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at System.ConsolePal.EnsureInitializedCore()
   at System.ConsolePal.ControlCHandlerRegistrar.Register()
   at System.Console.add_CancelKeyPress(ConsoleCancelEventHandler value)
   at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine) in E:\A\_work\17\s\src\MSBuild\XMake.cs:line 748
   at Microsoft.Build.CommandLine.MSBuildApp.Main(String[] args) in E:\A\_work\17\s\src\MSBuild\XMake.cs:line 215

This might be related with https://github.com/dotnet/corefx/issues/26966

However, using the dotnet command in a regular terminal causes no problems at all (which is what the original reporter stated (running dotnet restore crashes in the terminal).

Does this issue occur when all extensions are disabled?: N/A

Cannot run this without the c#/dotnet core extensions.

Tyriar commented 6 years ago

It looks like https://github.com/dotnet/corefx/issues/26966 has issues with certain terminals, let's track it there until that discussion is resolved.

jogleasonjr commented 6 years ago

Is there a way to specify a terminal as an argument to vscode when launching? Without wanting to set TERM in something like ~/.bashrc, as a workaround I've changed the default shell here.

Tyriar commented 6 years ago

@jogleasonjr you can set the shell and its arguments using terminal.integrated.<os>.shell and terminal.integrated.<os>.shellArgs. Changing $TERM could break stuff, there is no nicer way to do that AFAIK (I don't think the .env setting will allow that to be set).

jogleasonjr commented 6 years ago

@Tyriar yes I wouldn't want to change $TERM for anything non-experimental. It seems to me that the integrated terminal's configuration does not affect the one that invokes dotnet build from tasks.json.

For example setting an alternative shell using terminal.integrated.linux.shell (or just typing TERM=something_else in the integrated terminal on vscode launch) will fix the build errors in the terminal but not in a debug task.

Launching and attaching still work thankfully, so it seems to me that the best workaround for the moment is to comment out preLaunchTask in 'launch.json` and just build outside of the editor like the good 'ol days.

Tyriar commented 6 years ago

I think tasks take control of the shell as otherwise tasks.json would not be portable (eg. things that run in WSL don't run in cmd)

jogleasonjr commented 6 years ago

One way I found to do that in tasks.json is by setting the environment variable in the command property before the usual dotnet build:

"tasks": [
 {
    "label": "build",
    "command": "dotnet build",
    "linux": {
        "command": "env TERM=rxvt-unicode-256color dotnet build"
    },
   ...
  }
]

Setting TERM in tasks.linux.options.env: { } didn't seem to take affect, nor did the user setting terminal.integrated.env.linux: { }.

So the above workaround, as ill-advised as it may be in many cases, seems to work for now until this update propagates its way to vscode and the arch repos. It will allow for one click (or F5 key) build/debugging.