Commitlint: Error: ENOENT: no such file or directory, open 'F:\Flat Projects\aquasoft\$GIT_PARAMS' on Windows

Created on 30 Oct 2017  路  17Comments  路  Source: conventional-changelog/commitlint

Hello, I am presented with this error when calling the script "commitmsg ":"commitlint -e $GIT_PARAMS".

I do not know if any other configuration is required that I do not know.

I hope you can help me, and thank you very much in advance.

image

bug help wanted

Most helpful comment

Released via 5.2.3

All 17 comments

Reading the paths in the error message I guess you are on a Windows machine, right?

Could you try with commitlint -e %GIT_PARAMS%?

Hi, yes...

Still gives the same error.

image

I also tried with .git/COMMIT_EDITMSG.

image

I put a console.log inrequire-from-string.

image

And this is my commitlint.config.js file:

image

I deleted the file commitlint.config.js and created it manually without echo "module.exports = {extends: ['@commitlint/config-angular']};" > commitlint.config.js and eliminated the error, it worked.

image

However, I do not know what happens with the $GIT_PARAMS variable in windows.

It seems that there are problems using echo in powershell. Add this strange character?

With cmd it generates the file in this way:

echo module.exports = {extends: ['@commitlint/config-angular']}; > commitlint.config.js

And in bash it also works well.

The echo ... command is indeed only tested on bash.

I do not have access to win32 machines very often, so this is hard to test for me.

$GIT_PARAMS is intended to be used with husky. If you do not plan to use husky, just

commitlint -e

should be sufficient.

Yes I am using husky.

I leave this issue open?

For my part I will investigate to see what solution can be given to the use of the variable $GIT_PARAMS on Windows.

Thank you very much @marionebl

Yes, let's leave this open for now. We should check how to pass the path to the git commit edit message from husky to commitlint in a cross-platform compatible manner.

Also failed with this error in git bash on windows
"commitmsg": "commitlint -e" works for me

I still get the same error and "commitmsg": "commitlint -e .git/COMMIT_EDITMSG" works for me.

System: Window 7 x64
Node: 8.9.0

@SangKa: Does commitlint -e %GIT_PARAMS% work for you?

Unfortunately no, so I got here.

Okay, we'll have to implement a rather grungy fix for this, along the lines of

function normalizeEdit(edit) {
  if (typeof edit === 'boolean') {
     return edit;
  }
  if (edit === '$GIT_PARARMS' || edit === '%GIT_PARAMS%') {
    if (!'GIT_PARAMS' in process.env) {
       throw new Error(`Received ${edit} as value for -e | --edit, but GIT_PARAMS is not available globally.`);
    }
    return process.env.GIT_PARAMS;
  }
  return edit;
}

commitlint -e %GIT_PARAMS% works fine on Windows
commitlint -e works for both Windows and Mac

  1. Don't use echo with redirection in Powershell. It's a feature - Powershell by default encodes strings in UTF16-LE. That is why you're getting spaces after each letter, and commitlint doesn't parse the config. Type it out by hand, or use the powershell-specific command:
echo "module.exports = {extends: ['@commitlint/config-angular']};" | Out-File commitlint.config.js -Encoding utf8
  1. Can we use cross-env in some way to pass husky's args to commitlint? Not sure how though...

For what it's worth, %GIT_PARAMS% did work for me... Seems like cross-env might not be very useful in this case. 馃槥 We can access the params using process.env.GIT_PARAMS, for which we'll need to create a js file which spawns commitlint.

@kumarharsh Would you consider contributing a the fix for this as outlined via https://github.com/marionebl/commitlint/issues/103#issuecomment-346318328?

This would spare you from creating the js proxy file you mentioned and benefit other users down the line.

@marionbel - done!

Released via 5.2.3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marionebl picture marionebl  路  4Comments

whizark picture whizark  路  3Comments

ResDiaryLewis picture ResDiaryLewis  路  4Comments

kirillgroshkov picture kirillgroshkov  路  3Comments

MathiasKandelborg picture MathiasKandelborg  路  3Comments