ppap
ppap

Reputation: 331

Errno 2] No such file or directory: '$(Agent.ToolsDirectory)/azcopy/azcopy'

I am currently running a python script in the Azure pipeline.

The python script runs subprocess.run([cmd], capture_output=True), and the cmd is the azcopy command in the format of

$(Agent.ToolsDirectory)/azcopy/azcopy copy source target{token}

currently i have the azcopy installed

- task: Bash@3
      displayName: Install azcopy
      inputs:
        targetType: 'inline'
        script: |
          curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
          mkdir $(Agent.ToolsDirectory)/azcopy
          wget -O $(Agent.ToolsDirectory)/azcopy/azcopy_v10.tar.gz https://aka.ms/downloadazcopy-v10-linux
          tar -xf $(Agent.ToolsDirectory)/azcopy/azcopy_v10.tar.gz -C $(Agent.ToolsDirectory)/azcopy --strip-components=1

Then I have another bash script task that runs the python file, but i get the error message of [Errno 2] No such file or directory: '$(Agent.ToolsDirectory)/azcopy/azcopy'

$(Agent.ToolsDirectory)/azcopy/azcopy is recognized when i run it in the inline script, but it doesn't when I run the command through the python script.

Upvotes: 0

Views: 430

Answers (1)

Charles Xu
Charles Xu

Reputation: 31454

According to my experience, the possible reason is that the python script can't know the real path when you use the $(Agent.ToolsDirectory)/azcopy/azcopy. You can try to give the absolute path without any variables or set the variables inside the python script. Of course, you need to ensure that all the tasks run in the same agent.

Upvotes: 1

Related Questions