fix windev#4653
Conversation
|
this won't fix #4646 and even if it did there is already a open pr to fix it and changing winutil dev to accept args is good but it does it in a bloated way and can be improved |
|
Not really, because if current version is run without Admin privs, it didn't run pre-release, only the latest stable release. With this changes (beside making params work) if you run and passes tag so it actually run the pre-release |
|
The great and glorious AI at Google He/her/dog's telling me to do this $latestTag = (Invoke-RestMethod https://api.github.com/repos/ChrisTitusTech/winutil/tags).Name | Select-Object -First 1 |
|
in this PR so, the code AI gave you is valid, my code is just more generic |
In non-Admin terminal window, |
what?, again this pr won't fix the issue |
|
There are 2 bugs. First one masks the second. The logic that comes from $script = if ($PSCommandPath)` and beacuse it is `"& { & `'$($PSCommandPath)`' $($argList -join ' ') }"adds params for execution, then executes with admin privs: if ($processCmd -eq "wt.exe") {
Start-Process $processCmd -ArgumentList "$powershellCmd -ExecutionPolicy Bypass -NoProfile -Command `"$script`"" -Verb RunAs
} else {
Start-Process $processCmd -ArgumentList "-ExecutionPolicy Bypass -NoProfile -Command `"$script`"" -Verb RunAs
}If you try to run stable $script = if ($PSCommandPath) {
"& { & `'$($PSCommandPath)`' $($argList -join ' ') }"
} else {
"&([ScriptBlock]::Create((irm https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1))) $($argList -join ' ')"
}
$script = if ($PSCommandPath) {
"& { & `'$($PSCommandPath)`' $($argList -join ' ') }"
} else {
"&([ScriptBlock]::Create((irm https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1))) $($argList -join ' ')"
}downloads latest stable (effectively ignoring latest tag), and runs it if ($processCmd -eq "wt.exe") {
Start-Process $processCmd -ArgumentList "$powershellCmd -ExecutionPolicy Bypass -NoProfile -Command `"$script`"" -Verb RunAs
} else {
Start-Process $processCmd -ArgumentList "-ExecutionPolicy Bypass -NoProfile -Command `"$script`"" -Verb RunAs
}You can see it via version in $script = "&([ScriptBlock]::Create((irm https://github.com/ChrisTitusTech/winutil/releases/latest/download/winutil.ps1))) $($argList -join ' ')"` that get later executed with Admin privs. See version in $script = "&([ScriptBlock]::Create((Invoke-RestMethod -Uri https://github.com/ChrisTitusTech/winutil/releases/download/$latestTag/winutil.ps1))) $($argList -join ' ')" |
|
@jnsh-rf |
|
Then dont bitch about not understanding a problem that happens under very specific condition, that normal testing can't catch, and you dint bother to understand. And the bug you caused by not testing if windev would work with your changes. |
|
|
If the simplified version in that PR works, why don't you suggest changes here or send PR to my branch? |
also i can't make prs to forks (unless you know a way beause last time someone tried to do so for me it didn't work for them) |
|
i think you should close this pr it's just bloat |
|
I'll wait for Chris to decide. |
|
Why does it not work? Where does it fail? Where can it be improved? And most important - do you actually read what I wrote? If you want to me to know that something is wrong, point to it, explain and show better solution. Don't shout "its bad because its bad", take my work / investigation, and sell as yours. Unless you have something of value to add, don't bother responding. |
okay first problem second problem than you are adding a envrioment varible to the system to detact if winutil was launched with windev which is uneneccary you could just do a |
This PR isn't a duplicate. While #4651 targets the parameter error inside the core utility, this one fixes the broken my code does not pipe it via this PR is based on main, preserving ValidateSet is intended, btw
thats why code looks like this so it safely passes arguments; if wrong it wont break everything at some random point in execution chain $latestTag = (Invoke-RestMethod https://api.github.com/repos/ChrisTitusTech/winutil/tags).Name | Select-Object -First 1
$scriptString = Invoke-RestMethod -Uri https://github.com/ChrisTitusTech/winutil/releases/download/$latestTag/winutil.ps1
$scriptBlock = [scriptblock]::Create($scriptString)
& $scriptBlock @PSBoundParametersone of benefits of this approach is windev-only params, like specific tags
simple local variable like
Because WinUtil requires root privileges, the script immediately runs its admin check. Since the user is not an administrator, it prepares to launch a brand-new, elevated PowerShell window. When that new administrative window opens, it starts fresh RAM state with no memory of the variables or code that were running in the previous non-admin window. That's why it is hard to replicate. Without the exact version string (like |
|
you clearly don't seem to understand so let me make it clear for you WinUtill will not launch using the also this is incorrect |
|
Hey, the effort here is clear and the bug hunting is genuinely appreciated, but @GabiNun2 is right and it's worth understanding why before moving forward. The ValidateSet you added to windev.ps1 causes the exact same crash that started #4646 because users pipe windev.ps1 through iex with the standard command, and ValidateSet breaks under iex no matter where it sits, so the issue is still there just moved one level up. The env variable is also doing nothing useful because $latestTag is already in scope when the relaunch command string gets built, meaning the tag is naturally baked into that string before the new window ever opens, which is exactly what #4657 demonstrates with a much simpler approach. On the description, it is genuinely one of the longest PR descriptions in this repo for a change that touches three files, and while the investigation behind it is solid, writing five paragraphs of long and short versions, stack traces, and test harnesses when the core idea could have been explained in a few sentences makes it really hard for maintainers and contributors to engage with it, which is probably part of why this conversation went sideways. @GabiNun2 has been around this codebase long enough to know when something is adding unnecessary complexity and when a simpler path already exists, and in this case he is pointing at #4651 and #4657 which together cover everything this PR is trying to do without the contradictions. The best move here is to close this, let those two go through, and if you want to contribute the @PSBoundParameters improvement over @Args drop it as a small suggestion on #4657. Keep the next PR tight, explain only what changed and why, and when someone like @GabiNun2 points at a simpler solution it is worth slowing down and actually reading it before pushing back. Also on using AI for this kind of thing, it is a great tool for investigating bugs and drafting PRs but you have to actually verify what it gives you manually before putting it up, AI will confidently give you a solution that looks right but has the exact contradictions people pointed out here, make it dig deeper, question its own output, and always test before trusting it. The PR also breaks a few contributions guidelines directly. It should be focused on a single fix but the title alone mentions two separate things, both the bug and new feature boxes are checked, and the guidelines are clear that those should be separate PRs. The Compile.ps1 capitalisation change is an unrelated file edit which the guidelines say to avoid. On testing, the guidelines say to run .\Compile.ps1 -Run and verify nothing breaks before submitting, but a custom test script was used instead and @GabiNun2 showed the standard user command still crashes when tested properly. The description also has a caution note telling reviewers to read it fully which is a sign it went way beyond what the guidelines ask for, which is just explain what changed and why. |
|
if you wanna use AI to implement a fix to any bug you found or want to solve or a new feature idea you wan to implement, going further you can use this prep prompt before staring and it will make the AI work better , using AI is not wrong but not using it right is what people fallback on |
|
@vyas-devgna i couldn't have said it any better thank you |
|
also i did close #4657 because it was to niche because the only way someone will get this problem is if the user isn't running and admin using the dev branch since there is less than 20k users running windev and most of them are developers aka know what they are doing we shouldn't have this feature also if they are not running as admin it's not like it will fail it will just go to the main release so the user can still use winutil which has only been 1 person that we know of doing that out of millions so this will just be unneccary code |
that's fair |





Type of Change
Description