← 输入框|github.com|刷新
Skip to content

Cannot install via npm i git+https://... #1864

Open

Description

@samuela

System information

  • node version: v16.4.0
  • npm or yarn version: npm 7.18.1
  • OS/version/architecture: macOS 11.6
  • Applicable nodegit version: latest master, 4561dcb
node -v: v16.4.0
npm -v # (or yarn -v): npm 7.18.1
node -e "console.log(process.platform)": darwin
node -e "console.log(require('os').release())": 20.6.0
node -e "console.log(console.log(process.arch))": x64

You can see the full error logs here. Long story short installing via npm i git+https://github.com/nodegit/nodegit.git#4561dcb7c120474a4553baa27e4c4c2f4be23a2b is broken because for whatever reason the binding.gyp file is not being correctly generated in the build process.

Activity

  1. ianhattendorf commented on Oct 15, 2021

    @ianhattendorf
    Member

    If you have some time to investigate:

    This is probably due to isGitRepo

    isGitRepo = false;
    being set to false, causing generate to not be called
    return generate();
    .

    The build system is pretty old, so it's possible this option just wasn't considered.

  2. samuela commented on Oct 16, 2021

    @samuela
    ContributorAuthor

    Thanks @ianhattendorf! I can poke around a little bit, but I don't have much experience with npm/gyp.

    One thing that I have noticed is that I get a different error altogether when attempting to install globally:

    npm ERR! npm ERR! command sh -c node lifecycleScripts/preinstall && node lifecycleScripts/install
    npm ERR! npm ERR! [nodegit] Running pre-install script
    npm ERR! npm ERR! [nodegit] Running install script
    npm ERR! npm ERR! node:events:371
    npm ERR! npm ERR!       throw er; // Unhandled 'error' event
    npm ERR! npm ERR!       ^
    npm ERR! npm ERR!
    npm ERR! npm ERR! Error: spawn node-pre-gyp ENOENT
    npm ERR! npm ERR!     at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
    npm ERR! npm ERR!     at onErrorNT (node:internal/child_process:480:16)
    npm ERR! npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:83:21)
    

    Full logs here. Looks like some kind of issue running node-pre-gyp...

  3. samuela commented on Oct 17, 2021

    @samuela
    ContributorAuthor

    Looking at this a bit more: Why not just remove the isGitRepo check here:

    if (buildFlags.isGitRepo) {
    var submodules = require(local("submodules"));
    var generate = require(local("../generate"));
    return submodules()
    .then(function() {
    return generate();
    });
    }

    Is there a reason to not run submodules and generate in some cases?

  4. added a commit that references this issue on Oct 17, 2021
  5. samuela commented on Oct 17, 2021

    @samuela
    ContributorAuthor

    Ok, I tried fixing in samuela@b74a591. Now seeing a new error (full log here):

    66 error Error: Cannot find module 'fs-extra'
    66 error Require stack:
    66 error - /Users/skainswo/.npm/_cacache/tmp/git-clone-1d65c3f9/generate/scripts/utils.js
    66 error - /Users/skainswo/.npm/_cacache/tmp/git-clone-1d65c3f9/generate/scripts/generateJson.js
    66 error - /Users/skainswo/.npm/_cacache/tmp/git-clone-1d65c3f9/generate/index.js
    66 error - /Users/skainswo/.npm/_cacache/tmp/git-clone-1d65c3f9/lifecycleScripts/preinstall.js
    66 error     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:924:15)
    66 error     at Function.Module._load (node:internal/modules/cjs/loader:769:27)
    66 error     at Module.require (node:internal/modules/cjs/loader:996:19)
    66 error     at require (node:internal/modules/cjs/helpers:92:18)
    66 error     at Object.<anonymous> (/Users/skainswo/.npm/_cacache/tmp/git-clone-1d65c3f9/generate/scripts/utils.js:1:13)
    66 error     at Module._compile (node:internal/modules/cjs/loader:1092:14)
    66 error     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    66 error     at Module.load (node:internal/modules/cjs/loader:972:32)
    66 error     at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    66 error     at Module.require (node:internal/modules/cjs/loader:996:19) {
    66 error   code: 'MODULE_NOT_FOUND',
    66 error   requireStack: [
    66 error     '/Users/skainswo/.npm/_cacache/tmp/git-clone-1d65c3f9/generate/scripts/utils.js',
    66 error     '/Users/skainswo/.npm/_cacache/tmp/git-clone-1d65c3f9/generate/scripts/generateJson.js',
    66 error     '/Users/skainswo/.npm/_cacache/tmp/git-clone-1d65c3f9/generate/index.js',
    66 error     '/Users/skainswo/.npm/_cacache/tmp/git-clone-1d65c3f9/lifecycleScripts/preinstall.js'
    66 error   ]
    

    which is odd since fs-extra is in package.json as expected. I wonder: does npm distinguish between build-time dependencies and runtime dependencies? Perhaps that would explain this failure.

  6. ianhattendorf commented on Oct 20, 2021

    @ianhattendorf
    Member

    Is there a reason to not run submodules and generate in some cases?

    I believe this is for supporting non-git installs (e.g. tarballs), but that appears to be broken (npm i complains about missing dist/nodegit.js)

    does npm distinguish between build-time dependencies and runtime dependencies? Perhaps that would explain this failure.

    Some scripts run during the preinstall step, where packages aren't yet installed (e.g.

    // We have to manually promisify this because at this is required in lifecycle
    ). It's possible that's the issue here.

  7. marvindanig commented on Oct 23, 2021

    @marvindanig

    In my case, the installation fails with the node:16-stretch image because it does not find python. The full error output is over here.

    This is weird because I specifically install python right before the npm ci step on my dockerfile:

    FROM node:17-stretch
    ENV NODE_ROOT /var/www/red.goose
    WORKDIR $NODE_ROOT
    RUN apt-get update && apt-get install -y imagemagick git
    …
    …
    COPY . .
    RUN apt-get update || : && apt-get install python -y
    RUN npm install -g npm@8.1.1
    RUN npm ci
    …
    …
    
  8. marvindanig commented on Oct 23, 2021

    @marvindanig

    I got a new error the second time which I tried with the newest version of nodegit and node:17-stretch image.

  9. samuela commented on Oct 23, 2021

    @samuela
    ContributorAuthor

    I got a new error the second time which I tried with the newest version of nodegit and node:17-stretch image.

    #10 245.4 npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
    #10 245.4 npm ERR! In file included from /root/.cache/node-gyp/17.0.1/include/node/openssl/././archs/linux-x86_64/asm/include/openssl/ssl.h:21:0,
    #10 245.4 npm ERR!                  from /root/.cache/node-gyp/17.0.1/include/node/openssl/./ssl_asm.h:11,
    #10 245.4 npm ERR!                  from /root/.cache/node-gyp/17.0.1/include/node/openssl/ssl.h:4,
    #10 245.4 npm ERR!                  from ../vendor/libgit2/src/netops.h:17,
    #10 245.4 npm ERR!                  from ../vendor/libgit2/src/fetch.h:14,
    #10 245.4 npm ERR!                  from ../vendor/libgit2/src/fetch.c:8:
    #10 245.4 npm ERR! /root/.cache/node-gyp/17.0.1/include/node/openssl/macros.h:155:4: error: #error "OPENSSL_API_COMPAT expresses an impossible API compatibility level"
    #10 245.4 npm ERR!  #  error "OPENSSL_API_COMPAT expresses an impossible API compatibility level"
    #10 245.4 npm ERR!     ^~~~~
    

    Looks like it's not finding the correct version of OpenSSL headers it's looking for...

  10. marvindanig commented on Oct 25, 2021

    @marvindanig

    OTOH the build succeeded for my web-app without issues with the node:15-stretch image.

  11. Vadorequest commented on Jul 17, 2022

    @Vadorequest

    I also tried to use that "pattern" to try to authenticate using oauth through the url, but it failed, too.

    const repoUrlWithOAuth = `git+https://${process.env.GITHUB_REPO_TOKEN}:x-oauth-basic@github.com/${repoOwner}/${repoName}.git`;
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions