Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
felipebritor opened this issue Jan 13, 2020 · 8 comments
Labels
stale Stale issues

Comments

@felipebritor
Copy link

felipebritor commented Jan 13, 2020

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

@felipebritor
Copy link
Author

I ended up setting another version on travis' before-install script, which worked. But the bug remains for python v3.6.7. Is it an issue for node-gyp itself?

@karousn
Copy link

karousn commented Feb 20, 2020

the version that use it here is for legacy python version, i guest 2.7.* . so i think will be better to update node-gyp version use it here to be able for as to install recent python version.

@sadvazha
Copy link

sadvazha commented Mar 9, 2020

Had the same issue, i have solved it by setting a PYTHON env variable to PYTHON=/path/to/python2.7 for npm install. There was a problem with node-gyp

@redduck3
Copy link

Had the same issue, I found that the node-gyp version in package.json is locked to 3.X. Please upgrade node-gyp to support python3.

@sam-github

This comment has been minimized.

@sam-github
Copy link
Contributor

Looked, this isn't related to the node-gyp version in the package.json, which is a dev dep (not install dep), so the fact that it is v3.x isn't related.

gyp ERR! node-gyp -v v5.0.5

I help maintain node-gyp, I'll see if I can track down if this is an issue with upstream.

@sam-github
Copy link
Contributor

sam-github commented Mar 11, 2020

Looks like this is a node-gyp bug, fixed in nodejs/node-gyp#1925, released in v5.0.6. Use a version of npm that includes that version. I just did an npm install -g npm, got npm 6.14.2:

% npm ls -g node-gyp
/home/sam/.nvm/versions/node/v12.16.1/lib
└─┬ npm@6.14.2
  ├── node-gyp@5.1.0 
  └─┬ npm-lifecycle@3.1.4
    └── node-gyp@5.1.0  deduped

Did an npm install of node-rdkafka, and it fixed the error above.

I believe that should close this issue, its not an issue with this project, and its fixed upstream, and released in npm.

@stale
Copy link

stale bot commented Jun 9, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale Stale issues label Jun 9, 2020
@stale stale bot closed this as completed Jun 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Stale issues
Projects
None yet
Development

No branches or pull requests

5 participants