Telemetry should include current PYTHONPATH as env to Popen & should fail gracefully
Environment summary
CLI Version 2.0.30
Installed with brew
macOS
Shell: bash
- Telemetry upload happens as a separate process and should pass the current PYTHONPATH.
- It should handle telemetry upload errors more gracefully rather than showing the stacktrace.
1. Popen should include the PYTHONPATH https://github.com/Azure/azure-cli/blob/d23e1a979dfcd647e07c008971be83919110adda/src/azure-cli-core/azure/cli/core/telemetry.py#L231
Since it doesn't I believe the current PYTHONPATH will not be passed to the subprocess and users may see an import error. Which leads to the next point...
2. It should fail gracefully when there is an error
If the telemetry upload fails, it should fail gracefully.
In this case, the issue was that there both Python 3.5 (manual install) and 3.6 (brew install) were installed and the wrong version was used when attempting to upload.
brew link --overwrite python resolved the errors but they should have been handled gracefully.
From user: I am getting the following error/warning after every az command though. Az command does work properly but looks like it is looking for some python files in the folders I just deleted.
[0] ~ $ Traceback (most recent call last):
File "/usr/local/Cellar/azure-cli/2.0.30/libexec/lib/python3.6/site-packages/azure/cli/core/telemetry_upload.py", line 24, in <module>
import azure.cli.core.decorators as decorators
File "/usr/local/Cellar/azure-cli/2.0.30/libexec/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 12, in <module>
from pkg_resources import parse_version
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pkg_resources/__init__.py", line 83, in <module>
import parser
File "/usr/local/Cellar/azure-cli/2.0.30/libexec/lib/python3.6/site-packages/azure/cli/core/parser.py", line 15, in <module>
import azure.cli.core.telemetry as telemetry
File "/usr/local/Cellar/azure-cli/2.0.30/libexec/lib/python3.6/site-packages/azure/cli/core/telemetry.py", line 19, in <module>
import azure.cli.core.decorators as decorators
AttributeError: module 'azure.cli' has no attribute 'core'
cc: @troydai (@williexu)
Is there a workaround for this?
@AXington I have to rename PYTHONPATH to PYTHONPATH_BAK when I want to use azure-cli. Not sure if that is a viable workaround for you, but it's good enough for me.
we have rewritten the whole telemetry uploader, and i believe both issues have been taken care of