Vscode-cpptools: Unable to start debugging. No terminal is available to launch the debugger. Please install Gnome Terminal or XTerm.

Created on 14 Jul 2016  路  22Comments  路  Source: microsoft/vscode-cpptools

_From @naveedrasheed on July 13, 2016 20:28_

  • VSCode Version: 1.3.1
  • OS Version: ArchLinux

Steps to Reproduce:

  1. Build a C\C++ project.
  2. Create launch.json
  3. Try to start debugging.

I think there should be an option in launch.json to set terminal path as well.

_Copied from original issue: Microsoft/vscode#9231_

debugger wontfix

Most helpful comment

For those of you who want konsole support in VSCode C++ extension here's a modified version of MIEngine to allow that (It also prefers creating a new tab for the program output if you have a konsole window already launched)

Instructions:
Replace the files in "~/.vscode/extensions/ms-vscode.cpptools-/debugAdapters/bin/ with the attached files in zip.
('alt + .' in file manager to show hidden files)

MIEngine Konsole patch.zip

All 22 comments

The problem is xterm and gnome-terminal is hard-coded at terminal.ts.
`let defaultTerminalLinux = 'xterm';
if (env.isLinux) {
if (fs.existsSync('/etc/debian_version')) {
defaultTerminalLinux = 'x-terminal-emulator';
} else if (process.env.DESKTOP_SESSION === 'gnome' || process.env.DESKTOP_SESSION === 'gnome-classic') {
defaultTerminalLinux = 'gnome-terminal';
}
}

export const DEFAULT_TERMINAL_LINUX = defaultTerminalLinux;

export interface ITerminalConfiguration {
terminal: {
external: {
linuxExec: string,
osxExec: string,
windowsExec: string
}
};
}
`
How can I use "ITerminalConfiguration"?

A real simple solution to this is get a terminal path or name from launch.js and use it everywhere.

Hi @naveedrasheed,

What terminal emulator would you like to use?

For your reference, the code that launches the terminal emulator is not the one you copied (which is from the VSCode codebase), but rather it's here:

https://github.com/Microsoft/MIEngine/blob/master/src/MICore/TerminalLauncher.cs

(search for LinuxTerminalLauncher)

As you can see, one of the issues is that different terminal emulators take arguments in different ways: e.g., see the use of -x for gnome-terminal and -e for xterm.

Note that MIEngine is an open source project that accepts pull requests from the community, so feel free to play around and submit a fix.

@naveedrasheed, unfortunately, we can't simply add a terminal path for our launch options. The debugger has to interact with the terminal, and each terminal behaves differently, so we cannot support them all. Are you unable to install xterm?

Hello,
having the same probleme, im NOT able to install xterm. I have just installed Konsole.
Is there a way to change this in source code for myself? what do i have to build then?

greetz equinoxr

@equinoxr

If you are interested in trying to get Konsole to work for yourself, you can clone http://www.github.com/Microsoft/miengine, and edit the file src/MICore/TerminalLauncher. You can compile it with mono, or on Windows using .NET Desktop, and patch your copy of the dll.

We might be willing to take a pull request for it, but we don't have any automated tests for the terminal launch code, so it might not be possible for us to maintain.

Right now, we are working on trying to get our significant bug debt under control. After that, we plan to have the debugger work with the new integrated terminal for VS Code, so this problem will go away in the near future, we hope.

Uff, tried to compile Miengine but its just to complicated for me... could somone compile it for me as a amd64 Linux version? this whole project is too complicated for me... to muc depencies and stuff.. for someone who knows the project probably just a few clicks... so in TerminalLauncer.cs

    private const string GnomeTerminalPath = "/usr/bin/gnome-terminal";

private const string XTermPath = "/usr/bin/xterm";

should be

    private const string GnomeTerminalPath = "/usr/bin/konsole";

private const string XTermPath = "/usr/bin/konsole";

yeah its a work around, but then i could use visual studio code! (got no sudo rights to install xterm... :( )

@equinoxr, the MiEngine is a .NET dll. You don't need to compile it for a particular architecture. If you are on Linux, you should be able to build just the MICore project using Mono (you don't have to build the whole thing). Have you used Mono before? I'll see if I can track down some instructions for you.

hey thanks for your reply.

i build one hello world project with mono, thats it..
and the miengine dll is also in visual studio code in linux? confusing..

yeah if you would have some map how to compile it with mono on linux that would be cool...

