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

Windows OS command fails when referenced through its symbolic link #1177

Closed
1 of 6 tasks
WhisperingChaos opened this issue Jul 5, 2020 · 3 comments
Closed
1 of 6 tasks
Assignees
Labels
Area: Git Area: Scripting and command line awaiting-deployment Code complete; awaiting deployment and/or deployment in progress investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: Windows

Comments

@WhisperingChaos
Copy link

Describe the bug
Attempting to run a Windows .cmd file through a relative symbolic link appearing within a git repository produces unexpected behavior - that may or may not immediately fail. The relative link refers to a file contained in the repo. After installing this git repo into the Windows virtual environment via actions/checkout@v2, the symbolic link is converted into an actual file whose content reflects the link reference, not the content of the file targeted by the link. Therefore, attempting to run the .cmd file executes the link reference instead of dereferencing it to execute the content of the actual file. Furthermore, the command arguments specified on the call aren't forwarded by the link reference.

Area for Triage: git

Question, Bug, or Feature?: Bug

Virtual environments affected

  • macOS 10.15
  • Ubuntu 16.04 LTS
  • Ubuntu 18.04 LTS
  • Ubuntu 20.04 LTS
  • Windows Server 2016 R2
  • Windows Server 2019

Expected behavior
Given a git repository containing a link file that's copied into a Windows virtual environment via actions/checkout@v2, executing the command dir /al via a github actions run: yaml keyword should display the file as a <SYMLINK>.

Actual behavior
The link file is converted into a basic file and executing dir /al within a git repository directory displays the file as just a file.

A description with steps to reproduce the issue. If your have a public example or repo to share,
please provide the link.

  1. The github repo symbolicLink contains a sample of the problem.
  2. Fork the project.
  3. Commit an update.
  4. View the output of its CI workflow.

The output below was generated by this workflow:


0s
Hello World 
Run actualBehavior.cmd

Simple dir command to show files


d:\a\symbolicLink\symbolicLink\test>dir
 Volume in drive D is Temporary Storage
 Volume Serial Number is 1EA7-C472

 Directory of d:\a\symbolicLink\symbolicLink\test

07/05/2020  02:54 AM    <DIR>          .
07/05/2020  02:54 AM    <DIR>          ..
07/05/2020  02:54 AM               431 actualBehavior.cmd
07/05/2020  02:54 AM               482 expectedBehavior.cmd
07/05/2020  02:54 AM                27 helloworld.cmd
               3 File(s)            940 bytes
               2 Dir(s)  13,098,856,448 bytes free

Limit dir to only symbolic links. 
Notice no files reported, although
helloWorld.cmd should appear as one.


d:\a\symbolicLink\symbolicLink\test>dir /al 
 Volume in drive D is Temporary Storage
 Volume Serial Number is 1EA7-C472```

0s
Hello World Arg2-1 Arg2-2
Patch behavior by recreating symbolic link.


d:\a\symbolicLink\symbolicLink\test>del helloWorld.cmd 

d:\a\symbolicLink\symbolicLink\test>mklink  helloWorld.cmd ..\component\helloWorld.cmd 
symbolic link created for helloWorld.cmd <<===>> ..\component\helloWorld.cmd

Command now properly reports file as a symbolic link.


d:\a\symbolicLink\symbolicLink\test>dir /al 
 Volume in drive D is Temporary Storage
 Volume Serial Number is 1EA7-C472

 Directory of d:\a\symbolicLink\symbolicLink\test

07/05/2020  02:54 AM    <SYMLINK>      helloWorld.cmd [..\component\helloWorld.cmd]
               1 File(s)              0 bytes
               0 Dir(s)  13,098,852,352 bytes free

Executing command through link now properly forwards
arguments (Arg2-1 Arg2-2) to actual command and
produces expected behavior.


d:\a\symbolicLink\symbolicLink\test>helloWorld.cmd Arg2-1 Arg2-2 
Hello World Arg2-1 Arg2-2

The symlink behavior above seems related to this Docker for Windows #5778 issue.

@github-actions github-actions bot added Area: Git bug Something isn't working needs triage labels Jul 5, 2020
@Darleev Darleev added investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: Windows Area: Scripting and command line and removed bug Something isn't working needs triage labels Jul 6, 2020
@al-cheb
Copy link
Contributor

al-cheb commented Jul 6, 2020

Hello, @WhisperingChaos
This behavior is by design core.symlinks=false - https://github.com/git-for-windows/git/wiki/Symbolic-Links. The pr with core.symlinks=true by default - #1186.

    steps:
      - name: core.symlinks
        run: |
          git config --global core.symlinks true
      - name: Checkout tools repo
        uses: actions/checkout@v2
        with:
          repository: WhisperingChaos/symbolicLin

image

@WhisperingChaos
Copy link
Author

@al-cheb Many thanks for your speedy reply, link to web page explaining the "by design" reasoning, providing the git config option to circumvent it, and future patch to resolve this issue! Fantastic! You provided a much better experience than many of ones I encountered for products that I purchased!

@al-cheb al-cheb added the awaiting-deployment Code complete; awaiting deployment and/or deployment in progress label Jul 7, 2020
@al-cheb
Copy link
Contributor

al-cheb commented Jul 22, 2020

Hello, @WhisperingChaos
We have deployed a new image with the /o:EnableSymlinks=Enabled parameter is enabled by default - #1186.

jobs:
  build:
    runs-on: windows-latest

    steps:
      - name: Checkout tools repo
        uses: actions/checkout@v2
        with:
          repository: WhisperingChaos/symbolicLink
      - name: dir SYMLINK
        shell: cmd
        run: dir /al test

image

Feel free to open the thread if you have any concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Git Area: Scripting and command line awaiting-deployment Code complete; awaiting deployment and/or deployment in progress investigate Collect additional information, like space on disk, other tool incompatibilities etc. OS: Windows
Projects
None yet
Development

No branches or pull requests

3 participants