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

Back to create windows cmd script if symlink creation fails #57

Closed
wants to merge 9 commits into from

Conversation

enr
Copy link
Contributor

@enr enr commented Oct 11, 2022

This change allows you to use webman even if developer mode has not been enabled in windows:

if symlink creation fails, fallbacks to creating a script named ${executable name minus extension}.cmd.

Could impact #53 (and maybe #11) so, if you were interested in this, it would be necessary to correct the "Windows Symlink check" which I have left untouched right now.

@jolheiser
Copy link
Contributor

This would also need to know about the extension when removing, etc.

@enr
Copy link
Contributor Author

enr commented Oct 11, 2022

Hi @jolheiser ,
at the moment file name is resolved here:

https://github.com/enr/webman/blob/win-cmd/link/link_windows.go#L34

but I agree with the need to standardize the logic of creating executables (symlink or scripts) names which is now scattered in different functions.

@enr
Copy link
Contributor Author

enr commented Oct 11, 2022

Hi @jolheiser

This would also need to know about the extension when removing, etc.

I'm not on a windows machine now, I'll try the remove command as soon as I can.
Have you other advices about other places to check?
Cheeers, Enrico

@candrewlee14
Copy link
Owner

The run command may need to know about the .cmd extension as well. I'm interested to hear why you want this feature... originally I had Windows machines create .bat files instead of symlinks but we switched to symlinks since Windows 11 allows developer mode.

Do you have a Windows machine that you can't switch to Developer mode?

@enr
Copy link
Contributor Author

enr commented Oct 11, 2022

Hi @candrewlee14, exactly this: at dayjob I use a windows pc without administrative permissions.
I originally tried webman just because the readme specified No elevated permissions required! and in fact the first time installation worked perfectly creating the bat files, but with the latest release I have errors related to symlink.
If you are interested and do not see shortcomings in this, I am willing to try to bring the necessary changes to remove and run too.

@candrewlee14
Copy link
Owner

Makes sense, I'll probably run into use cases like that as well. I think allowing that would be good, but maybe with a warning on the first usage.

@jolheiser
Copy link
Contributor

To avoid situations where there might be a mix of symlink and cmd, maybe this should be a configuration setting?

That way instead of a fallback it can be consistently applied.

@enr
Copy link
Contributor Author

enr commented Oct 11, 2022

In this branch both the symlinks and the scripts have the executable name + .cmd:
in this way webman can not care about the type because in add it creates one or the other according to the system's capabilities, and in remove it knows that it will find the file to remove in .webman/bin/{name}.cmd which is symlink or script.
This is, imho, good for the development and robustness of the code but it can be counterintuitive for the user who could find a .cmd instead of the exe he was expecting.
A configuration could actually facilitate maintainability, I leave the decision to you

@jolheiser
Copy link
Contributor

One of the main reasons I drove for symlinks was because I ran into problems where only an exe (symlink) would work, such as a git extension, or using glow inside nvim.

I would personally prefer a config still, but I am not the only voice. 🙂
I'll leave the final decision to you and @candrewlee14

@candrewlee14
Copy link
Owner

I think a config makes more sense, the symlinks having a .cmd extension is a bit misleading and I think it'd be better to have that more clearly delineated.

@enr
Copy link
Contributor Author

enr commented Oct 11, 2022

I agree with the configuration.
with a system-wide property however, the problem would remain of resolving the exact name of the executable (in fact a user could install some software in one way and then change the property).
Maybe could be webman (when running the add command) to save the installation mode and possibly the correct names of all the files added in webman / bin

@jolheiser
Copy link
Contributor

The nice thing with a config is that doctor knows the state it should be in and can change accordingly.
If it is in symlink mode, it converts cmd files. If it's in cmd mode, it converts symlinks to cmd

@candrewlee14
Copy link
Owner

I like that idea from @jolheiser.

The format is specified in the config. If at any point you manually change that config, use the doctor.
Maybe there should also be a command that changes that config like webman config windows_symlinks off or something like that, which would auto-run the piece of doctor that moves all the binary links to use that configured format.

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.

3 participants