yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.44k stars 2.73k forks source link

"yarn global add" doesn't globally install packages if .yarn-cache was restored #1151

Open ide opened 8 years ago

ide commented 8 years ago

Do you want to request a feature or report a bug? Bug

What is the current behavior? If you restore .yarn-cache from another machine (e.g. on a CI system) that had a globally installed package, then running yarn global add <pkg> doesn't install the package on the new machine.

If the current behavior is a bug, please provide the steps to reproduce. Set up a circle.yml file that tells CircleCI to cache ~/.yarn-cache. Run a build and then run it again (make sure in the "Restore cache" step that home/ubuntu/.yarn-cache is restored).

The second time around, even though yarn global add codecov runs successfully and says success Installed codecov@1.0.1 with binaries: codecov, the codecov package is missing. It doesn't place anything in nvm's global node_modules folder nor the bin folder.

machine:
  pre:
    - mkdir ~/.yarn-cache
  node:
    version: 6

dependencies:
  cache_directories:
    - ~/.yarn-cache
  pre:
    - curl -o- -L https://yarnpkg.com/install.sh | bash
    - yarn global add codecov
  override:
    - yarn

test:
  pre:
    - yarn run lint
  override:
    - yarn test -- --coverage
  post:
    - codecov

What is the expected behavior? yarn global add <pkg> should reinstall the package. As a workaround, using npm or yarn global remove <pkg> works fine.

Please mention your node.js, yarn and operating system version. Node 6.8.1 installed with nvm 0.31.0 Yarn 0.15.1 installed via curl + bash Ubuntu 12.04 on CircleCI

WoodyWoodsta commented 8 years ago

I'm having the same issue, but with different circumstances. If I install a new version of node alongside an old version (using nvm), then yarn global add does not result in any packages being installed in the new bin. I assume that installing yarn in the new version of node results in the cache being "restored" from the old version of node?

jch254 commented 8 years ago

^ Me too!

IcanDivideBy0 commented 8 years ago

Same issue, using

  post:
    - bash <(curl -s https://codecov.io/bash)

is fast enouth (more than npm) and don't require to install any dependency

andrewmclagan commented 7 years ago

yeah we are also having this same issue

tusharmath commented 7 years ago

@andrewmclagan I had some issues like these after some debugging I realized that there were two versions of yarn. After that you must make sure that the bin folder is in the path variable —

export PATH="/usr/local/bin:/Users/andrew/.config/yarn/global/node_modules/.bin"
iryston commented 7 years ago

More universal export (without username): PATH="${HOME}/.config/yarn/global/node_modules/.bin${PATH:+:${PATH}}"; export PATH;

IzaGz commented 7 years ago

@iryston where should i put this?

iryston commented 7 years ago

@IzaGz it depends on your OS and shell. If you have *NIX & BASH put it in .bashrc or .bash_profile. For ZSH put it in .zshrc or .zprofile.

casaper commented 7 years ago

More universal export (without username): PATH="${HOME}/.config/yarn/global/node_modules/.bin${PATH:+:${PATH}}"; export PATH;

why so complicated? Here this does the job equally well and universal … export PATH="$PATH:$HOME/.config/yarn/global/node_modules/.bin"

dylanfoster commented 7 years ago

just out of curiosity, is there any reason we don't use the same path that npm uses? I was expecting yarn to be a drop in replacement (minus command names) for npm.

jrgtt commented 6 years ago

Isn't there a cleaner solution? I installed parcel globally and came up to this issue... The solutions above work, but checking out the global .bin folder of yarn there's way more there than I actually need. Following this solution added a bunch of binaries to my path without necessity.

vzaidman commented 6 years ago

workaround for windows:

%USERPROFILE%\AppData\Local\Yarn\bin
Alecto commented 6 years ago

yarn add global gulp-cli не устанавливает gulp-cli глобально, либо в ту же папку, либо в корень диска.