| name | windows-git-bash-compatibility |
| description | Windows and Git Bash compatibility guidance for Azure Data Factory development and CI/CD |
Windows & Git Bash Compatibility for Azure Data Factory
Overview
Azure Data Factory development frequently occurs on Windows machines using Git Bash (MINGW64) as the primary shell. This introduces path conversion challenges that can break CI/CD pipelines, npm commands, and deployment scripts.
Git Bash Path Conversion Behavior
Automatic Path Conversion
Git Bash (MINGW) automatically converts Unix-style paths to Windows paths:
Conversions:
/foo → C:/Program Files/Git/usr/foo
/foo:/bar → C:\msys64\foo;C:\msys64\bar (path lists)
--dir=/foo → --dir=C:/msys64/foo (arguments)
What Triggers Conversion:
- Leading forward slash (
/) in arguments
- Colon-separated path lists
- Arguments after
- or , with path components
What's Exempt:
- Arguments containing
= (variable assignments)
- Drive specifiers (
C:)
- Arguments with
; (already Windows format)
- Arguments starting with
// (Windows switches)
ADF-Specific Path Issues
npm Build Commands
Problem:
npm run build validate ./adf-resources /subscriptions/abc/resourceGroups/rg/providers/Microsoft.DataFactory/factories/myFactory
Solution:
export MSYS_NO_PATHCONV=1
npm run build validate ./adf-resources /subscriptions/abc/resourceGroups/rg/providers/Microsoft.DataFactory/factories/myFactory
MSYS_NO_PATHCONV=1 npm run build export ./adf-resources /subscriptions/.../myFactory "ARMTemplate"
PowerShell Scripts
Problem:
pwsh ./PrePostDeploymentScript.Ver2.ps1 -armTemplate "./ARMTemplate/ARMTemplateForFactory.json"
Solution:
MSYS_NO_PATHCONV=1 pwsh ./PrePostDeploymentScript.Ver2.ps1 -armTemplate "./ARMTemplate/ARMTemplateForFactory.json"
ARM Template Paths
Problem:
az deployment group create \
--resource-group myRG \
--template-file ARMTemplate/ARMTemplateForFactory.json
Solution:
export MSYS_NO_PATHCONV=1
az deployment group create \
--resource-group myRG \
--template-file ./ARMTemplate/ARMTemplateForFactory.json
Shell Detection Patterns
Bash Shell Detection
#!/usr/bin/env bash
if [ -n "$MSYSTEM" ]; then
echo "Running in Git Bash/MinGW ($MSYSTEM)"
export MSYS_NO_PATHCONV=1
fi
case "$(uname -s)" in
MINGW64*|MINGW32*|MSYS*)
echo "Git Bash detected"
export MSYS_NO_PATHCONV=1
;;
Linux*)
if grep -q Microsoft /proc/version 2>/dev/null; then
echo "WSL detected"
else
echo "Native Linux"
fi
;;
Darwin*)
echo "macOS"
;;
esac
case "$OSTYPE" in
msys*)
echo "Git Bash/MSYS"
export MSYS_NO_PATHCONV=1
;;
linux-gnu*)
echo "Linux"
;;
darwin*)
echo "macOS"
;;
esac
Node.js Shell Detection
function detectShell() {
const env = process.env;
if (env.MSYSTEM) {
return {
type: 'mingw',
subsystem: env.MSYSTEM,
needsPathFix: true
};
}
if (env.WSL_DISTRO_NAME) {
return {
type: 'wsl',
distro: env.WSL_DISTRO_NAME,
needsPathFix: false
};
}
if (env.PSModulePath?.split(';').length >= 3) {
return {
type: 'powershell',
needsPathFix: false
};
}
if (process.platform === 'win32' && env.PROMPT === '$P$G') {
return {
type: 'cmd',
needsPathFix: false
};
}
(env. === ) {
{
: ,
:
};
}
(env.?.()) {
{ : , : };
}
(env.?.()) {
{ : , : };
}
{
: ,
: process.,
:
};
}
shell = ();
.();
(shell.) {
process.. = ;
.();
}
. = { detectShell };
PowerShell Detection
# Detect PowerShell edition and version
function Get-ShellInfo {
$info = @{
Edition = $PSVersionTable.PSEdition
Version = $PSVersionTable.PSVersion
OS = $PSVersionTable.OS
Platform = $PSVersionTable.Platform
}
if ($info.Edition -eq 'Core') {
Write-Host "PowerShell Core (pwsh) - Cross-platform compatible" -ForegroundColor Green
$info.CrossPlatform = $true
} else {
Write-Host "Windows PowerShell - Windows only" -ForegroundColor Yellow
$info.CrossPlatform = $false
}
return $info
}
$shellInfo = Get-ShellInfo
CI/CD Pipeline Patterns
Local Development Scripts
validate-adf.sh (Git Bash compatible):
#!/usr/bin/env bash
set -e
if [ -n "$MSYSTEM" ]; then
export MSYS_NO_PATHCONV=1
echo "🔧 Git Bash detected - path conversion disabled"
fi
ADF_ROOT="./adf-resources"
FACTORY_ID="/subscriptions/${AZURE_SUBSCRIPTION_ID}/resourceGroups/${RESOURCE_GROUP}/providers/Microsoft.DataFactory/factories/${FACTORY_NAME}"
echo "📋 Validating ADF resources..."
npm run build validate "$ADF_ROOT" "$FACTORY_ID"
echo "📦 Generating ARM templates..."
npm run build export "$ADF_ROOT" "$FACTORY_ID" "ARMTemplate"
echo "✅ Validation complete"
deploy-adf.sh (Cross-platform):
#!/usr/bin/env bash
set -e
detect_shell() {
if [ -n "$MSYSTEM" ]; then echo "git-bash"
elif [ -n "$WSL_DISTRO_NAME" ]; then echo "wsl"
elif [[ "$OSTYPE" == "darwin"* ]]; then echo "macos"
else echo "linux"
fi
}
SHELL_TYPE=$(detect_shell)
echo "🖥️ Detected shell: $SHELL_TYPE"
if [ "$SHELL_TYPE" = "git-bash" ]; then
export MSYS_NO_PATHCONV=1
fi
curl -sLo PrePostDeploymentScript.Ver2.ps1 \
https://raw.githubusercontent.com/Azure/Azure-DataFactory/main/SamplesV2/ContinuousIntegrationAndDelivery/PrePostDeploymentScript.Ver2.ps1
echo "⏸️ Stopping triggers..."
MSYS_NO_PATHCONV=1 pwsh ./PrePostDeploymentScript.Ver2.ps1 \
-armTemplate "./ARMTemplate/ARMTemplateForFactory.json" \
-ResourceGroupName "$RESOURCE_GROUP" \
-DataFactoryName "$FACTORY_NAME" \
-predeployment \
-deleteDeployment
az deployment group create \
--resource-group \
--template-file ./ARMTemplate/ARMTemplateForFactory.json \
--parameters ./ARMTemplate/ARMTemplateParametersForFactory.json \
--parameters factoryName=
MSYS_NO_PATHCONV=1 pwsh ./PrePostDeploymentScript.Ver2.ps1 \
-armTemplate \
-ResourceGroupName \
-DataFactoryName \
-predeployment \
-deleteDeployment
package.json with Shell Detection
{
"scripts": {
"prevalidate": "node scripts/detect-shell.js",
"validate": "node node_modules/@microsoft/azure-data-factory-utilities/lib/index validate",
"prebuild": "node scripts/detect-shell.js",
"build": "node node_modules/@microsoft/azure-data-factory-utilities/lib/index export"
},
"dependencies": {
"@microsoft/azure-data-factory-utilities": "^1.0.3"
}
}
scripts/detect-shell.js:
const detectShell = () => {
if (process.env.MSYSTEM) {
console.log('🔧 Git Bash detected - disabling path conversion');
process.env.MSYS_NO_PATHCONV = '1';
return 'git-bash';
}
console.log(`🖥️ Shell: ${process.platform}`);
return process.platform;
};
detectShell();
Common Issues and Solutions
Issue 1: npm build validate fails with "Resource not found"
Symptom:
npm run build validate ./adf-resources /subscriptions/abc/...
Cause: Git Bash converted the factory ID path
Solution:
export MSYS_NO_PATHCONV=1
npm run build validate ./adf-resources /subscriptions/abc/...
Issue 2: PowerShell script paths incorrect
Symptom:
pwsh PrePostDeploymentScript.Ver2.ps1 -armTemplate "./ARM/template.json"
Cause: Git Bash converted the ARM template path
Solution:
MSYS_NO_PATHCONV=1 pwsh PrePostDeploymentScript.Ver2.ps1 -armTemplate "./ARM/template.json"
Issue 3: Azure CLI template-file parameter fails
Symptom:
az deployment group create --template-file ./ARMTemplate/file.json
Cause: Path conversion interfering with Azure CLI
Solution:
export MSYS_NO_PATHCONV=1
az deployment group create --template-file ./ARMTemplate/file.json
Best Practices
1. Set MSYS_NO_PATHCONV in .bashrc
if [ -n "$MSYSTEM" ]; then
export MSYS_NO_PATHCONV=1
fi
2. Create Wrapper Scripts
export MSYS_NO_PATHCONV=1
npm run build "$@"
3. Use Relative Paths with ./
./ARMTemplate/ARMTemplateForFactory.json
ARMTemplate/ARMTemplateForFactory.json
4. Document Shell Requirements
# README.md
## Development Environment
### Windows Users
- Use Git Bash or PowerShell Core (pwsh)
- Git Bash users: Add `export MSYS_NO_PATHCONV=1` to .bashrc
- Alternative: Use WSL2 for native Linux environment
5. Test on Multiple Shells
- Git Bash (MINGW64)
- PowerShell Core 7+
- WSL2 (Ubuntu/Debian)
- cmd.exe (if applicable)
Quick Reference
| Environment Variable | Purpose | Value |
|---|
MSYS_NO_PATHCONV | Disable all path conversion (Git for Windows) | 1 |
MSYS2_ARG_CONV_EXCL | Exclude specific arguments from conversion (MSYS2) | * or patterns |
MSYSTEM | Current MSYS subsystem | MINGW64, MINGW32, MSYS |
WSL_DISTRO_NAME | WSL distribution name | Ubuntu, Debian, etc. |
Resources
Summary
Key Takeaways:
- Git Bash automatically converts Unix-style paths to Windows paths
- Use
export MSYS_NO_PATHCONV=1 to disable conversion
- Detect shell environment using
$MSYSTEM variable
- Test CI/CD scripts on all shells used by your team
- Use PowerShell Core (pwsh) for cross-platform scripts
- Add shell detection to local development scripts