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

VSCode can't launch haxe #119

Closed
RedHairHead opened this issue Feb 25, 2020 · 18 comments
Closed

VSCode can't launch haxe #119

RedHairHead opened this issue Feb 25, 2020 · 18 comments

Comments

@RedHairHead
Copy link

I have the following configuration files:

build.hxml

-cp src
-D analyzer-optimize
-main Main
--interp

task.json

{
	"version": "2.0.0",
	"tasks": [
		{
			"label": "Broken",
			"command": "haxe",
			"args": [
				"build.hxml"
			],
			"group": "build"
		},
		{
			"label": "Working",
			"command": "haxe.cmd",
			"args": [
				"build.hxml"
			],
			"group": "build"
		},
	]
}

As you can see, the two tasks differ only in that the first calls command haxe, and the second command haxe.cmd.
When second task works, first produces an error:

> Executing task: C:\npm\haxe build.hxml <

The terminal process command 'C:\npm\haxe build.hxml' failed to launch (exit code: {2})

Not sure, but it's possible that this only reproduced on Windows 10, because I don’t remember that I came across this on Windows 7 (now there is no way to check).

And one more important point. A broken task will work without errors if haxe is installed on the system through a standard installer, but the installed version of the compiler is executed, and not the one specified in .haxerc.

Version: 1.42.1 (user setup)
Commit: c47d83b293181d9be64f27ff093689e8e7aed054
Date: 2020-02-11T14:45:59.656Z
Electron: 6.1.6
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Windows_NT x64 10.0.18362
@Gama11
Copy link
Member

Gama11 commented Feb 25, 2020

Is there a reason you use custom tasks, rather than those auto-generated by vshaxe? Together with the Lix VSCode extension, that should work fine.

@RedHairHead
Copy link
Author

@Gama11 It's funny what exactly you ask about it because I started using tasks in this way when I saw something similar in your repository.
https://github.com/Gama11/HaxeRepro/blob/c4061a64456c1f2a994dbcdd43e169339e37cf97/.vscode/tasks.json

It seems to me very convenient that for each goal its own task is used and each of them can be configured as you like without changing the .hxml file.

@Gama11
Copy link
Member

Gama11 commented Feb 25, 2020

Have a look at the settings.json in that repo. If you do it that way, the tasks will still be generated by vshaxe.

@RedHairHead
Copy link
Author

Sorry for the noobs questions. I still can’t understand why the usual way to start tasks does not work, but I downloaded HaxeRepro and tried to figure out what to do. As I understand it, I have to choose a configuration using >Haxe: Select Configuration, and then run >Tasks: Run Build Task. This works, but I also get an error when starting the debugger:

PreLaunchTask 'HL / JIT (debug)' exited with exit code {1}.

This appears not only for HL, but for all targets. Although, if click Debug Anyway, debugging works. This is normal?

@Gama11
Copy link
Member

Gama11 commented Feb 25, 2020

That only works as long as you already compiled HL successfully before.

I'm not sure what's wrong with with your tasks, I was just wondering why you were doing it that way to begin with. Are you using a local or a global lix setup?

@RedHairHead
Copy link
Author

I am successfully compiling HL. The error occurs when preLaunchTask passes any arguments to the compiler. I use this because it works with a typical haxe installation. This is convenient because I can describe the general arguments of the compiler in the hxml file, and the specific ones for each targets in the tasks. But when using Lix, I can have only one default task ("active configuration"), others just do not work. Lix setup local, but this does not affect anything in this case.

@Gama11
Copy link
Member

Gama11 commented Feb 25, 2020

If you have a local lix setup, you probably want to be calling Haxe through npx haxe - so in your VSCode task, that would be command: "npx", and haxe as the first argument.

I am successfully compiling HL

With a VSCode task? Or on the command line?

@RedHairHead
Copy link
Author

The error occurs even when I use the global setup. Running Haxe from the command line works. But running through a task (with the same arguments) doesn`t work.

With a VSCode task?

Tasks don't work (except for the active configuration task). And since a task is called in the debugger configuration("preLaunchTask": "HL/JIT (debug)"), this also causes an error.
As a result, I cannot create my own tasks and cannot specify tasks in the debugger configuration.

@Gama11
Copy link
Member

Gama11 commented Feb 25, 2020

Have you tried with npx haxe?

@RedHairHead
Copy link
Author

I tried it. Same error.
The terminal process command 'C:\Program Files\nodejs\npx haxe build.hxml --interp' failed to launch (exit code: {2})

@RedHairHead
Copy link
Author

I tried to do the same on my old laptop with Windows 7. And it works without errors! Apparently the problem is in VSCode on Windows 10. Sadness.

@RedHairHead
Copy link
Author

Since the tasks still work, if I call haxe.cmd, the question is, does haxe.exe do something that haxe.cmd doesn't, or can I use it safely?

@Gama11
Copy link
Member

Gama11 commented Feb 25, 2020

The terminal process command 'C:\Program Files\nodejs\npx haxe build.hxml --interp' failed to launch (exit code: {2})

Hm, I can reproduce that too, not sure why that's happening...

@Gama11
Copy link
Member

Gama11 commented Feb 25, 2020

Ah, you need "type": "shell". Makes sense, cmd files can't be launched as a process... (npx is a cmd file too)

@Gama11
Copy link
Member

Gama11 commented Feb 25, 2020

Something is still off though, VSCode docs claim that that should already be the default value, in which case explicitly specifying it shouldn't make a difference:

@RedHairHead
Copy link
Author

Hmm, really weird, but it solves the problem. It is not clear why the error cannot be reproduced if you install Haxe using the installer. But such a solution is enough for me. Thanks!

@Gama11
Copy link
Member

Gama11 commented Feb 26, 2020

Well, with the regular Haxe installer there's no haxe.cmd, just a haxe.exe.

@Gama11
Copy link
Member

Gama11 commented Feb 26, 2020

I think everything other than that "default value" hint in VSCode is clear now (opened an issue for that: microsoft/vscode#91553), so I'll close.

@Gama11 Gama11 closed this as completed Feb 26, 2020
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

2 participants