Skip to content

TypeError: Unicode-objects must be encoded before hashing on node-gyp (Python 3.6.7)Β #743

@felipebritor

Description

@felipebritor

Environment Information

  • OS [Ubuntu 16.04.5 LTS]: [edited]
  • Node Version [10.18.1]:
  • NPM Version [6.13.4]:
  • C++ Toolchain [gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609]: [edited]
  • node-rdkafka version [2.7.4]:

Steps to Reproduce

Try to build the following Dockefile:

FROM python:3.6.7

RUN apt-get update \
    && apt-get install -y build-essential \
    ca-certificates \
    libsasl2-dev \
    libsasl2-modules \
    libssl-dev

RUN curl -sL https://deb.nodesource.com/setup_10.x | bash && apt install -y nodejs

RUN node -v && npm -v

RUN npm install node-rdkafka

node-rdkafka Configuration Settings

Not needed

Additional context

Hello.

last week, I had a surprise when deploying an app, our build is throwing:

> node-rdkafka@2.7.4 install /home/travis/es/src/.../node_modules/node-rdkafka
> node-gyp rebuild

Traceback (most recent call last):
  File "/home/travis/.nvm/versions/node/v10.18.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 50, in <module>
    sys.exit(gyp.script_main())
  File "/home/travis/.nvm/versions/node/v10.18.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 554, in script_main
    return main(sys.argv[1:])
  File "/home/travis/.nvm/versions/node/v10.18.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 547, in main
    return gyp_main(args)
  File "/home/travis/.nvm/versions/node/v10.18.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 532, in gyp_main
    generator.GenerateOutput(flat_list, targets, data, params)
  File "/home/travis/.nvm/versions/node/v10.18.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 2215, in GenerateOutput
    part_of_all=qualified_target in needed_targets)
  File "/home/travis/.nvm/versions/node/v10.18.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 794, in Write
    extra_mac_bundle_resources, part_of_all)
  File "/home/travis/.nvm/versions/node/v10.18.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 978, in WriteActions
    part_of_all=part_of_all, command=name)
  File "/home/travis/.nvm/versions/node/v10.18.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 1724, in WriteDoCmd
    force = True)
  File "/home/travis/.nvm/versions/node/v10.18.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 1779, in WriteMakeRule
    cmddigest = hashlib.sha1(command if command else self.target).hexdigest()
TypeError: Unicode-objects must be encoded before hashing

gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/home/travis/.nvm/versions/node/v10.18.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 4.19.52
gyp ERR! command "/home/travis/.nvm/versions/node/v10.18.0/bin/node" "/home/travis/.nvm/versions/node/v10.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/travis/es/src/github.ibm.com/CIO-SETS/engage-support/foe-fom/services/node_modules/node-rdkafka
gyp ERR! node -v v10.18.0
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-rdkafka@2.7.4 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-rdkafka@2.7.4 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/travis/.npm/_logs/2020-01-09T18_26_58_064Z-debug.log

We use travis and it's python version is 3.6.7, I've tested other version and it worked fine on all of them. Which is strange, as 3.6.* is technically supported by node-gyp.

May someone give some light on what can I do? Forcing the use of another python version is something I'll have to explain to our ops team, so I would rather leave it to a last resort

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleStale issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions