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

git-cz fails with "Cannot convert undefined or null to object" #227

Closed
rileyjshaw opened this issue Nov 25, 2020 · 12 comments · Fixed by #267
Closed

git-cz fails with "Cannot convert undefined or null to object" #227

rileyjshaw opened this issue Nov 25, 2020 · 12 comments · Fixed by #267
Labels

Comments

@rileyjshaw
Copy link

I just migrated my personal site (repo, in case config is relevant) to a new machine. git-cz is failing with the following trace:

> rileyjshaw.com@1.0.0 commit /Users/rjs/code/rileyjshaw
> git-cz --disable-emoji

cz-cli@4.2.2, git-cz@4.7.4

(node:11594) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at runInteractiveQuestions (/Users/rjs/code/rileyjshaw/node_modules/git-cz/dist/cz.js:576:10)
    at run (/Users/rjs/code/rileyjshaw/node_modules/git-cz/dist/cz.js:157:11)
    at exports.prompter (/Users/rjs/code/rileyjshaw/node_modules/git-cz/dist/cz.js:164:3)
    at /Users/rjs/code/rileyjshaw/node_modules/commitizen/dist/commitizen/commit.js:598:9
    at /Users/rjs/code/rileyjshaw/node_modules/fs-extra/lib/mkdirs/mkdirs.js:56:16
    at callback (/Users/rjs/code/rileyjshaw/node_modules/graceful-fs/polyfills.js:295:20)
    at FSReqCallback.oncomplete (fs.js:184:5)

I followed this back to runInteractiveQuestions.js. cliAnswers is undefined, so,

const runInteractiveQuestions = async (state, cliAnswers) => {
  Object.keys(cliAnswers).forEach((key) => {

fails. I'm confused because in cz.js,

    await runInteractiveQuestions(state);

runInteractiveQuestions is called with a single argument. But this was passing before, so I'm sure I've made a simple configuration mistake.

I'm stuck debugging this, so any advice is appreciated.

For what it's worth, I tested this on:

  • npm v7.0.8, Node v15.2.1
  • npm v6.14.8, Node v14.15.1
@rodrigograca31
Copy link
Collaborator

can you please try 4.7.1 and tell us if the problem still exists?

npm i git-cz@4.7.1 -g

I merged a PR in 4.7.2 related to --dissable-emoji ....
https://github.com/streamich/git-cz/releases/tag/v4.7.2

@rileyjshaw
Copy link
Author

rileyjshaw commented Dec 1, 2020

I'm still seeing Cannot convert undefined or null to object on 4.7.1. I'm using this with commitizen by the way, so I skipped the -g in your snippet above. Let me know if I'm missing something, or if there's more I can help with on my end :)

@rileyjshaw
Copy link
Author

I just updated to the latest version and I'm not seeing this error anymore – thank you!

@rileyjshaw
Copy link
Author

I'm seeing this again on a fresh install of 4.7.6.

@rileyjshaw rileyjshaw reopened this Jan 21, 2021
@rileyjshaw
Copy link
Author

For testing, I dropped back to a previous version:

npm i git-cz@4.7.1

and it's working as expected. Looks like there may be a regression.

rileyjshaw added a commit to rileyjshaw/rileyjshaw.github.io that referenced this issue Mar 7, 2021
rileyjshaw added a commit to rileyjshaw/rileyjshaw.github.io that referenced this issue Mar 7, 2021
@petermetz
Copy link

Hit the same issue, multiple times with it disappearing and then resurfacing with different versions as well, made no sense.

So, I started checking other things and found out that I also had commitizen installed which for some reason declares it's own, conflicting binary also called git-cz that (I'm guessing) may end up being hooked up to ./node_modules/.bin/git-cz randomly depending on the cookie crumbles when you run npm install (which I assume does as much as possible parallelized)

Uninstalled commitizen and right now it's working. Just a theory, but maybe it's right.
@rileyjshaw have you also been using commitizen at the same time as git-cz?

@nonameolsson
Copy link

nonameolsson commented May 2, 2021

I have been following this discussion for a while and just wanted to fill in.

I've had commitizen installed, and sometimes I've had this error. Maybe you are on to something @petermetz 👍

Hit the same issue, multiple times with it disappearing and then resurfacing with different versions as well, made no sense.

So, I started checking other things and found out that I also had commitizen installed which for some reason declares it's own, conflicting binary also called git-cz that (I'm guessing) may end up being hooked up to ./node_modules/.bin/git-cz randomly depending on the cookie crumbles when you run npm install (which I assume does as much as possible parallelized)

