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

Fixes “Not a valid executable” error in installer #221

Merged
merged 3 commits into from
Dec 18, 2018

Conversation

aakriti-jain
Copy link
Contributor

This issue was addressed in git-for-windows/git#1951.
Currently, I have only edited the error message as it only showed the first 3 characters if the path was not of a valid .exe file.

I need a suggestion: Should I also make it support CMD commands using %PATH% enviroment? Currently the message is apt for its working.

Signed-off-by: Aakriti Jain [email protected]

Copy link
Member

@dscho dscho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use this opportunity to make the code less confusing... What do you think?

end;
if Pos('.exe',Lowercase(Path))=0 then begin
CustomEditorPath:=EditorPage.Values[0];
CustomEditorOptions:='';

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

@dscho
Copy link
Member

dscho commented Dec 7, 2018

Thank you so much for working on this!

Should I also make it support CMD commands using %PATH% enviroment? Currently the message is apt for its working.

I think it would be wonderful if the EnableNextButtonOnValidExecutablePath() function could try other things if it detects that the file referred by CustomEditorPath does not exist:

  • it could see whether CustomEditorPath lacks a file extension, and if it does, append the extensions listed in the environment variable PATHEXT (.com, .exe, .bat, etc) and see whether that exists (adjusting the CustomEditorPath variable accordingly).
  • it could see whether there is a dir separator in the path (\ or /), and if there is none, search through all the directories listed in the PATH environment variable.

Furthermore, instead of the hard-coded .exe test, it could extract the file extension and if there is one, verify that it is one of the items listed in PATHEXT (a neat trick is to surround that string with semicolons and then search for ;<ext>;, i.e. Pos(';'+FileExtension+';',';'+PathExt+';')).

This is asking a lot, though... it is kind of the triple serving of fries with home made aioli and the truffle mayonnaise.

@aakriti-jain
Copy link
Contributor Author

The code is currently such that after every change, it checks weather the variable CustomEditorPath exists and is an .exe file, and enables/disables the Next button accordingly. That means the status of button changes after every hit of keyboard.
I may be wrong, but wont this approach make a lot of overhead?

But still I am working on the solution for it. I will let you know if I manage to get it to work.

@dscho
Copy link
Member

dscho commented Dec 7, 2018

The code is currently such that after every change, it checks weather the variable CustomEditorPath exists and is an .exe file, and enables/disables the Next button accordingly. That means the status of button changes after every hit of keyboard.
I may be wrong, but wont this approach make a lot of overhead?

You're right!

I was wrong to mention that function. What I meant was the validation that would bug the user with that error message unless the path exists and ends in .exe.

@dscho
Copy link
Member

dscho commented Dec 9, 2018

Please note that Git v2.20.0 has already been released, and therefore I want to publish Git for Windows v2.20.0 as soon as possible.

Unfortunately, this means that this PR won't make it in before that version, but given that the custom editor option is relatively new (and does not seem to be used very often yet), I think we can take our time to hammer out the kinks and get it into v2.20.1 (or v2.20.0(2), or v2.21.0, whichever comes first after we're done with this PR). Does that sound okay, @aakriti-jain?

@aakriti-jain
Copy link
Contributor Author

Sorry @dscho I had exams in my college and had to pause the work on it. I will surely work on it and complete this task surely before the next release.

@dscho
Copy link
Member

dscho commented Dec 9, 2018

@aakriti-jain no worries. Do you want me to pick up some tasks, or do you want me to wait for you to do it all?

@aakriti-jain
Copy link
Contributor Author

@dscho If we have enough time, I'd love to work on this issue. I want to contribute to the project!

@dscho
Copy link
Member

dscho commented Dec 10, 2018

@aakriti-jain excellent. I think we have enough time. Just let me know whenever I can be of assistance.

@aakriti-jain
Copy link
Contributor Author

@dscho I have written the code as you suggested such that function PathIsValidExecutable now searches for every executable (in %PATHEXT%) in locations in %PATH%. And there is no noticeable lag too 😄
But when I test it with Sublime Text using the command subl -w, it would just get stuck, even after editing the temporary file and closing the editor. I tried this with the released version of Git for Windows (but instead giving complete path), had the same problem. VSCode works smoothly though.

So I guess this was not an error of the new code that I wrote, but with the Sublime Text instead. So should I try to fix this in the same PR or move it to a second?

@dscho dscho merged commit 30b895e into git-for-windows:master Dec 18, 2018
dscho added a commit that referenced this pull request Dec 18, 2018
This topic branch is based on the Pull Request at
#221 and then makes
sure that these work as well as we can make them:

- code --wait
- code.cmd --wait
- "C:\Program Files\Microsoft VS Code\bin\code.cmd" --wait
- "C:\Program Files\Some Editor\se.exe"
- C:\Program Files\Some Editor\se.exe

Hopefully this will satisfy every user (or at least give those who
really want something else, still, a good starting point to take care of
their own wishes).

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit that referenced this pull request Dec 18, 2018
The custom editor setting in the installer [has been improved
substantially](#221).

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho
Copy link
Member

dscho commented Dec 18, 2018

@aakriti-jain thank you so much! I worked a bit on top of your patches, and I think it should work with Sublime Text now. Could I ask you to test?

@aakriti-jain
Copy link
Contributor Author

Yes I will test it now! Sorry I was out of station these days and couldn't test it then. I will just test and complete this issue.

@aakriti-jain
Copy link
Contributor Author

@dscho all the cases have been tested and most of them worked perfectly fine! Thank you so much for the extra patches you made!

Just a thing more: This option is still disabled-
capture

I have Sublime Text 3 properly installed but its not showing so.

@dscho
Copy link
Member

dscho commented Dec 24, 2018

I have Sublime Text 3 properly installed but its not showing so.

Hmm. I don't have that installed...

Could you maybe debug by placing strategic "debug print statements" (I usually abuse LogError() for this purpose) and then run ./installer/release.sh -d Editor in /usr/src/build-extra/?

@aakriti-jain
Copy link
Contributor Author

Can I work on it a bit later in a separate PR? Been a bit busy these days

@dscho
Copy link
Member

dscho commented Jan 9, 2019

Can I work on it a bit later in a separate PR? Been a bit busy these days

Of course!

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

Successfully merging this pull request may close these issues.

2 participants