diff --git a/src/azure-cli/azure/cli/command_modules/storage/azcopy/util.py b/src/azure-cli/azure/cli/command_modules/storage/azcopy/util.py index afe475d522c..88d5b4cf6a0 100644 --- a/src/azure-cli/azure/cli/command_modules/storage/azcopy/util.py +++ b/src/azure-cli/azure/cli/command_modules/storage/azcopy/util.py @@ -53,10 +53,13 @@ def install_azcopy(self, install_location): else: raise CLIError('Azcopy ({}) does not exist.'.format(self.system)) try: - os.chmod(install_dir, os.stat(install_dir).st_mode | stat.S_IWUSR) _urlretrieve(file_url, install_location) os.chmod(install_location, os.stat(install_location).st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) + except PermissionError as err: + raise CLIError(f'Permission error while attempting to download azcopy to {install_dir}. ' + f'You could install the specified azcopy version {AZCOPY_VERSION} manually or ' + f'grant write permission and retry. ({err})') except IOError as err: raise CLIError('Connection error while attempting to download azcopy {}. You could also install the ' 'specified azcopy version to {} manually. ({})'.format(AZCOPY_VERSION, install_dir, err))