MSYS2 TIPS

You might be surprised why I am using MSYS2 so much these days. In short, my new job doesn't allow me to use Linux at work. I cannot bear the CMD.EXE and PWSH.EXE, they might be great tools for someone else, but definitely not for me.

  1. If you visit a shared folder like /c/vagrant, you will get the infamous Too many levels of symbolic links error message. Fortunately, we have a solution: add a new user Environment variable MSYS=nonativeinnerlinks. I assume you know how to add a user environment to the windows system. If it doesn't take effect, save your current work and reboot. I didn't reboot my Windows 11 VM, but I did have restarted the Windows terminal application to ensure the new MSYS2 terminal will work with the links!
  2. If you prefer using Git for windows in MSYS2 but don't want to install GitBash because GitBash is also built on MSYS2, Install Git for windows inside MSYS2 will help you! BTW, git_bash_for_windows_is_based_on_msys2_why_not is another very good reference for this topic. I actually got the previous link from the latter article.
  3. Change the home directory to /c/Users/your-name. If you copy from the following, don't forget to change david.wei to your Windows username.
    $ cat /etc/nsswitch.conf
    # Begin /etc/nsswitch.conf
    passwd: db
    group: db
    db_enum: cache builtin
    #db_home: cygwin desc
    db_home: env windows /c/Users/david.wei
    db_shell: cygwin desc
    db_gecos: cygwin desc
    # End /etc/nsswitch.conf
    
  4. If you run cmd.exe in a msys2 terminal, that %PATH% environment will inherit from the PATH environment in the current bash session.
  5. put export MSYS="winsymlinks:lnk" into your .bashrc to get a similar behaviour when you do ln -s Reference