Skip to content

Instantly share code, notes, and snippets.

@askielboe
Last active October 19, 2017 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save askielboe/0c0bc3fdf88193bb17fc4fef5d332ad1 to your computer and use it in GitHub Desktop.
Save askielboe/0c0bc3fdf88193bb17fc4fef5d332ad1 to your computer and use it in GitHub Desktop.
Script to reproduce a bug in yarn (#4734) - please replace askielboe/yarn-bug.git with your own github repo
#!/bin/bash
echo "\n==================================================="
echo "=== Clearing yarn cache and directories for clean state\n"
yarn cache clean yarn-bug
rm -rf yarn-bug
rm -rf yarn-bug-reproduce
echo "\n==================================================="
echo "=== Creating and pushing first commit to GitHub\n"
mkdir yarn-bug
cd yarn-bug
git init
git remote add origin git@github.com:askielboe/yarn-bug.git
touch version_1.0
git add version_1.0
git commit -m "version 1.0"
git push -u origin master
cd ..
echo "\n==================================================="
echo "=== Installing the new commit with yarn\n"
alias yarn="node ~/work/yarn/lib/cli/index.js"
mkdir yarn-bug-reproduce
cd yarn-bug-reproduce
packagejson='{
"name": "yarn-bug",
"version": "1.0.0",
"dependencies": {
"yarn-bug": "askielboe/yarn-bug#master"
}
}'
echo "$packagejson" > package.json
yarn install
echo "\nThe folder node_modules/yarn-bug now contains only version_1.0 (as it should):"
ls node_modules/yarn-bug
cd ..
echo "\n==================================================="
echo "=== Push new commit with file version_2.0 to GitHub\n"
cd yarn-bug
touch version_2.0
git add version_2.0
git commit -m "version 2.0"
git push
cd ..
echo "\n==================================================="
echo "=== Clear node_modules and do a new yarn install\n"
cd yarn-bug-reproduce
rm -rf node_modules
yarn install
echo "\nThe folder node_modules/yarn-bug does not contain version_2.0 from the new commit:"
ls node_modules/yarn-bug
echo "\nyarn.lock file contains the hash of the first commit (i.e. yarn has not checked for new commits at github):"
cat yarn.lock
echo "\n==================================================="
echo "=== Clear node_modules and yarn.lock and do a new install\n"
rm -rf node_modules; rm -rf yarn.lock
yarn install
echo "\nThe folder node_modules/yarn-bug now contains version_2.0 (as it should):"
ls node_modules/yarn-bug
echo "\nyarn.lock file also contains the hash of HEAD (so far so good):"
cat yarn.lock
echo "\n==================================================="
echo "=== Clear only node_modules (again) and do a new install\n"
rm -rf node_modules
yarn install
echo "\nThe folder node_modules/yarn-bug now does not contain version_2.0 (yarn has somehow installed from an old cache):"
ls node_modules/yarn-bug
echo "\nyarn.lock file still contains the correct hash of HEAD:"
cat yarn.lock
echo "\n==================================================="
echo "=== Clear only node_modules (again) and do a new install with --frozen-lockfile\n"
rm -rf node_modules
yarn install --frozen-lockfile
echo "\nThe folder node_modules/yarn-bug still does not contain version_2.0:"
ls node_modules/yarn-bug
echo "\nyarn.lock file still contains the correct hash of HEAD:"
cat yarn.lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment