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

Install fd via npm #438

Closed
pablopunk opened this issue May 8, 2019 · 10 comments
Closed

Install fd via npm #438

pablopunk opened this issue May 8, 2019 · 10 comments

Comments

@pablopunk
Copy link
Contributor

pablopunk commented May 8, 2019

I know no one asked for it but I created an npm package to install and use fd. I prefer npm because I use it for a lot of cross-platform tools. Works on mac and linux.

npm install -g fd-find

https://github.com/pablopunk/fd-find

@sharkdp
Copy link
Owner

sharkdp commented May 8, 2019

Thank you! Would you like to send a PR to add instructions to the README?

@pablopunk
Copy link
Contributor Author

Sure, give me some minutes

@pablopunk
Copy link
Contributor Author

#439

@orestisfl
Copy link

orestisfl commented Mar 25, 2020

This package seems to be outdated right now and I am having trouble installing it through npm. Can attach logs if you can't reproduce.

@pablopunk
Copy link
Contributor Author

@orestisfl works for me (https://asciinema.org/a/mxVBkJ0jW5Rft2cDxiWS9Cbvo). Yes, if you could provide some logs it'd be great.

@orestisfl
Copy link

Hmm, weird. After all, this only fails on the default docker ubuntu:18.04 container, I can install it locally.

root@5ad7ce06969d:/# apt-get update -qq \
> && apt-get full-upgrade -qq \
> && apt-get install -qq  build-essential wget curl git software-properties-common tmux vim \
> && curl -sL https://deb.nodesource.com/setup_13.x | bash \
> && apt-get install -y nodejs
…
> root@5ad7ce06969d:/# npm i -g fd-find
/usr/bin/fd -> /usr/lib/node_modules/fd-find/dist/fd

> [email protected] postinstall /usr/lib/node_modules/fd-find
> node download.js

/usr/lib/node_modules/fd-find/download.js:40
        throw error
        ^

Error: Command failed: 
    mkdir -p /usr/lib/node_modules/fd-find/dist &&     wget https://github.com/sharkdp/fd/releases/download/v7.5.0/fd-v7.5.0-x86_64-unknown-linux-gnu.tar.gz -O /usr/lib/node_modules/fd-find/dist/download.tar.gz &&     tar xzf /usr/lib/node_modules/fd-find/dist/download.tar.gz -C /usr/lib/node_modules/fd-find/dist/ &&     mv /usr/lib/node_modules/fd-find/dist/fd-v7.5.0-x86_64-unknown-linux-gnu/fd /usr/lib/node_modules/fd-find/dist/fd &&     rm -rf /usr/lib/node_modules/fd-find/dist/fd-v7.5.0-x86_64-unknown-linux-gnu /usr/lib/node_modules/fd-find/dist/download.tar.gz
  
/usr/lib/node_modules/fd-find/dist/download.tar.gz: Permission denied

    at ChildProcess.exithandler (child_process.js:303:12)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1026:16)
    at Socket.<anonymous> (internal/child_process.js:441:11)
    at Socket.emit (events.js:315:20)
    at Pipe.<anonymous> (net.js:674:12) {
  killed: false,
  code: 1,
  signal: null,
  cmd: '\n' +
    '    mkdir -p /usr/lib/node_modules/fd-find/dist &&     wget https://github.com/sharkdp/fd/releases/download/v7.5.0/fd-v7.5.0-x86_64-unknown-linux-gnu.tar.gz -O /usr/lib/node_modules/fd-find/dist/download.tar.gz &&     tar xzf /usr/lib/node_modules/fd-find/dist/download.tar.gz -C /usr/lib/node_modules/fd-find/dist/ &&     mv /usr/lib/node_modules/fd-find/dist/fd-v7.5.0-x86_64-unknown-linux-gnu/fd /usr/lib/node_modules/fd-find/dist/fd &&     rm -rf /usr/lib/node_modules/fd-find/dist/fd-v7.5.0-x86_64-unknown-linux-gnu /usr/lib/node_modules/fd-find/dist/download.tar.gz\n' +
    '  '
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node download.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-03-25T15_09_14_573Z-debug.log
root@5ad7ce06969d:/# cat /root/.npm/_logs/2020-03-25T15_09_14_573Z-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'i', '-g', 'fd-find' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 0d94d05e23a92c74
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 200 https://registry.npmjs.org/fd-find 223ms
8 http fetch GET 200 https://registry.npmjs.org/fd-find/-/fd-find-1.0.6.tgz 71ms
9 silly pacote tag manifest for fd-find@latest fetched in 329ms
10 timing stage:loadCurrentTree Completed in 389ms
11 silly install loadIdealTree
12 silly install cloneCurrentTreeToIdealTree
13 timing stage:loadIdealTree:cloneCurrentTree Completed in 1ms
14 silly install loadShrinkwrap
15 timing stage:loadIdealTree:loadShrinkwrap Completed in 2ms
16 silly install loadAllDepsIntoIdealTree
17 silly resolveWithNewModule [email protected] checking installable status
18 timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 7ms
19 timing stage:loadIdealTree Completed in 12ms
20 silly currentTree lib
21 silly idealTree lib
21 silly idealTree `-- [email protected]
22 silly install generateActionsToTake
23 timing stage:generateActionsToTake Completed in 10ms
24 silly diffTrees action count 1
25 silly diffTrees add [email protected]
26 silly decomposeActions action count 8
27 silly decomposeActions fetch [email protected]
28 silly decomposeActions extract [email protected]
29 silly decomposeActions preinstall [email protected]
30 silly decomposeActions build [email protected]
31 silly decomposeActions install [email protected]
32 silly decomposeActions postinstall [email protected]
33 silly decomposeActions finalize [email protected]
34 silly decomposeActions refresh-package-json [email protected]
35 silly install executeActions
36 silly doSerial global-install 8
37 verbose correctMkdir /root/.npm/_locks correctMkdir not in flight; initializing
38 verbose lock using /root/.npm/_locks/staging-a072192f34a17023.lock for /usr/lib/node_modules/.staging
39 silly doParallel extract 1
40 silly extract [email protected]
41 silly tarball trying fd-find@latest by hash: sha512-k+wNvZf1xVaPLpZsvVUfEO5QB88SU5TH8F0c0n5fK3tS1RiUyppfiEObPe+e5aZv244xGqGR3/C5zA6VeKRLJw==
42 silly extract fd-find@latest extracted to /usr/lib/node_modules/.staging/fd-find-a73f60b9 (41ms)
43 timing action:extract Completed in 46ms
44 silly doReverseSerial unbuild 8
45 silly doSerial remove 8
46 silly doSerial move 8
47 silly doSerial finalize 8
48 silly finalize /usr/lib/node_modules/fd-find
49 timing action:finalize Completed in 6ms
50 silly doParallel refresh-package-json 1
51 silly refresh-package-json /usr/lib/node_modules/fd-find
52 timing action:refresh-package-json Completed in 36ms
53 silly doParallel preinstall 1
54 silly preinstall [email protected]
55 info lifecycle [email protected]~preinstall: [email protected]
56 timing action:preinstall Completed in 2ms
57 silly doSerial build 8
58 silly build [email protected]
59 info linkStuff [email protected]
60 silly linkStuff [email protected] has /usr/lib/node_modules as its parent node_modules
61 silly linkStuff [email protected] is part of a global install
62 silly linkStuff [email protected] is installed into a global node_modules
63 silly linkStuff [email protected] is installed into the top-level global node_modules
64 verbose linkBins [ { fd: 'dist/fd' }, '/usr/bin', true ]
65 silly gently link link does not already exist {
65 silly gently link   link: '/usr/bin/fd',
65 silly gently link   target: '/usr/lib/node_modules/fd-find/dist/fd'
65 silly gently link }
66 timing action:build Completed in 15ms
67 silly doSerial global-link 8
68 silly doParallel update-linked 0
69 silly doSerial install 8
70 silly install [email protected]
71 info lifecycle [email protected]~install: [email protected]
72 timing action:install Completed in 1ms
73 silly doSerial postinstall 8
74 silly postinstall [email protected]
75 info lifecycle [email protected]~postinstall: [email protected]
76 verbose lifecycle [email protected]~postinstall: unsafe-perm in lifecycle false
77 verbose lifecycle [email protected]~postinstall: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/usr/lib/node_modules/fd-find/node_modules/.bin:/usr/lib/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
78 verbose lifecycle [email protected]~postinstall: CWD: /usr/lib/node_modules/fd-find
79 silly lifecycle [email protected]~postinstall: Args: [ '-c', 'node download.js' ]
80 silly lifecycle [email protected]~postinstall: Returned: code: 1  signal: null
81 info lifecycle [email protected]~postinstall: Failed to exec postinstall script
82 timing action:postinstall Completed in 878ms
83 verbose unlock done using /root/.npm/_locks/staging-a072192f34a17023.lock for /usr/lib/node_modules/.staging
84 timing stage:rollbackFailedOptional Completed in 9ms
85 timing stage:runTopLevelLifecycles Completed in 1433ms
86 verbose stack Error: [email protected] postinstall: `node download.js`
86 verbose stack Exit status 1
86 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
86 verbose stack     at EventEmitter.emit (events.js:315:20)
86 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
86 verbose stack     at ChildProcess.emit (events.js:315:20)
86 verbose stack     at maybeClose (internal/child_process.js:1026:16)
86 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
87 verbose pkgid [email protected]
88 verbose cwd /
89 verbose Linux 5.3.0-42-generic
90 verbose argv "/usr/bin/node" "/usr/bin/npm" "i" "-g" "fd-find"
91 verbose node v13.11.0
92 verbose npm  v6.13.7
93 error code ELIFECYCLE
94 error errno 1
95 error [email protected] postinstall: `node download.js`
95 error Exit status 1
96 error Failed at the [email protected] postinstall script.
96 error This is probably not a problem with npm. There is likely additional logging output above.
97 verbose exit [ 1, true ]

The error /usr/lib/node_modules/fd-find/dist/download.tar.gz: Permission denied seems like something is trying to execute /usr/lib/node_modules/fd-find/dist/download.tar.gz.

@pablopunk
Copy link
Contributor Author

@orestisfl I'd say wget is failing to download it cause it doesn't have write access to that folder, but I'm not sure

@orestisfl
Copy link

I am running as root by default, so it does have the correct permissions.

Funny thing is that if I copy & paste the command it works.

@pablopunk
Copy link
Contributor Author

Okay, here's the issue. Try running npm with the --unsafe-perm option. This works for me:

FROM mhart/alpine-node:12
RUN npm i -g fd-find --unsafe-perm

@orestisfl
Copy link

Oof, ok thanks. Sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants