How to install latest (untagged) state of a repo using bower?

Bower

Bower Problem Overview


I have a very small repo in which I do all dev work in the master branch and use tags as "stable" points in history.

I guess by default Bower seems to fetch the latest tagged version of a repo. I'm trying to get the most recent commit in the master branch.

I've tried running all these, in every conceivable order:

bower cache-clean mypackage
bower install mypackage --force-latest
bower install mypackage --force --force-latest
bower install mypackage --force

I've also tried adding latest to my bower.json file:

"dependencies": {
  "mypackage": "latest"
}

And then running:

bower update mypackage

No matter what it seems to always get the latest tagged state.

How do I get the latest, most up-to-date, untagged state of the project?

Bower Solutions


Solution 1 - Bower

Specify a git commit SHA instead of a version:

bower install '<git-url>#<git-commit-sha>'

Example:

bower install 'git://github.com/yeoman/stringify-object.git#d2895fb97d'

You can also specify a branch instead of a SHA, but that's generally not recommended unless it's in development and you control all the parts.

Solution 2 - Bower

Yes, you can point to the git url, or use name/repo shorthand (for github repos):

bower.json

{
  "name": "bower-test",
  "dependencies": {
    "dpm": "[email protected]:okfn/dpm.git",
    "docker-nmpjs": "terinjokes/docker-npmjs"
  }
}

More in the docs

As @roi noted in the comments, you can use the --save flag to automatically add dependencies to bower.json, e.g. bower install terinjokes/docker-npmjs --save

Solution 3 - Bower

You can install a branch in Bower > 1.0.0:

bower install xxx#foo-branch

More details at https://github.com/bower/bower/issues/107#issuecomment-22352689.

Solution 4 - Bower

If you are using a bower.json file you specify the latest version of a branch with a line in either the dependencies or devDependencies as appropriate for your project configuration:

"angular-bootstrap": "[email protected]:angular-ui/bootstrap.git#bootstrap3",

Then when you run bower install the latest version of that branch is installed. That would be branch bootstrap3 of angular-ui in this example.

Solution 5 - Bower

bower install --save package-name#master

adds this:

"dependencies": {
  "package-name": "master"
}

Solution 6 - Bower

using bower.json:

"dependencies": {
	"jquery.slimscroll": "latest",
	"jQuery": "1.11",
	"fullPage.js": "[email protected]:overbyte/fullPage.js.git#1d6bbac3d4c3b1d3d7d4096cdbcabd1c3914393f",
}

where

"[library name - in this case a forked version of fullpage.js]" : "[from git clone box in github][#commit number if required - without this you will get latest tagged version]"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJohnnyView Question on Stackoverflow
Solution 1 - BowerSindre SorhusView Answer on Stackoverflow
Solution 2 - BowerNick TomlinView Answer on Stackoverflow
Solution 3 - BowerGiovanni CappellottoView Answer on Stackoverflow
Solution 4 - BowerwibobmView Answer on Stackoverflow
Solution 5 - BowereladoView Answer on Stackoverflow
Solution 6 - BowerobieView Answer on Stackoverflow