microsoft / vscode-maven

VSCode extension "Maven for Java"
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-maven
Other
183 stars 88 forks source link

command always has prefix character "&" #633

Open QingFengpoor opened 3 years ago

QingFengpoor commented 3 years ago

Describe the bug when run commands in Lifecycle or Plugins, it always starts with "&" in terminal. with CMD or BASH, get syntax error, unexpected token &.

Environments (please complete the following information as much as possible):

Screenshots xxx@xxxx MINGW64 /c/CodeProjects/Java/ReleaseNoteEditor/springmvc/releasenote issue (issue) $ & mvn compiler:testCompile -f "c:\CodeProjects\Java\ReleaseNoteEditor\springmvc\releasenote issue\pom.xml" bash: syntax error near unexpected token `&'

Eskibear commented 3 years ago

https://github.com/microsoft/vscode-maven/blob/63994716b6156fab360f64ee68148d42ecaff438/src/mavenTerminal.ts#L100-L106

That's possibly because PowerShell was wrongly detected. What terminal are you actually using? (looks like Git Bash?) You can check it by command Terminal: Select Default Profile as below image

QingFengpoor commented 3 years ago

@Eskibear yes, output of Terminal: select Default Profile looks like this

PowerShell C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe                               profiles
Git Bash ...
Command Prompt ...
---------------------------
Windows PowerShell ....                detected
Cygwin ....

the PowerShell profile is highlight. by default, my terminal is Git Bash. There is something wired that when I open VSCode for this project, the terminal is Powershell, while I add the second terminal, it is Git Bash. For other folders, it is the same. Additionally, when I open the second VSCode window, the terminal is Git Bash.

QingFengpoor commented 3 years ago

My settings.json contains

    "terminal.integrated.tabs.enabled": true,
    "terminal.integrated.scrollback": 1600,
    "terminal.integrated.defaultProfile.windows": "Git Bash",

only these three conditions for terminal.

Eskibear commented 3 years ago

"terminal.integrated.defaultProfile.windows": "Git Bash",

I can reproduce your issue by specifying above setting.

In this extension default shell is inferred from vscode.env.shell, defined in https://github.com/microsoft/vscode/blob/2f2b6b528d0062b81d7b3e16c88115827b84cfca/src/vs/vscode.d.ts#L8154-L8159

I believe it's a vscode issue due related to shell profiles.

Eskibear commented 3 years ago

See https://github.com/microsoft/vscode/issues/121760

Eskibear commented 3 years ago

Do you have entry "terminal.integrated.shell.windows" in your settings? If so, remove it. I just tried in latest insiders version, seems it has been fixed.

QingFengpoor commented 3 years ago

No. I have already noted it. // "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",.

QingFengpoor commented 3 years ago

Hi, Eskibear. I think my situation is different from the issue mentioned above.
Firstly, command terminal :select default profile shows the profile of Git Bash. terminal select default profile

Secondly, I have not use "terminal.integrated.shell.". All terminal settings(containing "terminal") are here:

    // terminal
    "terminal.integrated.tabs.enabled": true,
    "terminal.integrated.scrollback": 1600,
    // "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
    // "terminal.integrated.shellArgs.windows": [],
    "terminal.integrated.defaultProfile.windows": "Git Bash",
    // "terminal.integrated.automationShell.windows": "Git Bash",
Eskibear commented 3 years ago

Root cause is vscode.env.shell doesn't honor what you set in terminal.integrated.defaultProfile. I found similar issues in other popular extensions like python and code runner etc...

It looks vscode team has fixed that (but not released into stable version), and I tried but not repro your issue in latest insiders version. Can you verify if the issue is still there in latest insiders version?
FYI download it here: https://code.visualstudio.com/insiders/

QingFengpoor commented 3 years ago

Eskibear, I am out off work smile , and my work computer is in my company. I will try it next week. Thank u.

jaigarV commented 9 months ago

The issue is still present in Version: 1.85.1, I have run into it while using Python and a venv. Do you have any idea when will it be released in a stable version of vscode?