thanks in anticipation and greetz ;)
equinoxr

ok build the dll with visual studio community, but now i got a new failure:

error while processing request 'launch' (exception: Could not load type 'Microsoft.MIDebugEngine.DebuggedProces' from assembly Microsoft.MIDebugEngine [...])

mhh ? any ideas what i did wrong?

greetz & thx

What did you build and what did you attempt to patch? I'm glad that you were able to compile with Visual Studio. Unfortunately, compiling on Linux is difficult, and I have yet to get it to work.

In order to get the particular assembly that you are interested working, you need only build the MICore project and replace the single dll that it generates. You may also like to base your changes off of the release-cpptools branch of the MIEngine, rather than Master. Master likely has some changes in it that are not in your copy of vscode.

Hi patched only the MICore.dll, this is now working ( when i choose cpptools branch and desktop.debug enviroment...), so i repoduced the failure with my own dll (cant find xterm failure) -- so there is no problem more.
But no i have really problems with konsole, because it seems like it takes the arguments in a total other way then xterm... tried things like --rcfile and stuff... can you give me an example how xterm is called vom vscode? E.g.

xterm -title "title" -e bash -c "[initscript btw what the hell is this??]"

so that i could try it in terminal and then with konsole...
konsole seems to not like "" sometimes and stuff..

took the whole day for this now, but still now solution ahhhhhhhhh :dancing_women:

hope its possible to do what i like................

greetz and thanks equinox

Glad you got it to compile, @equinoxr. Now that you are running into issues with launching konsole with the correct arguments, you might be able to see why it is that we can't support all of the different terminals available for Linux. There are just too many variations for us to be able to reliably test.

The init script is essentially an in-line bash script that tells sets up stdin/stdout redirection to talk to the debugger and launches gdb or lldb against the program that you want to debug. It is initialized inside LocalLinuxTerminalTransport and UnixUtilities.

That probably isn't so important, however. More important is how you set up the command to execute inside the terminal xterm uses -e . I don't know what Konsole uses, unfortunately. Just a cursory look at this: http://stackoverflow.com/questions/13714249/konsole-execute-a-script, makes it look like you can skip the --rcFile switch, and just use -e in the same way xterm does. I don't know how to set the title of the terminal however. You can try to just get rid of the title portion, though, and see if that will work.

OK solved it (was hard work! :) ):
I wrote _initScript in a Shell script (replaced ; with \n dont know if is necessary.. and worte "#!/bin/bash \n" on top)
`
string scriptPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/script.sh";

  File.WriteAllText(scriptPath, _initScript);

`

this was necessary because bash was confused with to many '' ...
i also had to chmod the script and then execute it here is the oneliner:
string terminalArguments = " --title " + _title + " -e \"/bin/bash -c \'" + "chmod +x " + scriptPath + " ; " + scriptPath + "\'\"";
(works with
private const string XTermPath = "/usr/bin/konsole";
I dont usw bashCommandPrefix...).

maybe it helps someone.

Greetz equinoxr

P.S.: Del Myers thanks for your help and where can I contact you? Have an idea regarding embedded Linux and VS Code...

@equinoxr, if you have some suggestions for the cpp tools for embedded Linux, feel free to log another issue here so that we can discuss it as a community. And I'm glad to help!

For those of you who want konsole support in VSCode C++ extension here's a modified version of MIEngine to allow that (It also prefers creating a new tab for the program output if you have a konsole window already launched)

Instructions:
Replace the files in "~/.vscode/extensions/ms-vscode.cpptools-/debugAdapters/bin/ with the attached files in zip.
('alt + .' in file manager to show hidden files)

MIEngine Konsole patch.zip

@KarthikJay Thanks for the patch, it worked great on my side.

my working folder like "ham-serv (copy)" and debugging was giving the same error. then I changed folder name "hamsertest" and worked fine. A problem can be some characters at path.

Is there way to run program in build-in terminal?

same issue. my terminal is: deepin-terminal.

Why not install a gnome-terminal or xterm?

@Cekerel why install them?

@LinArcX I agree with you, I don't want gnome-terminal or xterm.
A workaround for Debian 9/VSCode 1.28.1/Mate terminal 1.16.3 is to create a symlink from /usr/bin/mate-terminal.wrapper:
cd /usr/bin
ln -s /usr/bin/mate-terminal.wrapper xterm

Was this page helpful?
0 / 5 - 0 ratings