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

Newlines in arguments passed to node -e ... #1791

Open
julienp opened this issue Jul 12, 2024 · 5 comments
Open

Newlines in arguments passed to node -e ... #1791

julienp opened this issue Jul 12, 2024 · 5 comments
Labels

Comments

@julienp
Copy link

julienp commented Jul 12, 2024

We ran into an issue when calling node -e ... with a script that contains new lines. pulumi/pulumi#16649

Repro:

main.go:

package main

import (
	"fmt"
	"os/exec"
)

func main() {
	argWithNewLines := `if (true) {
		console.log("it's true!");
	}`
	cmd := exec.Command("node", "-e", argWithNewLines)
	out, err := cmd.Output()
	if err != nil {
		fmt.Printf("Error: %s", err)
	}
	fmt.Println(string(out))
}

Run with:

go run main.go

When I have the Volta shim node.exe in the path, I get an error:

PS C:\Users\pulumiadmin> go run main.go
Error: exit status 1

With the actual node.exe on path, it works:

PS C:\Users\pulumiadmin> go run main.go
it's true!
@chriskrycho
Copy link
Contributor

Ah, thanks for the report! That is indeed quirky, and we should make sure we pass that through cleanly!

@karthest
Copy link

That's weired , it's totally OK on wsl2 ubuntu with volta v1.1.1 and node v20.12.2. Maybe the issue is related to a specific environment
image

@julienp
Copy link
Author

julienp commented Aug 10, 2024

I am not much of a Windows user, from what I remember, I was able to reproduce this on a Windows (11 I think?) VM in Azure, not using WSL, no special config on the VM. We had at least 2 Pulumi users report an issue, where we narrowed down the root cause to this issue.

I don't know how the Volta shims work, but I guess when running under WSL it's doing an exec syscall, but on plain Windows it will have to do something more intricate I believe?

@charlespierce
Copy link
Contributor

Thanks for the reports, and the environment investigation! I suspect this might be related to the fact that we use cmd /C to execute the shimmed packages—I wonder if there's some strange argument handling there that is making it not parse correctly. I do a lot of my individual development on Windows, so should be able to investigate this weekend.

@charlespierce
Copy link
Contributor

Didn't get to investigating that weekend 😅 However just now I did confirm, and from some digging online, I think this might be a hard limitation of cmd.exe, which we use internally to handle resolving executables on Windows.

However, as mentioned in my most recent comment on #1761, that PR may provide a path forward to removing that use of cmd.exe entirely, which would (hopefully) resolve this in passing. I'm hoping to get an investigatory PR up that does that sometime today, though my flight is landing so I may run out of time!

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

No branches or pull requests

4 participants