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

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

Open
ide opened this issue Oct 17, 2016 · 13 comments
Open

Comments

@ide
Copy link
Contributor

ide commented Oct 17, 2016

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 [email protected] 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
Copy link

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
Copy link

jch254 commented Nov 2, 2016

^ Me too!

@IcanDivideBy0
Copy link

IcanDivideBy0 commented Nov 2, 2016

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
Copy link

yeah we are also having this same issue

@tusharmath
Copy link

@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
Copy link

iryston commented Dec 14, 2016

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

@IzaGz
Copy link

IzaGz commented Dec 23, 2016

@iryston where should i put this?

@iryston
Copy link

iryston commented Dec 23, 2016

@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
Copy link

casaper commented Dec 26, 2016

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
Copy link

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
Copy link

jrgtt commented Feb 13, 2018

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
Copy link

workaround for windows:

%USERPROFILE%\AppData\Local\Yarn\bin

@Alecto
Copy link

Alecto commented Nov 1, 2018

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

ForbesLindesay added a commit to RollingVersions/RollingVersions that referenced this issue Apr 12, 2020
ForbesLindesay added a commit to RollingVersions/RollingVersions that referenced this issue Apr 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests