azure-cli: `portalocker` error: FileNotFoundError: [Errno 2] No such file or directory
This is autogenerated. Please review and update as needed.
Describe the bug
Command Name
az account get-access-token
Errors:
The command failed with an unexpected error. Here is the traceback:
[Errno 2] No such file or directory
Traceback (most recent call last):
File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 657, in execute
raise ex
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 691, in _run_job
result = cmd_copy(params)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
return self.handler(*args, **kwargs)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/profile/custom.py", line 75, in get_access_token
tenant=tenant)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/_profile.py", line 381, in get_raw_token
credential = self._create_credential(account, tenant)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/_profile.py", line 588, in _create_credential
return identity.get_user_credential(username_or_sp_id)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/auth/identity.py", line 182, in get_user_credential
return UserCredential(self.client_id, username, **self._msal_app_kwargs)
File "/opt/az/lib/python3.6/site-packages/azure/cli/core/auth/msal_authentication.py", line 41, in __init__
accounts = self.get_accounts(username)
File "/opt/az/lib/python3.6/site-packages/msal/application.py", line 872, in get_accounts
accounts = self._find_msal_accounts(environment=self.authority.instance)
File "/opt/az/lib/python3.6/site-packages/msal/application.py", line 912, in _find_msal_accounts
query={"environment": environment})
File "/opt/az/lib/python3.6/site-packages/msal_extensions/token_cache.py", line 53, in find
with CrossPlatLock(self._lock_location):
File "/opt/az/lib/python3.6/site-packages/msal_extensions/cache_lock.py", line 29, in __enter__
file_handle = self._lock.__enter__()
File "/opt/az/lib/python3.6/site-packages/portalocker/utils.py", line 199, in __enter__
return self.acquire()
File "/opt/az/lib/python3.6/site-packages/portalocker/utils.py", line 161, in acquire
fh = self._prepare_fh(fh)
File "/opt/az/lib/python3.6/site-packages/portalocker/utils.py", line 194, in _prepare_fh
fh.truncate(0)
FileNotFoundError: [Errno 2] No such file or directory
To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
- Put any pre-requisite steps here…
az account get-access-token --resource {} --subscription {} -o={}
Expected Behavior
Environment Summary
Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-debian-bullseye-sid, Ubuntu 20.04.3 LTS
Python 3.6.10
Installer: DEB
azure-cli 2.30.0
Extensions:
azure-devops 0.20.0
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 22 (11 by maintainers)
Moving to a new issue #20707.
There’s no real downside, the only “downside” I see is that it could hide these errors. This scenario should not occur so I do believe it should warrant a warning that your lock might not be valid anymore.
Once the lockfile has disappeared, your lock has disappeared as well and anyone else could lock in the mean time.