-
-
Notifications
You must be signed in to change notification settings - Fork 296
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
Executing scripts with ./ results in an error in Windows 11 #1660
Comments
Works for me. That is, I have no difficulty running external commands (programs) from an Elvish shell on Windows 11; even using a relative path:
What version of Elvish are you running ( |
@SpacewaIker, ping? Is this still an issue for you? If it is can you answer my questions from my previous comment? If this is no longer an issue for you it would be appreciated if you explained what the problem was and close this issue. |
I have elvish version #!/bin/sh Which I now realize probably doesn't work on Windows. After further testing, here's what I found: With Powershell, running the With cmd, running With elvish, running either I also tried writing a simple shell script for testing: #!/bin/sh
echo "hello world" But this one gives weird results: Powershell and cmd want to open the file in a new program (with a windows dialog) when executing the script, while elvish gives the error So honestly, I'm not sure what's going on. It seems like elvish is trying to run scripts through windows cmd, which is failing because of the leading ./, which is required to elvish to execute the file as a script. But as I said, I didn't have this problem before, and scripts were executing as expected. Not sure what changed on my computer since then... |
I'm pretty sure that when you type
No, it is not. This is what I see when I attempt to run a shell script with a shebang line on Windows 11:
I understand what is happening on my system but do not understand what is happening on your system. Scripts with shebang lines do not work on Windows 11. At least not with Elvish. That's because on UNIX systems the shebang line is interpreted by the OS kernel. Elvish simply tells the OS kernel to execute the script and the kernel reads the first line, recognizes the shebang, and turns the execution request into I have a framework that I use for automating the building and unit testing of projects like Elvish on various virtual machines I run locally. Including a Windows 11 VM. For the Windows 11 system I explicitly execute statements like |
Also, Google for "windows script shebang" and you will find a lot of discussion about this topic. If your script has an explicit extension (e.g., |
Yes, it does seem like running As for the rest, firstly I appreciate the explanations, I'm not very knowledgeable about this kind of stuff and I like to learn more. Secondly, I tried downloading elvish v0.18.0, and the behaviour was different. With this version, running I do see something about executables on windows in the release notes for version 0.19.0, but it's listed as a bug fix and is related to command completion, so I'm not sure why the above works on version 0.18.0 but not 0.19.0. Is it possible that this is a bug that was introduced in version 0.19.0? Maybe the way that the scripts are run by elvish is different and broke things on windows? Probably not, since you said you didn't have any issues running scripts from windows, but maybe I misunderstood. In any case, I can switch to version 0.18.0 for the time being and I'll see if the issue persists when version 0.20.0 comes out. I'd be happy to look into this issue further but as I said, I don't know much about shells and all of this stuff, and I don't know Go either... |
@SpacewaIker Presumably The behavior you observed between 0.18.0 and 0.19.0 is likely caused by a Go standard library change (https://tip.golang.org/doc/go1.19#os-exec-path). When Elvish was compiled with an older version of Go compiler, it respected That |
Filed golang/go#58743 |
My apologies, I did not mean to leave that impression. I was showing how I don't have any issues running programs (i.e., binary executables) using a relative path like |
@xiaq Yes actually! I hadn't thought of using @krader1961 I see, thanks for the clarification. So since |
I can't think of a good reason why |
This is something that PowerShell seems to do anyway, |
I'm trying to execute a
gradlew
file in a java project like soThe command/file part is highlighted in green, seemingly indicating that elvish knows what I'm talking about. However, when I execute this, I get:
I'm fairly sure that when I first installed elvish, executing scripts like this worked, but now it doesn't anymore. I honestly don't know what could cause this issue, which is why my description is so vague. Has anyone else had this issue? Should I just try to reinstall elvish? Thanks!
The text was updated successfully, but these errors were encountered: