cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] git dependencies cause weird behaviour when git is not installed

Open Coding-Kiwi opened this issue 1 year ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This issue exists in the latest npm version

  • [X] I am using the latest npm

Current Behavior

running npm install or npm ci when git is not available causes the error

npm warn tarball tarball data for @user/package@git+https://mygitserver/user/package#hash (null) seems to be corrupted. Trying again.

which is a bit misleading in my opinion, I searched way to long for what the issue is because npm did not hint anything in that direction, not even when running with --verbose

Expected Behavior

Throw a clear error telling the user "cannot install git dependency, there is no git executable available"

Steps To Reproduce

  1. I ran inside a drone CI/CD config with the node:lts-alpine docker image which does not have git installed by default
steps:
  - name: npm
    image: node:lts-alpine
    commands:
      - npm ci
  1. install the package (I used npm i -D git+https://myrepo.com/user/repo.git#hash)
  2. run npm ci in pipeline
  3. get error about tarball
  4. add apk add --no-cache git to the pipeline script and it works

Environment

  • npm: 10.8.2
  • Node.js: 20.16.0
  • OS Name: Windows 11 / Linux Alpine
  • npm config:
; "builtin" config from C:\Users\Erik\AppData\Roaming\npm\node_modules\npm\npmrc

prefix = "C:\\Users\\MyUser\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; node version = v20.16.0
; npm local prefix = C:\<project dir>
; npm version = 10.8.2
; cwd = C:\<project dir>
; HOME = C:\Users\MyUser
; Run `npm config ls -l` to show all defaults.

Coding-Kiwi avatar Aug 20 '24 21:08 Coding-Kiwi

Generally you should have git installed if you are using the git dependencies https://docs.npmjs.com/cli/v10/commands/npm-doctor#checking-for-git-executable-in-path

When running npm install, it does say that git can not be spawn

/app # npm install https://github.com/npm/promise-spawn.git
npm error code ENOENT
npm error syscall spawn git
npm error path git
npm error errno -2
npm error enoent An unknown git error occurred
npm error enoent This is related to npm not being able to find a file.
npm error enoent
npm error A complete log of this run can be found in: /root/.npm/_logs/2024-08-26T15_55_15_629Z-debug-0.log

milaninfy avatar Aug 26 '24 16:08 milaninfy

Not able to reproduce the issue and come to the exact error mentioned in the report. Closing as I believe it's not an issue as npm cli as npm requires git to be installed.

milaninfy avatar Sep 11 '24 13:09 milaninfy