nicojs / node-link-parent-bin

A tool to link the bins of the your npm dependencies to child packages in a node multi-package repository
43 stars 11 forks source link

Ignore EEXIST error #2

Closed jan-molak closed 7 years ago

jan-molak commented 7 years ago

Hey @nicojs and thanks for this great module :-)

It seems that ParentBinLinker unnecessarily complains if the symlink already exists. This makes people looking at the logs think that there's a problem while, in fact, everything is just fine:

[2017-07-31 13:42:05.970] [ERROR] ParentBinLinker - Could not link bin _mocha for child admin-console. { Error: EEXIST: file already exists, symlink '../../../../node_modules/mocha/bin/_mocha' -> '/Users/jan/path/to/project/packages/package/node_modules/.bin/_mocha'
    at Error (native)
  errno: -17,
  code: 'EEXIST',
  syscall: 'symlink',
  path: '../../../../node_modules/mocha/bin/_mocha',
  dest: '/Users/jan/path/to/project/packages/package/node_modules/.bin/_mocha' }

Would it be possible to ignore EEXIST?

Thanks, Jan

nicojs commented 7 years ago

Yes, i noticed this as well (only on linux). It only occurs if there already a symlink to a different location. Probably you have a dependency in both your parent and child module.

I will fix it, logging it in info i think would be best.

nicojs commented 7 years ago

It's fixed with this commit: https://github.com/nicojs/node-link-parent-bin/commit/020a7e94a4a486aaa75a284600d0c9b5b5a1a38c

I've released v0.1.3 for it. Let me know if you have any more problems!

jan-molak commented 7 years ago

Great stuff, thanks @nicojs! I'll check on Monday 👍

Aqours commented 5 years ago

@nicojs This issue can be reproduced on Windows Linux Subsystem(Ubuntu). link-parent-bin v1.0.0

nicojs commented 5 years ago

@Aqours thanks for your response.

Could you please show what the error is exactly? I'm getting this log message when using WSL (indicating the desired behavior works):

08:20:00 (64) INFO link Different link at 'packages/wct-runner/node_modules/.bin/_mocha' already exists. Leaving it alone, the package is probably already installed in the child package.
Aqours commented 5 years ago
15:23:26 (315) INFO ParentBinLinker Linking dependencies ["@babel/cli","@babel/core","@babel/preset-env","@types/chai","@types/clipboard","@types/core-js","@types/event-hooks-webpack-plugin","@types/events","@types/gulp","@types/karma","@types/lodash","@types/md5","@types/mocha","@types/node","@types/sinon","@types/terser-webpack-plugin","@types/url-parse","@types/webpack","@types/webpack-bundle-analyzer","@types/webpack-dev-server","ansi-colors","autoprefixer","babel-loader","babelify","browserify","browserify-derequire","browserify-versionify","chai","css-loader","cssnano","del","event-hooks-webpack-plugin","file-loader","git-rev-sync","gulp","gulp-cli","gulp-header","gulp-rename","gulp-sourcemaps","gulp-uglify","http-server","karma","karma-chrome-launcher","karma-mocha","karma-mocha-reporter","karma-typescript","lerna","less","less-loader","link-parent-bin","mocha","postcss-loader","rimraf","rollup","shell-env","sinon","style-loader","terser-webpack-plugin","ts-loader","ts-node","tslint","typescript","url-loader","vinyl-buffer","vinyl-source-stream","watchify","webpack","webpack-bundle-analyzer","webpack-cli","webpack-dev-server","worker-loader"] under children ["adv-danmaku","danmaku","danmaku-live","danmaku-websocket","flv.js","screenshot"]
15:23:34 (315) ERROR ParentBinLinker Could not link bin babel for child adv-danmaku. { [Error: EEXIST: file already exists, symlink '../../../../node_modules/@babel/cli/bin/babel.js' -> '/mnt/c/VCS/bilibili/js-common/packages/adv-danmaku/node_modules/.bin/babel']
  errno: -17,
  code: 'EEXIST',
  syscall: 'symlink',
  path: '../../../../node_modules/@babel/cli/bin/babel.js',
  dest:
   '/mnt/c/VCS/bilibili/js-common/packages/adv-danmaku/node_modules/.bin/babel' }
15:23:34 (315) ERROR ParentBinLinker Could not link bin babel for child danmaku-websocket. { [Error: EEXIST: file already exists, symlink '../../../../node_modules/@babel/cli/bin/babel.js' -> '/mnt/c/VCS/bilibili/js-common/packages/danmaku-websocket/node_modules/.bin/babel']
  errno: -17,
  code: 'EEXIST',
  syscall: 'symlink',
  path: '../../../../node_modules/@babel/cli/bin/babel.js',
  dest:
   '/mnt/c/VCS/bilibili/js-common/packages/danmaku-websocket/node_modules/.bin/babel' }
15:23:34 (315) ERROR ParentBinLinker Could not link bin babel for child screenshot. { [Error: EEXIST: file already exists, symlink '../../../../node_modules/@babel/cli/bin/babel.js' -> '/mnt/c/VCS/bilibili/js-common/packages/screenshot/node_modules/.bin/babel']
  errno: -17,
  code: 'EEXIST',
  syscall: 'symlink',
  path: '../../../../node_modules/@babel/cli/bin/babel.js',
  dest:
   '/mnt/c/VCS/bilibili/js-common/packages/screenshot/node_modules/.bin/babel' }
15:23:34 (315) ERROR ParentBinLinker Could not link bin babel for child danmaku-live. { [Error: EEXIST: file already exists, symlink '../../../../node_modules/@babel/cli/bin/babel.js' -> '/mnt/c/VCS/bilibili/js-common/packages/danmaku-live/node_modules/.bin/babel']
  errno: -17,
  code: 'EEXIST',
  syscall: 'symlink',
  path: '../../../../node_modules/@babel/cli/bin/babel.js',
  dest:
   '/mnt/c/VCS/bilibili/js-common/packages/danmaku-live/node_modules/.bin/babel' }
... // too many errors

It works fine when I run command in CMD/PowerShell.

nicojs commented 5 years ago

Are you mix-and-matching WSL and PowerShell / CMD? I don't think link-parent-bin supports that. Other tools don't support that either, for example npm itself.

I myself use a different directory for WSL vs PowerShell/CMD/GitBash. WSL2 even goes as far as running bash in an actual vm so I would expect it not to share the disk with windows itself.

Aqours commented 5 years ago

I use WSL(without PS/CMD) to clone new project and npm install deps with run link-parent-bin, still report these errors.

I seems these errors are related to WSL, I use git-bash terminal later, it works great too. Thanks

Aqours commented 5 years ago

@nicojs I still have this problem on Mac or CI(docker/Linux). Is there any way to ignore these errors?

Aqours commented 5 years ago

It seems be related to local deps symlink.

// directory structure
root
    packages/
        projectA
            package.json
    node_modules/
       projectA (local dependency which symlink to above) 

This directory structure would cause those errors when I exec link-parent-bin. ref: local dependency

nicojs commented 5 years ago

@Aqours in your example, what are you trying to do exactly? What is the link-parent-bin command you're executing?

A small reproduction repo would be helpful. It can be a zip you attach to this issue.