What have you found for these years?

2010-12-03

bundler workflow

Play around with kramdown and github flavored markdown.
Maybe I should start using markdown, although I am not satisfied
with it, but it's the best formatting engine I can find... at this point.
And it's indeed popular. (means more supports)

18:38 ~/p/c/facebase master> kramdown doc/bunlder.md | pbcopy

bundler workflow

Summary

  • update gems: `bundle install`
  • update gems: `bundle install --path ~/.gems`
  • update Gemfile.lock: `rm Gemfile.lock; bundle check`

Glossary

  • bundler: The gem
  • bundle: The command line tool in bundler
  • gem: The command line tool in rubygems, the ruby package manager
  • `COMMAND`: Illustrate a shell (bash) command.

  • Gemfile: Could be considered as a gem config for human.

  • Gemfile.lock: The manifest of gems for the project, generated from Gemfile. Do not edit this file directly. This is used for launching the application.

  • root permission: If we need root permission to do something, then a `sudo COMMAND` prefix to the command is a must.

Developers who don’t care about gems

So just leave Gemfile and Gemfile.lock alone. In most cases, you might only need to run `bundle install`. But sometimes it might go wrong by accident or human mistakes or so, then you might need to update Gemfile.lock. To update this file, remove it from filesystem first, then invoke `bundle check` or `bundle list`. This would tell bundler try to resolve dependency graph from Gemfile.

If running `bundle install` gives some errors installing some gems, try to install it via native `gem install GEM_NAME`

p.s. According to `bundle --help install`, we should never use `sudo bundle install`. If bundler needs root permission, it will ask us at the time the permission is needed.

If you’ve already used it before, and some permission is broken, you might want to run this to fix the permission: `sudo chown -R `whoami` ~/.gem`

Developers who might need to update Gemfile

To update Gemfile, The workflow would be:

  1. Remove Gemfile.lock from filesystem: `rm Gemfile.lock`
  2. Update Gemfile
  3. Run `bundle check` or `bundle list` to generate a new Gemfile.lock
  4. Checkin Gemfile and Gemfile.lock in git: `git add Gemfile Gemfile.lock`

Gem paths

By default, there are two kinds of gem installation path. One is called system gem, another one is called user gem. To install gems to system gem path, we’ll need root permission (sudo). To install gems to user gem path, we won’t need root permission. I (godfat) would recommend not to use sudo, so that it is more secure. To install gems to user gem path via bundler, use: `bundle install --path ~/.gems` The --path option would be remembered by bundler, so that we don’t need to type it every time.

0 retries:

Post a Comment

All texts are licensed under CC Attribution 3.0