Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

npm install fails with missing git hook #1444

Closed
dryajov opened this issue Jul 16, 2018 · 10 comments
Closed

npm install fails with missing git hook #1444

dryajov opened this issue Jul 16, 2018 · 10 comments

Comments

@dryajov
Copy link
Member

dryajov commented Jul 16, 2018

  • Version: latest master (0.30.0)
  • Platform: mac osx high sierra (10.13.5 (17F77))
  • Subsystem: js-ipfs (running node v9.11.1 and npm v6.1.0)

Type: Bug

Severity: High

Description: npm install fails with:

> git-validate@2.2.2 install /Users/dryajov/personal/projects/ipfs/ipfs/js-ipfs/node_modules/git-validate
> node bin/install
fs.js:660
  return binding.open(pathModule.toNamespacedPath(path),
                 ^
Error: ENOENT: no such file or directory, open '/Users/dryajov/personal/projects/ipfs/ipfs/js-ipfs/.git/hooks/pre-push'
    at Object.fs.openSync (fs.js:660:18)
    at Object.fs.writeFileSync (fs.js:1319:33)
    at Object.exports.installHooks (/Users/dryajov/personal/projects/ipfs/ipfs/js-ipfs/node_modules/git-validate/lib/utils.js:248:12)
    at Object.<anonymous> (/Users/dryajov/personal/projects/ipfs/ipfs/js-ipfs/node_modules/git-validate/bin/install.js:3:7)
    at Module._compile (internal/modules/cjs/loader.js:654:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:695:10)

Steps to reproduce the error:

  • clone this repo and do an npm i
@dryajov
Copy link
Member Author

dryajov commented Jul 16, 2018

This is due to a broken symlink in the .git/hooks directory. Removing the symlink (.git/hooks/pre-push) and rerunning npm i fixes this issue.

@jacobheun
Copy link
Contributor

Looking into this it looks like Aegir < 15 was using the pre-push modules. In Aegir >= 15 the move was made to use git-validate. This issue is that pre-push was creating symlinks to itself in the node_modules directory. When git-validate does an install it does some inspection on the hook, which now has a dead symlink.

Aside from doing a pre-install removal in aegir, which is probably unnecessary for this, the removal is the quickest fix.

@vmx
Copy link
Member

vmx commented Jul 17, 2018

Is this OSX specific? It never happened to me (I'm on Linux).

@jacobheun
Copy link
Contributor

Possibly, I am also on OSX. I can try replicating later today on Linux.

@vmx
Copy link
Member

vmx commented Jul 17, 2018

Although I prefer having pre-push hooks, I also don't want to see everyone's project broken. I wonder if there's a workaround/better solution.

@jacobheun
Copy link
Contributor

Okay, I was able to replicate this consistently with docker, however, it only occurs if the node_modules are removed in between npm installs. Anyone who didn't manually remove the node_modules prior to the install probably won't have the issue.

I don't think we need to do any code changes for this. In theory we could create some backward compatibility support via preinstall scripts, but since we're still in beta releases I think it's okay to just add a quick note about upgrading to 0.30 to the readme in case anyone hits the issue.

Here are the Dockerfile contents for reference:

Works

FROM node:10

RUN git clone https://github.com/ipfs/js-ipfs.git
RUN cd ./js-ipfs && ls -la && \
  git checkout v0.29.3 && \
  npm i && ls -la .git/hooks && \
  git checkout master && \
  npm i && ls -la .git/hooks

Fails

FROM node:10

RUN git clone https://github.com/ipfs/js-ipfs.git
RUN cd ./js-ipfs && ls -la && \
  git checkout v0.29.3 && \
  npm i && ls -la .git/hooks && \
  rm .git/hooks/pre-push 2> /dev/null && \
  git checkout master && \
  npm i && ls -la .git/hooks

@0x-r4bbit
Copy link
Contributor

Anyone who didn't manually remove the node_modules prior to the install probably won't have the issue.

This makes sense. Unfortunately, chances are very high that users do this. Will send a PR to have note int he README.

0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this issue Jul 18, 2018
Closes ipfs#1444

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this issue Jul 18, 2018
Closes ipfs#1444

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this issue Jul 18, 2018
Closes ipfs#1444

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
0x-r4bbit added a commit to 0x-r4bbit/interface-ipfs-core that referenced this issue Jul 18, 2018
Turns out that, similar to ipfs/js-ipfs#1444, we've introduce a
regression in ipfs-inactive@87a8f96 in which we upgrade
Aegir to 15.0.0. This causes problems during installation of npm dependencies for any existing clone
of the repository as the pre-push hook becomes a dead symlink.

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
@0x-r4bbit
Copy link
Contributor

Turns out this is happening over at interface-core-ipfs as well. Created another PR over there accordingly: ipfs-inactive/interface-js-ipfs-core#329

@vmx
Copy link
Member

vmx commented Jul 18, 2018

The proper solution is to make git-validate not fail. Let's hope this PR gets accepted: nlf/git-validate#67

0x-r4bbit added a commit to 0x-r4bbit/js-ipfs that referenced this issue Jul 18, 2018
Closes ipfs#1444

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
@0x-r4bbit
Copy link
Contributor

Nice @vmx !

alanshaw pushed a commit that referenced this issue Jul 18, 2018
Closes #1444

License: MIT
Signed-off-by: Pascal Precht <pascal.precht@gmail.com>
vmx added a commit to ipfs/aegir that referenced this issue Jul 19, 2018
With the change from `pre-push` to `git-validate` there was an issue
when you were removing `node_modules` before upgrading to AEgir 15.0.0.
(see ipfs/js-ipfs#1444 for more).

On the most recent version of git-validate that issue was fixed.
vmx added a commit to ipfs/aegir that referenced this issue Jul 19, 2018
With the change from `pre-push` to `git-validate` there was an issue
when you were removing `node_modules` before upgrading to AEgir 15.0.0.
(see ipfs/js-ipfs#1444 for more).

On the most recent version of git-validate that issue was fixed.
vmx added a commit to ipfs/aegir that referenced this issue Jul 20, 2018
With the change from `pre-push` to `git-validate` there was an issue
when you were removing `node_modules` before upgrading to AEgir 15.0.0.
(see ipfs/js-ipfs#1444 for more).

On the most recent version of git-validate that issue was fixed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants