un-ts / changesets-gitlab

GitLab CI cli for changesets like its GitHub Action.
https://opencollective.com/unts/projects/changesets-gitlab
MIT License
88 stars 34 forks source link

npx changesets-gitlab - git fetch origin main - unable to access URL using bad/illegal format or missing URL #116

Open jorgecasar opened 1 year ago

jorgecasar commented 1 year ago

Running npx changesets-gitlab I'm having this error, and I couldn't find any info about what could be the reason.

URL https://gitlab.company.com/project/path/name.git is correct and I could access by the browser.

Could you help us with any clue to look for a solution?

$ npx changesets-gitlab
::set-output name=published::false
::set-output name=publishedPackages::[]
setting git user
[command]/usr/bin/git config user.name Bot
[command]/usr/bin/git config user.email bot@company.com
setting GitLab credentials
[command]/usr/bin/git checkout changeset-release/main
error: pathspec 'changeset-release/main' did not match any file(s) known to git
[command]/usr/bin/git checkout -b changeset-release/main
Switched to a new branch 'changeset-release/main'
[command]/usr/bin/git fetch origin main
fatal: unable to access 'https://gitlab.company.com/project/path/name.git/': URL using bad/illegal format or missing URL
Error: The process '/usr/bin/git' failed with exit code 128
    at ExecState._setResult (/builds/project/path/name/node_modules/@actions/exec/lib/toolrunner.js:592:25)
    at ExecState.CheckComplete (/builds/project/path/name/node_modules/@actions/exec/lib/toolrunner.js:575:18)
    at ChildProcess.<anonymous> (/builds/project/path/name/node_modules/@actions/exec/lib/toolrunner.js:469:27)
    at ChildProcess.emit (node:events:514:28)
    at ChildProcess.emit (node:domain:489:12)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)

[command]/usr/bin/git fetch origin main
fatal: unable to access 'https://gitlab.company.com/project/path/name.git/': URL using bad/illegal format or missing URL
Error: The process '/usr/bin/git' failed with exit code 128
JounQin commented 1 year ago

Do you have a custom GITLAB_HOST environment?

jorgecasar commented 1 year ago

Yes, Im using this variables:

variables:
  NPM_TOKEN: ${CI_JOB_TOKEN}
  GITLAB_HOST: https://${CI_SERVER_HOST}
  GITLAB_CI_USER_NAME: BOT
  GITLAB_CI_USER_EMAIL: bot@company.com 

Could be a change in the configuration? The Gitlab version is GitLab Community Edition 15.11.2

JounQin commented 1 year ago

I have no idea with this, maybe you'll need to use patch-package to debug.

Arnoid31 commented 1 year ago

Hello there! I'm encoutering the exact same issue, and can't find a clue even using patch-package to debug. It looks like the trailing / in the URL is totally at fault, but I can't find where it comes from. Here are the logs when adding some git commands (remote origin set-url and remote -v especially):

[command]/usr/bin/git remote set-url origin https://BOT/ :[MASKED]glpat-@gitlab.com/path/to/repository.git
[command]/usr/bin/git remote get-url --all origin
https://BOT/ :[MASKED]glpat-@gitlab.com/path/to/repository.git
[command]/usr/bin/git -v
git version 2.39.2
[command]/usr/bin/git remote -v
origin  https://BOT/ :[MASKED]glpat-@gitlab.com/path/to/repository.git (fetch)
origin  https://BOT/ :[MASKED]glpat-@gitlab.com/path/to/repository.git (push)
[command]/usr/bin/git fetch https://BOT/ :[MASKED]glpat-@gitlab.com/path/to/repository.git my-branch
fatal: unable to access 'https://gitlab.com/path/to/repository.git/': URL using bad/illegal format or missing URL

I'm not a Git specialist enough to understand if that's normal the remote is git: protocol but it becomes https: in fetch/in error log when fetching. On local, with the same Git version, using git: procotol, everything is OK when I fetch.

JounQin commented 1 year ago

@Arnoid31 Does git fetch origin main run successfully when you debug manually? I can only imagine it to be a git issue itself?

Arnoid31 commented 1 year ago

Hello @JounQin, and thank you for your reactivity :) I get exactly the same issue. But in fact I'm surprised we are using here an https: protocol with a .git suffix. 3 weeks ago, the job was working and the fetch was done this way:

[command]/usr/bin/git fetch origin my-branch
From https://gitlab.com/path/to/repository
 * branch            master     -> FETCH_HEAD

and everything was going well. Another strange thing is, this is the only repository that fails this way, all the others using changesets-gitlab the exact same way are just fine.

JounQin commented 1 year ago

@Arnoid31 Are you using different changesets-gitlab versions in different repositories? If so then maybe some recent releases could be related.

Arnoid31 commented 1 year ago

Installed version is 0.10.3. I also tried with v0.10.1 which is run by another (working) repository and no change.

JounQin commented 1 year ago

Are they running on same git version?

Arnoid31 commented 1 year ago

You've got something here: working repo is running Git v2.20.1, not working is v2.39.2. Verified by using v2.20.1 on not working repo, and it works (but as a side effect I had to downgrade Node version from 20 to 16, so might also be related to Node version, but unlikely).

Arnoid31 commented 1 year ago

OK so, from what I see, it looks like finally the error comes from Node version. It works with a node:18.17 builder, but not with a node:20. I can't investigate more for the moment, but maybe I'll get back to you if I have some time to proceed to some more investigations.

zoontek commented 6 months ago

@JounQin I contacted you at the email address on your GitHub profile (admin(at)1stg(dot)me) to fund this issue investigation, but I'm not sure you are using it on day-to-day.

AlexeyTeterin commented 6 months ago

Faced exactly the same issue with node:20 after adding GITLAB_CI_USER_NAME variable. Without variable everything is ok.

JounQin commented 6 months ago

I check the source codes, the error should only occur at

https://github.com/un-ts/changesets-gitlab/blob/54e3175ad30a3819b9e9610d72cfe0ea1e68760b/src/run.ts#L215

It could be a git compatibility issue, I may need some more useful info like git/node versions, and maybe volunteer to help debugging like #145.

Robin-Ln commented 1 month ago

i have the same issue : https://gitlab.com/robin.louarn/monorepo-test/-/jobs/7603795314

$ node -v
v22.6.0
$ git -v
git version 2.39.2
$ pnpm exec changesets-gitlab
::set-output name=published::false
::set-output name=publishedPackages::[]
setting git user
[command]/usr/bin/git config user.name Robin LOUARN
fatal: not in a git directory
Error: The process '/usr/bin/git' failed with exit code 128
    at ExecState._setResult (/builds/robin.louarn/monorepo-test/node_modules/.pnpm/@actions+exec@1.1.1/node_modules/@actions/exec/lib/toolrunner.js:592:25)
    at ExecState.CheckComplete (/builds/robin.louarn/monorepo-test/node_modules/.pnpm/@actions+exec@1.1.1/node_modules/@actions/exec/lib/toolrunner.js:575:18)
    at ChildProcess.<anonymous> (/builds/robin.louarn/monorepo-test/node_modules/.pnpm/@actions+exec@1.1.1/node_modules/@actions/exec/lib/toolrunner.js:469:27)
    at ChildProcess.emit (node:events:520:28)
    at ChildProcess.emit (node:domain:488:12)
    at maybeClose (node:internal/child_process:1105:16)
    at Socket.<anonymous> (node:internal/child_process:[45](https://gitlab.com/robin.louarn/monorepo-test/-/jobs/7603795314#L45)7:11)
    at Socket.emit (node:events:520:28)
    at Socket.emit (node:domain:[48](https://gitlab.com/robin.louarn/monorepo-test/-/jobs/7603795314#L48)8:12)
    at Pipe.<anonymous> (node:net:337:12)
Robin-Ln commented 1 month ago

i have the same issue : https://gitlab.com/robin.louarn/monorepo-test/-/jobs/7603795314

$ node -v
v22.6.0
$ git -v
git version 2.39.2
$ pnpm exec changesets-gitlab
::set-output name=published::false
::set-output name=publishedPackages::[]
setting git user
[command]/usr/bin/git config user.name Robin LOUARN
fatal: not in a git directory
Error: The process '/usr/bin/git' failed with exit code 128
    at ExecState._setResult (/builds/robin.louarn/monorepo-test/node_modules/.pnpm/@actions+exec@1.1.1/node_modules/@actions/exec/lib/toolrunner.js:592:25)
    at ExecState.CheckComplete (/builds/robin.louarn/monorepo-test/node_modules/.pnpm/@actions+exec@1.1.1/node_modules/@actions/exec/lib/toolrunner.js:575:18)
    at ChildProcess.<anonymous> (/builds/robin.louarn/monorepo-test/node_modules/.pnpm/@actions+exec@1.1.1/node_modules/@actions/exec/lib/toolrunner.js:469:27)
    at ChildProcess.emit (node:events:520:28)
    at ChildProcess.emit (node:domain:488:12)
    at maybeClose (node:internal/child_process:1105:16)
    at Socket.<anonymous> (node:internal/child_process:[45](https://gitlab.com/robin.louarn/monorepo-test/-/jobs/7603795314#L45)7:11)
    at Socket.emit (node:events:520:28)
    at Socket.emit (node:domain:[48](https://gitlab.com/robin.louarn/monorepo-test/-/jobs/7603795314#L48)8:12)
    at Pipe.<anonymous> (node:net:337:12)

fix my problem for me