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

Maven output does not write to the VSC terminal window #489

Closed
RedWingBB opened this issue Apr 28, 2020 · 15 comments
Closed

Maven output does not write to the VSC terminal window #489

RedWingBB opened this issue Apr 28, 2020 · 15 comments
Assignees
Milestone

Comments

@RedWingBB
Copy link

When I run maven/package a new cmd window is launched and the build output is written to it

I right click the maven project, then Package
A cmd window pops up
The build output streams into it
Then the cmd window closes
This makes it difficult to see if the build succeeded, what were the problems, so on

It may be there is a configuration option in the plugin or in VSC itself that I havent found

Environment is an admin login on Windows Server 2090
Uploading a screen shot, I hope it shows up.

image

@Eskibear
Copy link
Member

Eskibear commented Apr 29, 2020

The command is expected to run on integrated terminal withing vscode.

  • What's your vscode's default integrated terminal? (can be found by Command palette -> Terminal: Select default shell)
  • And what's the exact command it sent to vscode? (you can press up in vscode's integrated terminal to find)

@Eskibear Eskibear self-assigned this Apr 29, 2020
@Eskibear Eskibear added the needs more info Further information is requested label Apr 29, 2020
@no-response
Copy link

no-response bot commented May 13, 2020

This issue has been closed automatically because it needs more information and has not had recent activity. Please reach out if you have or find the answers we need so that we can investigate further.

@Eskibear
Copy link
Member

@RedWingBB
It's probably because you've wronly set maven.executable.path by your own. Please check if the path ends with "mvn.cmd" instead of "mvn".

@RedWingBB
Copy link
Author

Thanks for the reply
Here is my command line
C:\Program Files (x86)\Apache\apache-maven-3.6.3\bin\mvn
My Terminal is Powershell

@no-response no-response bot removed the needs more info Further information is requested label May 29, 2020
@no-response no-response bot reopened this May 29, 2020
@Eskibear
Copy link
Member

If the ".cmd" file extension is not specified, powershell will run a CMD propmt in a new window.

What you can do now

Append ".cmd" to "mvn", that it, to set maven.executable.path to C:\Program Files (x86)\Apache\apache-maven-3.6.3\bin\mvn.cmd. Have a try, and let me know if it works.

@Eskibear
Copy link
Member

Fixed in #499

@RedWingBB
Copy link
Author

Adding .cmd did it
Thanks for the reply

@Nicryc
Copy link

Nicryc commented Sep 8, 2021

@Eskibear Since the last update of VSCode (August 2021 – 1.60) I'm facing this issue too.

Maven is forced inside a Powershell integrated terminal (although my default terminal is cmd) and run the following command : & "path\to\apache-maven-3.2.5\bin\mvn" clean install -f "path\to\pom.xml" which has for effect to open an external cmd terminal and running Maven inside. Everything was working as intended before this update though, that's really weird.

Adding a .cmd to mvn just give me a CommandNotFoundException

Working on Windows 10. Executed mvn through a right click to the Maven project and used a favourite command defined in maven.terminal.favorites : clean install

@Eskibear
Copy link
Member

Eskibear commented Sep 8, 2021

Since the last update of VSCode (August 2021 – 1.60) I'm facing this issue too.

It's possible that vscode has changed something. Reading release note of the August version, you'll find recently they have been working on terminal related improvement.

Maven is forced inside a Powershell integrated terminal (although my default terminal is cmd)

True, I can reproduce it.

run the following command : & "path\to\apache-maven-3.2.5\bin\mvn" clean install -f "path\to\pom.xml"

I cannot reproduce it, what's your maven.executable.path? On my machine, I set it to "C:\apache-maven-3.8.1\bin\mvn", and it ran PS > & "C:\apache-maven-3.8.1\bin\mvn.cmd" clean -f "path-to-pom.xml", appending ".cmd" to "mvn". And it was executed in integrated terminal.

The "&" was added here when powershell was detected as default shell:

if (currentWindowsShell() === ShellType.POWERSHELL) {
return `& ${cmd}`;
} else {

And the terminal is created using vscode's API, which should also use default shell. You mentioned a Powershell was used, and that looks consistent with above "&" behavior.

The problem is, why ".cmd" was not appended to your "mvn". Because it's also intentionally done for Powershell in #499

switch (currentWindowsShell()) {
case ShellType.WSL:
return await toWslPath(filepath);
case ShellType.POWERSHELL: {
// On Windows, append .cmd for `path/to/mvn` to prevent popup window
// See: https://github.com/microsoft/vscode-maven/pull/494#issuecomment-633869294
if (path.extname(filepath) === "") {
const amended: string = `${filepath}.cmd`;
if (await fse.pathExists(amended)) {
return amended;
}

Actions for you to take

Please help to check below:

  • What's your maven.executable.path setting?
  • Do you have path\to\apache-maven-3.2.5\bin\mvn**.cmd** on your filesystem?
  • What's you OS and how do you launch VS Code (desktop/web/codespaces/remote container/WSL/etc...)?

@Eskibear Eskibear reopened this Sep 8, 2021
@Eskibear Eskibear added this to the 0.34.0 milestone Sep 8, 2021
@Nicryc
Copy link

Nicryc commented Sep 11, 2021

  • My maven.executable.path : C:\Users\nicryc\Documents\Programmes portables\apache-maven-3.2.5\bin\mvn
  • I don't have a mvn.cmd in my filesystem.
  • I'm running Windows 10 and VS Code desktop.

I have downloaded my Maven version here and it doesn't provide a mvn.cmd.

@Eskibear
Copy link
Member

@Nicryc Thanks for the information. I can reproduce it now.

I don't have a mvn.cmd in my filesystem.

True. The problem is maven-3.2.5 use mvn.bat instead of mvn.cmd. I'll fix that ASAP.

For the moment you can set maven.executable.path to C:\Users\nicryc\Documents\Programmes portables\apache-maven-3.2.5\bin\mvn.bat as a workaround.

@Eskibear
Copy link
Member

For the moment you can set maven.executable.path to C:\Users\nicryc\Documents\Programmes portables\apache-maven-3.2.5\bin\mvn.bat as a workaround.

@Nicryc I simply provided a fix appending ".bat" or ".cmd" accordingly, covering your case. Please kindly let me know if that works for you. Thanks.

@Eskibear
Copy link
Member

will be shipped in 0.34.0.

To verify:

  1. download a maven-3.2.5 distribution, and extract somewhere
  2. set maven.executable.path to "<path-to-maven-3.2.5>/bin/mvn" (without file extension)
  3. change vscode default shell to PowerShell.
  4. Run maven commands, e.g. clean , see if it works.

@Eskibear
Copy link
Member

mitigated in v0.34.0

@Nicryc
Copy link

Nicryc commented Sep 24, 2021

Ok this is working like a charm. Thanks.

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

No branches or pull requests

3 participants