Uninstalled commitizen and right now it's working. Just a theory, but maybe it's right.

@rileyjshaw have you also been using commitizen at the same time as git-cz?

@rileyjshaw
Copy link
Author

@rileyjshaw have you also been using commitizen at the same time as git-cz?

Yes, I’ve also been using commitizen.

@petermetz
Copy link

Alright, then we are probably onto something. I'll head over to the commitizen repo and file a bug. It would be a breaking change for them to remove their alias (even if they agree to it) but at least we should discuss it. All this assuming of course that the root cause really is commitizen, but the circumstantial evidence definitely points in that direction.

@zhang-xianlei
Copy link

I just migrated my personal site (repo, in case config is relevant) to a new machine. git-cz is failing with the following trace:

> rileyjshaw.com@1.0.0 commit /Users/rjs/code/rileyjshaw
> git-cz --disable-emoji

cz-cli@4.2.2, git-cz@4.7.4

(node:11594) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at runInteractiveQuestions (/Users/rjs/code/rileyjshaw/node_modules/git-cz/dist/cz.js:576:10)
    at run (/Users/rjs/code/rileyjshaw/node_modules/git-cz/dist/cz.js:157:11)
    at exports.prompter (/Users/rjs/code/rileyjshaw/node_modules/git-cz/dist/cz.js:164:3)
    at /Users/rjs/code/rileyjshaw/node_modules/commitizen/dist/commitizen/commit.js:598:9
    at /Users/rjs/code/rileyjshaw/node_modules/fs-extra/lib/mkdirs/mkdirs.js:56:16
    at callback (/Users/rjs/code/rileyjshaw/node_modules/graceful-fs/polyfills.js:295:20)
    at FSReqCallback.oncomplete (fs.js:184:5)

I followed this back to runInteractiveQuestions.js. cliAnswers is undefined, so,

const runInteractiveQuestions = async (state, cliAnswers) => {
  Object.keys(cliAnswers).forEach((key) => {

fails. I'm confused because in cz.js,

    await runInteractiveQuestions(state);

runInteractiveQuestions is called with a single argument. But this was passing before, so I'm sure I've made a simple configuration mistake.

I'm stuck debugging this, so any advice is appreciated.

For what it's worth, I tested this on:

  • npm v7.0.8, Node v15.2.1
  • npm v6.14.8, Node v14.15.1

I just updated to the latest version and I'm not seeing this error anymore – thank you!

I also face the same problem as yours. Can you tell me you device OS, windows or macos?
My device is win10, And I set the git-cz version to 4.7.1, but the problem is still there.
Thank you!

streamich pushed a commit that referenced this issue Oct 13, 2021
# [4.8.0](v4.7.6...v4.8.0) (2021-10-13)

### Bug Fixes

* 🐛 give default value to prevent convert error ([c16df5d](c16df5d)), closes [#227](#227)
* better support for workspaces ([215b6c3](215b6c3))

### Features

* 🎸 add "format" field to customize subject in commit msg [#81](#81) ([5e998cf](5e998cf))
* 🎸️ format (custom message) ([6f0c828](6f0c828))
@streamich
Copy link
Owner

🎉 This issue has been resolved in version 4.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@zhang-xianlei
Copy link

Thank you!

rileyjshaw added a commit to rileyjshaw/rileyjshaw.github.io that referenced this issue Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants