[2021-02-18 22:42:44.666][warn ][command:224770f1-54e3-4ad5-a1ec-f024a8a8406e][tid:35][com.facebook.buck.event.listener.LoggingBuildListener] Buck wasn't able to parse /path/to/buck/file/BUCK:
TypeError: keys must be str, int, float, bool or None, not bytes
Call stack:
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/encoder.py", line 257, in iterencode
return _iterencode(o, 0)
Background
Problem
I see that the dictionary parsed here: https://github.com/facebook/buck/blob/master/python-dsl/buck_parser/buck.py#L2011 includes a byte literal:
Note the
b'PATH'
. I was able to get this printed by adding apprint
as follows: https://github.com/facebook/buck/commit/58d2e1d2c6ae53c14171051dfad881ae1e0e650bThis causes errors like:
I think the
__env
addition comes from https://github.com/facebook/buck/blob/master/python-dsl/buck_parser/buck.py#L1951.Stackoverflow question that might help with why byte literals are problematic: https://stackoverflow.com/questions/6269765/what-does-the-b-character-do-in-front-of-a-string-literal/6269785
Workaround
My workaround is to just use an older version of BUCK and use python2.7.