kevincobain2000 / gobrew

Go version manager, written in Go. Super simple tool to install and manage Go versions. Install go without root. Gobrew doesn't require shell rehash.
https://medium.com/web-developer/go-version-manager-gobrew-c8750157dfe6
MIT License
369 stars 24 forks source link

Fix: Win10 symlink require privilege #175

Closed vunhatchuong closed 8 months ago

vunhatchuong commented 8 months ago

Problem

  1. Symlink on Windows 10 Powershell required privilege, so we need to use cmd to create a symlink with mklink. See issue https://github.com/kevincobain2000/gobrew/issues/174

  2. filepath.EvalSymlinks doesn't work correctly on Windows. A fix is currently being proposed: https://github.com/golang/go/issues/63703

kevincobain2000 commented 8 months ago

Thanks Please wait for @juev's review

juev commented 8 months ago

@kevincobain2000 has become much better now, but I still don't like the idea of calling third-party programs from the code.

In addition, Windows has a lot of shell, that is, many launch options and each may have its own problems.

In my opinion, if we have a problem with creating a simlink, we can simply copy the directory from a certain version to the current directory.

For example, when it is necessary to switch the version:

  1. Remove the directory with the current version from versions
  2. Move or copy the version from current to versions
  3. Clear the current directory
  4. Copy the directory from versions/{version} to current

If it is not available, we download from the Internet accordingly.

Here you still need to think about how to solve the problem with copying the bin directory. But it seems that it is much easier than starting individual processes.

What do you think?

kevincobain2000 commented 8 months ago

Hi @juev Thanks for the review. I also do not prefer shell invoked as separate exec.

Your suggestion on version switch is good, it can be done natively - all in GO. But again, it is windows, I didn't intend to support powershell in the first place, people could just wsl instead.

Having said all that, if calling a separate powershell command, temporarily solves this issue, then it is cool. The same implementation will never get merged if it was a unix based os, and would code in GO. Also I have a windows machine now, but hate the idea of powershell in the first place. But people want it so be it as dirty as it can get.

kevincobain2000 commented 8 months ago

If you are ok then I am also ok for this merge. It's not like it is changing anything for unix based os.

kevincobain2000 commented 8 months ago

Let me know if you are ok with merge @juev

kevincobain2000 commented 8 months ago

Thanks @juev will merge it after dinner