Menu

#41 Problems with symlinks

1.0
closed
Alexx83
None
2014-12-02
2014-04-29
No

I tried this:

$ ln -sf ../../mingw64 foo

and it took a lot of time to be executed... Then I discovered that 'foo' is not a simlink but a copy of '../../mingw64', which is about 1.7 GiB! Worse...

$ du -s ../../mingw64
1,7G    ../../mingw64

while

$ du -s foo
1,8G    foo

I don't understand why 'ln' on MSYS2 behaves in this way.. On GNU/Linux, OSX and also Cygwin (from which MSYS2 is a fork), simlinks are text files.. This behavior seems confusing and dangerous.

I tried also to start msys2_shell.bat uncommenting out

rem set MSYS=winsymlinks:nativestrict

Anyway, trying to create Windows native simlinks fails...

So, the question is: How to create simlinks in MSYS2?

Discussion

  • Alexx83

    Alexx83 - 2014-04-29

    MSYS do not use symlinks because native windows applications don’t understand Cygwin symlinks.
    But you can enable native windows symlinks by editing msys2_shell.bat and uncommenting:

    rem set MSYS=winsymlinks:nativestrict

    In this case you need always run msys2_shell.bat as Administrator.

    Regards,
    Alexey.

     

    Last edit: Alexx83 2014-04-29
    • Angelo Graziosi

      Angelo Graziosi - 2015-03-14

      Sorry if I re-open this..

      OK, Windows applications do not understand symlinks, but nevertheless, the user can find them useful to setup its home/work directories...

      For example, suppose one has its configuration files for bash in $HOME/save-bash.cfg and in $HOME

      .bashrc --> $HOME/save-bash.cfg/my_bashrc
      etc..
      

      Another example. My (MSYS2) program read a cards file foo.cards to simulate a gravitational system. I could have different cards files for different configurations

      foo1.cards
      foo2.cards
      ...
      

      and I can switch them with a symlink,

      foo.cards --> foo1.cards
      

      or

      foo.cards --> foo2.cards
      

      etc..

      Ciao,
      Angelo.

       
      • Alexx83

        Alexx83 - 2015-03-14

        You can use Windows native symlinks. To enable it uncomment line with:
        MSYS=winsymlinks:nativestrict
        in MSYS2 start bat file. And run MSYS2 with admin privileges.

         
        • Angelo Graziosi

          Angelo Graziosi - 2015-03-14

          But that is the solution I don't prefer!!!

          I don't want symlinks to be used with windows applications but for MSYS2 itself! This lack limits the usage of MSYS2...

           
          • Alexx83

            Alexx83 - 2015-03-14

            Sorry but this is impossible to have symlinks because it break to use Win32 applications.

             
            • Angelo Graziosi

              Angelo Graziosi - 2015-03-14

              But as I wrote, I DO NOT want use symlinks with Windows (32,64...) application!!!!!!!! I DO NOT want use them under MINGW64 or MINGW32 but only under MSYS shell!!

              For example this works:

              $ ls -lrt /e/linux-angelo.bkp/programming/nbody.apps/
              totale 1163
              [...]
              -rw-r--r-- 1 angelo None   2316 22 gen 21.57 Makefile
              -rw-r--r-- 1 angelo None  19109 24 feb 12.44 close_encounters.f90
              lrwxrwxrwx 1 angelo None     37  4 mar 00.27 helios_orbits.cards -> helios_orbits.JPL-99942_Apophis.cards
              [...]
              -rw-r--r-- 1 angelo None   4033  6 mar 00.31 helios_orbits.JPL-1_Ceres.cards
              lrwxrwxrwx 1 angelo None     31  6 mar 00.32 close_encounters.cards -> helios_orbits.JPL-1_Ceres.cards
              drwxr-xr-x 1 angelo None      0  7 mar 10.14 docs
              

              being /e/ an usb key NTFS formatted, and

              $ less /e/linux-angelo.bkp/programming/nbody.apps/close_encounters.cards
              

              works just fine (notice that close_encounters.cards is a symlink). Here there are no win32 applications broken..

              If they break the usage of "..Win32 applications", why then MSYS2 has a few of them?

              $ find / -type l -name "*"
              /dev/fd
              /dev/stderr
              /dev/stdin
              /dev/stdout
              /etc/mtab
              /proc/cygdrive
              /proc/mounts
              find: failed to read file names from file system at or below ‘/’: No such file or directory
              
               
              • Alexx83

                Alexx83 - 2015-03-14

                I understand that you want to use symlinks with MSYS apps but how to separate it? For example, ls is MSYS application but we use it to work with MINGW apps too.

                 
                • Angelo Graziosi

                  Angelo Graziosi - 2015-03-14

                  Obviously symlinks work with all non-windows applications like ls... For this reason they can be used also in MINGW if we DO NOT use the for/in/with windows applications... :-)

                  Any way, it seems there is not intention to add them... :-(

                  we can close this discussion again.. but you are very limiting MSYS2...

                  Ciao,
                  Angelo.

                   
  • Alexx83

    Alexx83 - 2014-12-02
    • summary: Problems with simlinks --> Problems with symlinks
     
  • Alexx83

    Alexx83 - 2014-12-02
    • status: open --> closed
    • assigned_to: Alexx83
     
MongoDB Logo MongoDB