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

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

Closed
osnoser1 opened this issue Oct 30, 2017 · 17 comments

Comments

@osnoser1
Copy link

osnoser1 commented Oct 30, 2017

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

@marionebl
Copy link
Contributor

marionebl commented Oct 30, 2017

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

Could you try with commitlint -e %GIT_PARAMS%?

@osnoser1
Copy link
Author

Hi, yes...

Still gives the same error.

image

I also tried with .git/COMMIT_EDITMSG.

image

I put a console.log in require-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.

@osnoser1
Copy link
Author

osnoser1 commented Oct 30, 2017

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.

@marionebl
Copy link
Contributor

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.

@osnoser1 osnoser1 changed the title Error: ENOENT: no such file or directory, open 'F:\Flat Projects\aquasoft\$GIT_PARAMS' Error: ENOENT: no such file or directory, open 'F:\Flat Projects\aquasoft\$GIT_PARAMS' on Windows Oct 30, 2017
@osnoser1
Copy link
Author

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

@marionebl marionebl added the bug label Oct 30, 2017
@marionebl
Copy link
Contributor

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.

@yangg
Copy link

yangg commented Nov 15, 2017

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

@SangKa
Copy link

SangKa commented Nov 22, 2017

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

System: Window 7 x64
Node: 8.9.0

@marionebl
Copy link
Contributor

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

@SangKa
Copy link

SangKa commented Nov 22, 2017

Unfortunately no, so I got here.

@marionebl
Copy link
Contributor

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;
}

@liubiantao
Copy link
Contributor

liubiantao commented Nov 24, 2017

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

@kumarharsh
Copy link
Contributor

kumarharsh commented Dec 5, 2017

  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...

@kumarharsh
Copy link
Contributor

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.

@marionebl
Copy link
Contributor

@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.

@kumarharsh
Copy link
Contributor

@Marionbel - done!

@marionebl
Copy link
Contributor

Released via 5.2.3

bpedersen pushed a commit to bpedersen/commitlint that referenced this issue Oct 15, 2019
…itlint

chore: execute commitlint on commit-msg and not pre-commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

7 participants
@yangg @kumarharsh @osnoser1 @liubiantao @marionebl @SangKa and others