colcon / colcon-core

Command line tool to build sets of software packages
http://colcon.readthedocs.io
Apache License 2.0
103 stars 46 forks source link

Exception in shell extension 'bat' #92

Closed dzxsll closed 6 years ago

dzxsll commented 6 years ago

I try to build a ROS2 package but failed. My os is win10 with python3.7.0. Here is my problem screent shot. default

dirk-thomas commented 6 years ago

Please post any kind of output as text - images are not searchable.

Please also provide exact steps to reproduce the problem. In this case the content of your workspace as well as the locate you have set in your environment.

dzxsll commented 6 years ago

Thanks for your answer. First I created a ROS2 package by using ros2 pkg create then I try to build it but failed. I just Installed Binary packages in C:\dev\ros2 and didn't change anything about the loacte. All location is same as the https://github.com/ros2/ros2/wiki/Windows-Install-Binary. And my package location is C:\dev\ros2\mySource Here is my error output. I'm sorry for that don't know how to correctly ask question. -------------output------------------------- c:\dev\ros2\mySource>colcon build Starting >>> helloworld [1.483s] colcon.colcon_core.shell ERROR Exception in shell extension 'bat': 'utf-8' codec can't decode byte 0xb8 in position 30: invalid start byte Traceback (most recent call last): File "c:\python37\lib\site-packages\colcon_core\shell__init__.py", line 231, in get_command_environment task_name, Path(build_base), dependencies) File "c:\python37\lib\site-packages\colcon_core\shell\bat.py", line 103, in generate_command_environment env = await get_environment_variables(cmd, cwd=str(build_base)) File "c:\python37\lib\site-packages\colcon_core\shell__init__.py", line 273, in get_environment_variables parts = line.decode().split('=', 1) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 in position 30: invalid start byte

[1.484s] colcon.colcon_cmake.task.cmake.build ERROR Could not find a shell extension for the command environment Failed <<< helloworld [ Exited with code 1 ]

Summary: 0 packages finished [0.56s] 1 package failed: helloworld

dirk-thomas commented 6 years ago

The information isn't sufficient to reproduce the problem yet. Please include how exactly you create the package (with all the arguments you used as well as potential other edits of the manifest file). Also please post the content of your environment variables (the output of set).

You could also edit the source file where the exception is happening and try to add some debug output in that case to see what the variable line contains in that case.

dzxsll commented 6 years ago

Only [ c:\dev\ros2\mySource ros2 pkg create helloworld ]

The output of set:

``` adb=D:\workInNingbo\appSource\附件四:灵云麦克风阵列调试软件\adb环境搭建工具包\platform-tools ALLUSERSPROFILE=C:\ProgramData AMENT_PREFIX_PATH=d:\dev\ros2-windows APPDATA=C:\Users\mj-new1\AppData\Roaming APR_ICONV_PATH=C:\Program Files (x86)\Subversion\iconv ChocolateyInstall=C:\ProgramData\chocolatey ChocolateyLastPathUpdate=Tue Jul 31 17:28:35 2018 CLASSPATH=.;C:\Program Files\Java\jdk1.8.0_152\lib\dt.jar;C:\Program Files\Java\jdk1.8.0_152\lib\tools.jar CMAKE_PREFIX_PATH=d:\dev\ros2-windows COLCON_PREFIX_PATH=d:\dev\ros2-windows\ CommandPromptType=Native CommonProgramFiles=C:\Program Files\Common Files CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files CommonProgramW6432=C:\Program Files\Common Files COMPUTERNAME=MEIJIAN-JXY ComSpec=C:\WINDOWS\system32\cmd.exe DevEnvDir=C:\workInNingbo\app\Visual Studio\Common7\IDE\ DriverData=C:\Windows\System32\Drivers\DriverData DXSDK_DIR=C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\ ExtensionSdkDir=C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs Framework40Version=v4.0 FrameworkDir=C:\Windows\Microsoft.NET\Framework64\ FrameworkDIR64=C:\Windows\Microsoft.NET\Framework64 FrameworkVersion=v4.0.30319 FrameworkVersion64=v4.0.30319 FSHARPINSTALLDIR=C:\Program Files (x86)\Microsoft SDKs\F#\10.1\Framework\v4.0\ GRADLE_HOME=D:\workInNingbo\app\Android\Android Studio\gradle\gradle-2.14.1 HOMEDRIVE=C: HOMEPATH=\Users\mj-new1 INCLUDE=C:\workInNingbo\app\Visual Studio\VC\Tools\MSVC\14.14.26428\ATLMFC\include;C:\workInNingbo\app\Visual Studio\VC\Tools\MSVC\14.14.26428\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt JAVA_HOME=C:\Program Files\Java\jdk1.8.0_152 LIB=C:\workInNingbo\app\Visual Studio\VC\Tools\MSVC\14.14.26428\ATLMFC\lib\x64;C:\workInNingbo\app\Visual Studio\VC\Tools\MSVC\14.14.26428\lib\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\lib\um\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\ucrt\x64;C:\Program Files (x86)\Windows Kits\10\lib\10.0.17134.0\um\x64; LIBPATH=C:\workInNingbo\app\Visual Studio\VC\Tools\MSVC\14.14.26428\ATLMFC\lib\x64;C:\workInNingbo\app\Visual Studio\VC\Tools\MSVC\14.14.26428\lib\x64;C:\workInNingbo\app\Visual Studio\VC\Tools\MSVC\14.14.26428\lib\x86\store\references;C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17134.0;C:\Program Files (x86)\Windows Kits\10\References\10.0.17134.0;C:\Windows\Microsoft.NET\Framework64\v4.0.30319; LOCALAPPDATA=C:\Users\mj-new1\AppData\Local LOGONSERVER=\\MEIJIAN-JXY NETFXSDKDir=C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\ NUMBER_OF_PROCESSORS=8 OneDrive=C:\Users\mj-new1\OneDrive OpenCV_DIR=C:\opencv OPENSSL_CONF=C:\OpenSSL-Win64\bin\openssl.cfg OS=Windows_NT Path=d:\dev\ros2-windows\Scripts;d:\dev\ros2-windows\bin;d:\dev\ros2-windows\opt\rviz_yaml_cpp_vendor\bin;d:\dev\ros2-windows\opt\rviz_ogre_vendor\bin;d:\dev\ros2-windows\opt\rviz_assimp_vendor\bin;d:\dev\ros2-windows\opt\libcurl_vendor\bin;C:\workInNingbo\app\Visual Studio\VC\Tools\MSVC\14.14.26428\bin\HostX64\x64;C:\workInNingbo\app\Visual Studio\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.8;C:\workInNingbo\app\Visual Studio\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\workInNingbo\app\Visual Studio\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\workInNingbo\app\Visual Studio\MSBuild\15.0\bin\Roslyn;C:\workInNingbo\app\Visual Studio\Team Tools\Performance Tools\x64;C:\workInNingbo\app\Visual Studio\Team Tools\Performance Tools;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\\x64;C:\Program Files (x86)\Microsoft Visual Studio\Shared\Common\VSPerfCollectionTools\;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\;C:\Program Files (x86)\Microsoft SDKs\F#\10.1\Framework\v4.0\;C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\workInNingbo\app\Visual Studio\\MSBuild\15.0\bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\workInNingbo\app\Visual Studio\Common7\IDE\;C:\workInNingbo\app\Visual Studio\Common7\Tools\;C:\Python37\Scripts\;C:\Python37\;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\dotnet\;C:\Users\mj-new1\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;D:\workInNingbo\app\Git\cmd;D:\workInNingbo\appSource\附件四:灵云麦克风阵列调试软件\adb环境搭建工具包\platform-tools;C:\Program Files\Java\jdk1.8.0_152\bin;C:\Program Files\Java\jdk1.8.0_152\jer\bin;D:\workInNingbo\app\Android\Android Studio\gradle\gradle-2.14.1\bin;D:\workInNingbo\app\CMake\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\OpenSSL-Win64\bin\;C:\opencv\x64\vc15\bin;C:\ProgramData\chocolatey\lib\tinyxml2\lib;C:\Python37;C:\Program Files\CMake\bin;C:\Program Files\Cppcheck;C:\Program Files (x86)\Subversion\bin;C:\Program Files\Mercurial;C:\Users\mj-new1\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Mercurial\ PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.PYW PKG_CONFIG_PATH=d:\dev\ros2-windows\lib\pkgconfig Platform=x64 PROCESSOR_ARCHITECTURE=AMD64 PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 94 Stepping 3, GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=5e03 ProgramData=C:\ProgramData ProgramFiles=C:\Program Files ProgramFiles(x86)=C:\Program Files (x86) ProgramW6432=C:\Program Files PROMPT=$P$G PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules PUBLIC=C:\Users\Public PYTHONPATH=d:\dev\ros2-windows\Lib\site-packages ROS_DISTRO=bouncy ROS_PYTHON_VERSION=3 ROS_VERSION=2 SystemDrive=C: SystemRoot=C:\WINDOWS TEMP=C:\Users\mj-new1\AppData\Local\Temp TMP=C:\Users\mj-new1\AppData\Local\Temp UCRTVersion=10.0.17134.0 UniversalCRTSdkDir=C:\Program Files (x86)\Windows Kits\10\ USERDOMAIN=MEIJIAN-JXY USERDOMAIN_ROAMINGPROFILE=MEIJIAN-JXY USERNAME=mj-new1 USERPROFILE=C:\Users\mj-new1 VCIDEInstallDir=C:\workInNingbo\app\Visual Studio\Common7\IDE\VC\ VCINSTALLDIR=C:\workInNingbo\app\Visual Studio\VC\ VCToolsInstallDir=C:\workInNingbo\app\Visual Studio\VC\Tools\MSVC\14.14.26428\ VCToolsRedistDir=C:\workInNingbo\app\Visual Studio\VC\Redist\MSVC\14.14.26405\ VCToolsVersion=14.14.26428 VisualStudioVersion=15.0 VS110COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\ VS120COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\ VS140COMNTOOLS=D:\workInNingbo\app\Visual Studio 2015\Common7\Tools\ VS150COMNTOOLS=C:\workInNingbo\app\Visual Studio\Common7\Tools\ VSCMD_ARG_app_plat=Desktop VSCMD_ARG_HOST_ARCH=x64 VSCMD_ARG_TGT_ARCH=x64 VSCMD_VER=15.7.5 VSINSTALLDIR=C:\workInNingbo\app\Visual Studio\ windir=C:\WINDOWS WindowsLibPath=C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.17134.0;C:\Program Files (x86)\Windows Kits\10\References\10.0.17134.0 WindowsSdkBinPath=C:\Program Files (x86)\Windows Kits\10\bin\ WindowsSdkDir=C:\Program Files (x86)\Windows Kits\10\ WindowsSDKLibVersion=10.0.17134.0\ WindowsSdkVerBinPath=C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\ WindowsSDKVersion=10.0.17134.0\ WindowsSDK_ExecutablePath_x64=C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\ WindowsSDK_ExecutablePath_x86=C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\ WIX=C:\Program Files (x86)\WiX Toolset v3.11\ __DOTNET_ADD_64BIT=1 __DOTNET_PREFERRED_BITNESS=64 __VSCMD_PREINIT_PATH=C:\Python37\Scripts\;C:\Python37\;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\dotnet\;C:\Users\mj-new1\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;D:\workInNingbo\app\Git\cmd;D:\workInNingbo\appSource\附件四:灵云麦克风阵列调试软件\adb环境搭建工具包\platform-tools;C:\Program Files\Java\jdk1.8.0_152\bin;C:\Program Files\Java\jdk1.8.0_152\jer\bin;D:\workInNingbo\app\Android\Android Studio\gradle\gradle-2.14.1\bin;D:\workInNingbo\app\CMake\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\OpenSSL-Win64\bin\;C:\opencv\x64\vc15\bin;C:\ProgramData\chocolatey\lib\tinyxml2\lib;C:\Python37;C:\Program Files\CMake\bin;C:\Program Files\Cppcheck;C:\Program Files (x86)\Subversion\bin;C:\Program Files\Mercurial;C:\Users\mj-new1\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Mercurial\ ```

And thank you for your patience.

I will try to debug to see if I can find out the reason. PS: I tried to build a same package in my workmate computer and it worked.now I am so upset.

dzxsll commented 6 years ago

I find the problem in the Python37\Lib\site-packages\colcon_core\shell__init__.py and in the function get_environment_variables .

the code is here:

async def get_environment_variables(cmd, *, cwd=None, shell=True): """ Get the environment variables from the output of the command. :param args: the sequence of program arguments :param cwd: the working directory for the subprocess :param shell: whether to use the shell as the program to execute :rtype: dict """
output = await check_output(cmd, cwd=cwd, shell=shell)
env = {} for line in output.splitlines(): print(line.rstrip()) line = line.rstrip()
if not line: continue parts = line.decode().split('=', 1) if len(parts) != 2:

skip lines which don't contain an equal sign

        continue
    env[parts[0]] = parts[1]
assert len(env) > 0, "The environment shouldn't be empty"
return env

I print out the variable "line" and result is that " b'adb=D:\workInNingbo\appSource\\xb8\xbd\xbc\xfe\xcb\xc4\xa3\xba\xc1\xe9\xd4\xc6\xc2\xf3\xbf\xcb\xb7\xe7\xd5\xf3\xc1\xd0\xb5\xf7\xca\xd4\xc8\xed\xbc\xfe\adb\xbb\xb7\xbe\xb3\xb4\xee\xbd\xa8\xb9\xa4\xbe\xdf\xb0\xfc\platform-tools' "

So what does that mean? what I can do ?

calvertdw commented 6 years ago

My guess here would be that UTF-8 does not contain the Chinese character set. I'm not sure where the UTF-8 requirement is held.

calvertdw commented 6 years ago

The python decode method will require the correct encoding to be passed in, as it defaults to utf-8.

File "c:\python37\lib\site-packages\colcon_core\shell_init_.py", line 273, in get_environment_variables
parts = line.decode().split('=', 1)

https://docs.python.org/3.7/library/codecs.html

dirk-thomas commented 6 years ago

Can you please share information about your locale settings (by posting the output of the following commands):

python -c "import locale; print(locale.getlocale())"
python -c "import locale; print(locale.getdefaultlocale())"
python -c "import locale; print(locale.getpreferredencoding())"
dzxsll commented 6 years ago

Thank you for both answer. My win10 is the Chinese version but all location are named without any Chinese character. Should I change the os character set?

the output : d:\dev\packages\1.helloworld>python -c "import locale; print(locale.getlocale())" (None, None)

d:\dev\packages\1.helloworld>python -c "import locale; print(locale.getdefaultlocale())" ('zh_CN', 'cp936')

d:\dev\packages\1.helloworld>python -c "import locale; print(locale.getpreferredencoding())" cp936

Let me try to change the character set and see what will happen.

dzxsll commented 6 years ago

oh, I get it. I see where have the Chinese characters. when the colcon build a package, every environment variable will be sent to check. However anyone chinese character can cause the question. Now I deleted the variable and it can work!!! I so appreciate your answer and patience.

dirk-thomas commented 6 years ago

It would be easy to patch the code to ignore environment variable which do contain characters which can't be decoded. Though I noticed that e.g. PATH contained chinese characters in your case and just skipping PATH wouldn't work. So it would be good to figure out how to make it work...

Can you please try the following command and post the output - it is trying to decode one of the problematic lines using your default encoding:

python -c "line=b'adb=D:\workInNingbo\appSource\\xb8\xbd\xbc\xfe\xcb\xc4\xa3\xba\xc1\xe9\xd4\xc6\xc2\xf3\xbf\xcb\xb7\xe7\xd5\xf3\xc1\xd0\xb5\xf7\xca\xd4\xc8\xed\xbc\xfe\adb\xbb\xb7\xbe\xb3\xb4\xee\xbd\xa8\xb9\xa4\xbe\xdf\xb0\xfc\platform-tools';line = line.decode('cp963'); print(line)"
dzxsll commented 6 years ago

The command doesn't work , I am sorry. the cmd said LookupError:unkonwn encoding: cp963. But I can show you the string which contains chinese characters. Here: adb=D:\workInNingbo\appSource\附件四:灵云麦克风阵列调试软件\adb环境搭建工具包\platform-tools

it just mean attachment four: lingyun Microphone Array debug tool \ adb environment setup package

dirk-thomas commented 6 years ago

The locale had a flipped character. Please try this one again:

python -c "line=b'adb=D:\workInNingbo\appSource\\xb8\xbd\xbc\xfe\xcb\xc4\xa3\xba\xc1\xe9\xd4\xc6\xc2\xf3\xbf\xcb\xb7\xe7\xd5\xf3\xc1\xd0\xb5\xf7\xca\xd4\xc8\xed\xbc\xfe\adb\xbb\xb7\xbe\xb3\xb4\xee\xbd\xa8\xb9\xa4\xbe\xdf\xb0\xfc\platform-tools';line = line.decode('cp936'); print(line)"
dzxsll commented 6 years ago

The result: D:\dev\packages\helloworld>python -c "line=b'adb=D:\workInNingbo\appSource\xb8\xbd\xbc\xfe\xcb\xc4\xa3\xba\xc1\xe9\xd4\xc6\xc2\xf3\xbf\xcb\xb7\xe7\xd5\xf3\xc1\xd0\xb5\xf7\xca\xd4\xc8\xed\xbc\xfe\adb\xbb\xb7\xbe\xb3\xb4\xee\xbd\xa8\xb9\xa4\xbe\xdf\xb0\xfc\platform-tools';line = line.decode('cp936'); print(line)" Traceback (most recent call last): File "", line 1, in UnicodeDecodeError: 'gbk' codec can't decode byte 0xfe in position 34: illegal multibyte sequence

Sometime the chinese characters are really big trouble.

dirk-thomas commented 6 years ago

That is weird that is can't even decode the string with the default locale of your system. If you can figure out what locale is required to decode the string correctly on your system I would be happy to work on a patch.

dzxsll commented 6 years ago

HI,I made it. The reason why it can't decode the string is that There are three lost "\" in the string

appSource\xb8 should be appSource\\\xb8

xfe\adb should be xfe\\adb

And It can work. I don't konw how it transforms between UTF-8 and cp936. But fact is that something lost.

Here are command and result: D:\dev\packages\helloworld>python -c "line=b'adb=D:\workInNingbo\appSource\\\xb8\xbd\xbc\xfe\xcb\xc4\xa3\xba\xc1\xe9\xd4\xc6\xc2\xf3\xbf\xcb\xb7\xe7\xd5\xf3\xc1\xd0\xb5\xf7\xca\xd4\xc8\xed\xbc\xfe\\adb\xbb\xb7\xbe\xb3\xb4\xee\xbd\xa8\xb9\xa4\xbe\xdf\xb0\xfc\platform-tools';line = line.decode('cp936'); print(line)"

adb=D:\workInNingboppSource\附件四:灵云麦克风阵列调试软件\adb环境搭建工具包\platform-tools

dirk-thomas commented 6 years ago

And if you run the same command with utf-8 (or no argument) instead of cp936? Does it raise a UnicodeDecodeError again?

dzxsll commented 6 years ago

Result one: D:\dev\packages\helloworld>python -c "line=b'adb=D:\workInNingbo\appSource\\xb8\xbd\xbc\xfe\xcb\xc4\xa3\xba\xc1\xe9\xd4\xc6\xc2\xf3\xbf\xcb\xb7\xe7\xd5\xf3\xc1\xd0\xb5\xf7\xca\xd4\xc8\xed\xbc\xfe\adb\xbb\xb7\xbe\xb3\xb4\xee\xbd\xa8\xb9\xa4\xbe\xdf\xb0\xfc\platform-tools';line = line.decode('utf-8'); print(line)" Traceback (most recent call last): File "", line 1, in UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb8 in position 29: invalid start byte

Result tow: D:\dev\packages\helloworld>python -c "line=b'adb=D:\workInNingbo\appSource\附件四:灵云麦克风阵列调试软件\adb环境搭建工 具包\platform-tools';line = line.decode('utf-8'); print(line)" File "string", line 1 SyntaxError: bytes can only contain ASCII literal characters.

I think the Result tow is what you want.

dirk-thomas commented 6 years ago

I think the Result tow is what you want.

No, result 2 is not valid since you can't use non-ASCII characters in bytes.

Anyway I think using locale.getpreferredencoding() for decoding the lines (rather than using the default utf-8) seems to solve the problem for you. I created #95 which should fix the problem.

It would be great if you could try the proposed patch locally and confirm if it works afterwards (using the environment for which it fails currently). To install the modified version of colcon-core you can run:

pip install -U git+https://github.com/colcon/colcon-core.git@use_encoding_for_env