You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Windows support with scoop installer without bash #198
I think PR #194 is progressing well and should improve Windows compatibility. I was under the impression that @hj-lee fork was more about start-up time improvements but it's interesting to hear that it also comes along with improved windows compatibility.
I still don't know if kscript can be fixed to become fully windows compatible because certain features like custom interpreters or script-packaging will just work in bash.
I've not used scoop yet, but we could add it to the list of installation options. All we'd need to do is to patch the readme and add the corresponding deployment bits to kscript_release.sh. Feel welcome to provide a PR for this feature.
Actually, my PR improves platform independence a bit as it makes kscript less dependant on bash.
By default, the main script uses the kscript java process, and if it uses runtime flags(such as -Xmx), it executes Java using Java process API on Windows instead of depending on bash.
Regarding PR #194, it seems @abelsromero wants to use kscript on "git-bash". It is possible that PR #194 is not helpful to build scoop distribution. Also, I think my PR can be helpful to simplify PR #194 as my PR eliminates critical bash or cmd calls (compiling and executing). (Actually, my forked master branch has other changes, and one of them is "git-bash" support.)
Regarding PR #194, it seems @abelsromero wants to use kscript on "git-bash".
Just for testing because there's already a test suite written in bash. I have added more unit test, but I don't know enough he code to do more changes. In the long term I'd like to cover everything with Kotlin unit tests and avoid the bash test, but that will require some refactor that I feel it's risky for my first PR.
In #194 I have implemented native Windows calls and adapted who paths are generated:
That can be fixed and I'd recommend moving that conversation to #197. If we all agree that next release's goal is full Windows compatibility we just need some coordination 👍
About @hj-lee I'd really like to see some of its improvements (specially the one "calling directly the kotlin compiler instead of bash") but I don't like "use classloader to run the script main and more" (I've experienced classpath pollution in gradle plugins that add code to the classpath).
Said that, I have to say that some of @hj-lee ideas are great but having many improvements in the same branch puts the leader in a complicated position of "all or nothing". How about splitting them so we can choose with ones we want merge asap?
thanks @hj-lee and @abelsromero for your continued efforts to improve kscript. I've read both PRs again, and here are my thoughts - side by side to easy the discussion.
Sorry @raisercostin for hijacking your ticket with this more general discusssion. :-)
194
pros
preserves current execution model
actual core or PR is slim: just adds some quoting and path-tweaks along with which->where for improved windows compatiblity
cons
PR adds includes many other changes. Some are arguage
possible incorrect way to guess KOTLIN_HOME under windows
new include resolve mechanism without clear reason* KscriptTest.ktm
unclear if integration tests should not better be implemented for the shell, since kscript is a shell tool instead of jUnit. (imho they should go into the shell)
testing it on windows seems suboptimal. we should be able to run existing test_suite.sh in WSL and git-bash and have a dedicated suite for powershell.
the kscript launcher is still highly unlikely to run under powershell. What did we gain? (WSL compatiblity? git-bash compatbility?) Can kscript work in powershell at all (without a new launcher)?
102
pros
avoiding external tools where possible
support for -J and -D makes sense
calling java instead of kotlin may help to solve class loader issues which are known for kotlin scripting mode.(although it feels a bit like cheating on the platform :-)
execellent prep for @ligee migration to new kotlin scripting API
cons
incosistent execution model in presence/absence of KOTLIN_OPTS:
first its using spawning a subprocess and
second when doing so it using differing interpreters (java->kotlin).
unclear/potential classpath polution. Will the user code inherit all the kscript dependencies? It must not imho to avoid version conflicts for instance.
i was happy to have moved all args processing away from shell launcher, now it's coming back
Other notes
in presence of KOTLIN_OPTS there is no speed-improvment in #102 I think.
selfUpdate should be removed (to specific and to tied to bash). users willwant to update using their preferred method anyway.
Use java instead of kotlin - Call java instead of kotlin by building a fat kscript jar.
@hj-lee how does the first part before the dash relate to other second part? I dont' see how your PR would build a fat jar, and I also don't think it's a good strategy because it would make initial script run very slow in case of complex dependencies.
having many improvements in the same branch
Clearly smaller PRs are easier to merge. However its a bit tedious to create multiple PRs for every miniscule change, because they need to go into separate branches of the fork. So pooling them into a big-mother-of-all-PRs makes life much easier. :-)
Both #102 and #194 seem to stray from their original indent to some extent, but I can indeed cherry pick changes instead of a full merge as needed. So no need to split anything up.
Summary
To me #194 is a more incremental workaround for an improved windows compatbility which comes with some unclear/uneeded other changes (listed above). I may exclude these from the merge, which I'll try to do in the next days. But even with the PR, windows compatbility of kscript seems imho not really ready for primetime (missing powershell lancher, missing CI like using appveyor).
Clearly #102 goes much deeper by changing the execution model. This definitly results in a cleaner design without so many external tool invocations. However, because I care about backwards compatiblity much more than about a slightly faster execution, I don't feel ready yet to merge it because of my concerns/questions listed above). Once these are resolved, #102 is clearly the way forward.
PR adds includes many other changes. Some are arguage
* possible incorrect way to guess KOTLIN_HOME under windows
I tested several way and found no other that worked fine con cmd. :%
* new include resolve mechanism without clear reason* `KscriptTest.kt`m
I don't know what do you mean, I created the tests to help me test & and specially debug. They are not perfect, but the tests are the problem, feel free to delete them.
The dependency resolution is the result of the rebase from the master with #159.
* testing it on windows seems suboptimal. we should be able to run existing test_suite.sh in WSL and git-bash and have a dedicated suite for powershell.
I understood that was OK to be added in a separate PR.
* the kscript launcher is still highly unlikely to run under powershell. What did we gain? (WSL compatiblity? git-bash compatbility?) Can kscript work in powershell at all (without a new launcher)?
We can add a ".bat" similar to how gradlew works. Do you think this will suffice?
It may be a sound improvement, but the intent is not really clear to me yet.
testing in separate PR.
You already added some new tests, so my question/comment was rather about why the current tests are not sufficient to cover windows (e.g. when using kscript in a git-bash environment). I was initially under the impression that we wanted to fix kscript to pass the existing tests on windows first, and add more CI for git-bash, powershell, etc. later.
We can add a ".bat" similar to how gradlew works.
I have worked too little with windows in the last years, I don't know what the best practice would be. Providing a *bat version seems like a solution, but since kscript was intended to be used mainly as an interpreter (via shebang), so I'm not sure if kscript.bat would work.
It may be a sound improvement, but the intent is not really clear to me yet.
testing in separate PR.
You already added some new tests, so my question/comment was rather about why the current tests are not sufficient to cover windows (e.g. when using kscript in a git-bash environment). I was initially under the impression that we wanted to fix kscript to pass the existing tests on windows first, and add more CI for git-bash, powershell, etc. later.
We can add a ".bat" similar to how gradlew works.
I have worked too little with windows in the last years, I don't know what the best practice would be. Providing a *bat version seems like a solution, but since kscript was intended to be used mainly as an interpreter (via shebang), so I'm not sure if kscript.bat would work.
Can't recall exactly why I did this in e4c34d6#diff-71918461924a453d7a1654dcc529ba78R39 other than the fact that "./" does not wok for a windows path with "", and that this solution works fine for all OSs.
Providing a *bat version
That's the standard approach, just check how gradle wrapper does.
BTW: I have to attend some thing following weeks :% so I think is better to close all other PRs first. After that I will create a new one from master including the changes and comments manually to avoid mix the git history. Is that OK?
On Thu, Sep 30, 2021 at 1:08 PM pmatysek ***@***.***> wrote:
Can someone give me advice how to use kscript on Windows?
I should add to the secript something like that?
#!C:\Program Files\Git\git-bash.exe kscript
It shows me error [kscript] [ERROR] kotlinc is not in PATH, but kotlinc surely is in PATH
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.
As I said before kotlin was in path. So I've made some investigation and testing. As I figured out problem was with bash -c command. For some reason it's not showing any output neither while running on my windows cmd nor from kscript. There wasn't any output even from simple echo. Fortunately I found that command sh -c is working perfectly.
For that reason I wrote some piece of code which is choosing proper bash command for OS, here: #331
However I'm not sure if problem is only in my enviroment (with git-bash instalation or some windows configuration?) or global for windows.
Activity
holgerbrandl commentedon Dec 4, 2018
I think PR #194 is progressing well and should improve Windows compatibility. I was under the impression that @hj-lee fork was more about start-up time improvements but it's interesting to hear that it also comes along with improved windows compatibility.
I still don't know if
kscriptcan be fixed to become fully windows compatible because certain features like custom interpreters or script-packaging will just work in bash.I've not used scoop yet, but we could add it to the list of installation options. All we'd need to do is to patch the readme and add the corresponding deployment bits to kscript_release.sh. Feel welcome to provide a PR for this feature.
hj-lee commentedon Dec 4, 2018
Actually, my PR improves platform independence a bit as it makes kscript less dependant on bash.
By default, the main script uses the kscript java process, and if it uses runtime flags(such as -Xmx), it executes Java using Java process API on Windows instead of depending on bash.
hj-lee commentedon Dec 4, 2018
Regarding PR #194, it seems @abelsromero wants to use kscript on "git-bash". It is possible that PR #194 is not helpful to build scoop distribution. Also, I think my PR can be helpful to simplify PR #194 as my PR eliminates critical bash or cmd calls (compiling and executing). (Actually, my forked master branch has other changes, and one of them is "git-bash" support.)
abelsromero commentedon Dec 5, 2018
Just for testing because there's already a test suite written in bash. I have added more unit test, but I don't know enough he code to do more changes. In the long term I'd like to cover everything with Kotlin unit tests and avoid the bash test, but that will require some refactor that I feel it's risky for my first PR.
In #194 I have implemented native Windows calls and adapted who paths are generated:
abelsromero commentedon Dec 5, 2018
That can be fixed and I'd recommend moving that conversation to #197. If we all agree that next release's goal is full Windows compatibility we just need some coordination 👍
About @hj-lee I'd really like to see some of its improvements (specially the one "calling directly the kotlin compiler instead of bash") but I don't like "use classloader to run the script main and more" (I've experienced classpath pollution in gradle plugins that add code to the classpath).
Said that, I have to say that some of @hj-lee ideas are great but having many improvements in the same branch puts the leader in a complicated position of "all or nothing". How about splitting them so we can choose with ones we want merge asap?
hj-lee commentedon Dec 5, 2018
@abelsromero, #194 may be sufficient to support scoop, then. I guess @raisercostin can see?
Regarding #102, let's continue discussion on it.
(By the way, you're welcome @raisercostin)
holgerbrandl commentedon Dec 7, 2018
thanks @hj-lee and @abelsromero for your continued efforts to improve
kscript. I've read both PRs again, and here are my thoughts - side by side to easy the discussion.Sorry @raisercostin for hijacking your ticket with this more general discusssion. :-)
194
pros
which->wherefor improved windows compatiblitycons
PR adds includes many other changes. Some are arguage
KscriptTest.ktmunclear if integration tests should not better be implemented for the shell, since kscript is a shell tool instead of jUnit. (imho they should go into the shell)
testing it on windows seems suboptimal. we should be able to run existing test_suite.sh in WSL and git-bash and have a dedicated suite for powershell.
the kscript launcher is still highly unlikely to run under powershell. What did we gain? (WSL compatiblity? git-bash compatbility?) Can kscript work in powershell at all (without a new launcher)?
102
pros
cons
KOTLIN_OPTS:argsprocessing away from shell launcher, now it's coming backOther notes
in presence of
KOTLIN_OPTSthere is no speed-improvment in #102 I think.selfUpdateshould be removed (to specific and to tied to bash). users willwant to update using their preferred method anyway.@hj-lee how does the first part before the dash relate to other second part? I dont' see how your PR would build a fat jar, and I also don't think it's a good strategy because it would make initial script run very slow in case of complex dependencies.
Clearly smaller PRs are easier to merge. However its a bit tedious to create multiple PRs for every miniscule change, because they need to go into separate branches of the fork. So pooling them into a big-mother-of-all-PRs makes life much easier. :-)
Both #102 and #194 seem to stray from their original indent to some extent, but I can indeed cherry pick changes instead of a full merge as needed. So no need to split anything up.
Summary
To me #194 is a more incremental workaround for an improved windows compatbility which comes with some unclear/uneeded other changes (listed above). I may exclude these from the merge, which I'll try to do in the next days. But even with the PR, windows compatbility of kscript seems imho not really ready for primetime (missing powershell lancher, missing CI like using appveyor).
Clearly #102 goes much deeper by changing the execution model. This definitly results in a cleaner design without so many external tool invocations. However, because I care about backwards compatiblity much more than about a slightly faster execution, I don't feel ready yet to merge it because of my concerns/questions listed above). Once these are resolved, #102 is clearly the way forward.
abelsromero commentedon Dec 8, 2018
I tested several way and found no other that worked fine con cmd. :%
I don't know what do you mean, I created the tests to help me test & and specially debug. They are not perfect, but the tests are the problem, feel free to delete them.
The dependency resolution is the result of the rebase from the master with #159.
I understood that was OK to be added in a separate PR.
We can add a ".bat" similar to how gradlew works. Do you think this will suffice?
holgerbrandl commentedon Dec 10, 2018
Sorry for the confusion. I meant the change e4c34d6#diff-71918461924a453d7a1654dcc529ba78R39
It may be a sound improvement, but the intent is not really clear to me yet.
You already added some new tests, so my question/comment was rather about why the current tests are not sufficient to cover windows (e.g. when using
kscriptin a git-bash environment). I was initially under the impression that we wanted to fixkscriptto pass the existing tests on windows first, and add more CI for git-bash, powershell, etc. later.I have worked too little with windows in the last years, I don't know what the best practice would be. Providing a
*batversion seems like a solution, but sincekscriptwas intended to be used mainly as an interpreter (via shebang), so I'm not sure ifkscript.batwould work.holgerbrandl commentedon Dec 10, 2018
Sorry for the confusion. I meant the change e4c34d6#diff-71918461924a453d7a1654dcc529ba78R39
It may be a sound improvement, but the intent is not really clear to me yet.
You already added some new tests, so my question/comment was rather about why the current tests are not sufficient to cover windows (e.g. when using
kscriptin a git-bash environment). I was initially under the impression that we wanted to fixkscriptto pass the existing tests on windows first, and add more CI for git-bash, powershell, etc. later.I have worked too little with windows in the last years, I don't know what the best practice would be. Providing a
*batversion seems like a solution, but sincekscriptwas intended to be used mainly as an interpreter (via shebang), so I'm not sure ifkscript.batwould work.abelsromero commentedon Dec 15, 2018
Can't recall exactly why I did this in e4c34d6#diff-71918461924a453d7a1654dcc529ba78R39 other than the fact that "./" does not wok for a windows path with "", and that this solution works fine for all OSs.
That's the standard approach, just check how gradle wrapper does.
BTW: I have to attend some thing following weeks :% so I think is better to close all other PRs first. After that I will create a new one from master including the changes and comments manually to avoid mix the git history. Is that OK?
holgerbrandl commentedon Dec 16, 2018
Sure. If possible keep the new PR as focused as possible to easy merging.
holgerbrandl commentedon Jun 24, 2019
Windows support has improved considerably (still relies on gitbash but this is per design), so I'm closing this ticket.
pmatysek commentedon Sep 30, 2021
Can someone give me advice how to use kscript on Windows?
I should add to the script something like that?
#!C:\Program Files\Git\git-bash.exe kscriptIt shows me error
[kscript] [ERROR] kotlinc is not in PATH, but kotlinc surely is in PATHholgerbrandl commentedon Sep 30, 2021
pmatysek commentedon Oct 11, 2021
As I said before kotlin was in path. So I've made some investigation and testing. As I figured out problem was with
bash -ccommand. For some reason it's not showing any output neither while running on my windows cmd nor from kscript. There wasn't any output even from simpleecho. Fortunately I found that commandsh -cis working perfectly.For that reason I wrote some piece of code which is choosing proper bash command for OS, here: #331
However I'm not sure if problem is only in my enviroment (with git-bash instalation or some windows configuration?) or global for windows.
holgerbrandl commentedon Oct 23, 2021
Thanks for your clarifying description. Though, I'm not sure how to fix/incorporate that into kscript.