Purple-Devs / rbenv-binstubs

A Bundler binstubs Plugin for rbenv [maintainer wanted]
281 stars 11 forks source link

Usage info in README is incorrect #8

Closed mislav closed 11 years ago

mislav commented 11 years ago

You forgot to stress out that the users needs to run rbenv rehash after bundle install in each project.

Also, don't suggest that all users should run bundle install --binstubs. I personally prefer whitelisting binstubs by just generating ones I need:

bundle binstubs rake
bundle binstubs rspec-core
bundle binstubs cucumber

There is some discussion that bundle install --binstubs isn't compatible with Rails 4 (I don't know the state of this, though).

ianheggie commented 11 years ago

Hi Mislav, Thanks for the feedback,

On 24/07/13 00:42, Mislav Marohnić wrote:

  You forgot to stress out that the users needs to run rbenv
      rehash after bundle install in each
    project.

This is covered in the rbenv README - point 6 of https://github.com/sstephenson/rbenv#basic-github-checkout

Though I personally use https://github.com/sstephenson/rbenv-gem-rehash as mentioned in https://github.com/sstephenson/rbenv/wiki/Plugins#approved-plugins which runs rehash automatically, so I don't have to remember to do it anyway.

  Also, don't suggest that all users should run bundle
      install --binstubs. I personally prefer whitelisting
    binstubs by just generating ones I need:
  bundle binstubs rake
  bundle binstubs rspec-core
  bundle binstubs cucumber

My intent is to keep the instructions in the README as concise and simple as possible.

If you want to send me a suggested page for the wiki on the subject "Whitelisting binstubs, pros, cons and effect" I would be happy to consider it for inclusion. Please include the advantages you see as well as any disadvantages you recognised. Having encountered some subtle and weird problems arising from not using binstubs or bundle exec in the past, I personally like the "it just works" approach rather than having to remember if I had whitelisted the gem the command comes from.

ANYONE ELSE LIKE TO COMMENT?

  There is some discussion that bundle install --binstubs
    isn't compatible with Rails 4 (I don't know the state of this,
    though).

This was fixed in Rails 4.0.0 - I tested it a few days ago with the latest bundler and rails before tagging the current code base as release 1.0

mislav commented 11 years ago

It's true that rbenv Readme suggests that you run rbenv rehash after installing gems with executables, but that never applied to Bundler since bundle install historically didn't generate gem binstubs in the default executables directory. There would be nothing new to rehash. Users were required to prefix everything with bundle exec.

Your plugin frees us from bundle exec, but at the cost of having to start doing rehash after bundle install (which we previously weren't used to do). You should stress that out, but it's a good idea to also mention the gem-rehash plugin as a possible solution for having to remember this.

As for my thoughts on binstubs, I've summarized them here for you.

ianheggie commented 11 years ago

I am adding a comment to the the plugins README regarding running rehash manually or using the plugin.

Note, I checked without my plugin installed and rehash is required after bundle install, so it is not an "additional" cost. See below for an example using a fresh install of ruby 2.0

ianh@abe:~/tmp/rk$ rbenv install 2.0.0-p247 
Downloading ruby-2.0.0-p247.tar.gz...
-> http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz
Installing ruby-2.0.0-p247...
Installed ruby-2.0.0-p247 to /home/ianh/.rbenv/versions/2.0.0-p247

ianh@abe:~/tmp/rk$ rbenv version
2.0.0-p247 (set by /home/ianh/tmp/.ruby-version)
ianh@abe:~/tmp$ gem list

*** LOCAL GEMS ***

bigdecimal (1.2.0)
io-console (0.4.2)
json (1.7.7)
minitest (4.3.2)
psych (2.0.0)
rake (0.9.6)
rdoc (4.0.0)
test-unit (2.0.0.0)
ianh@abe:~/tmp/rk$ 
ianh@abe:~/tmp/rk$ rbenv which unicorn
rbenv: unicorn: command not found
ianh@abe:~/tmp/rk$ gem install bundler
Fetching: bundler-1.3.5.gem (100%)
Successfully installed bundler-1.3.5
1 gem installed
ianh@abe:~/tmp/rk$ cat Gemfile 
source 'https://rubygems.org'

gem 'unicorn'
ianh@abe:~/tmp/rk$ bundle install
Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
Installing kgio (2.8.0) 
Installing rack (1.5.2) 
Installing raindrops (0.11.0) 
Installing unicorn (4.6.3) 
Using bundler (1.3.5) 
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
ianh@abe:~/tmp/rk$ rbenv which unicorn
/home/ianh/.rbenv/versions/2.0.0-p247/bin/unicorn
ianh@abe:~/tmp/rk$ type unicorn
bash: type: unicorn: not found
ianh@abe:~/tmp/rk$ rbenv rehash
ianh@abe:~/tmp/rk$ type unicorn
unicorn is /home/ianh/.rbenv/shims/unicorn
ianh@abe:~/tmp/rk$
ianh@abe:~/tmp/rk$ ls ~/.rbenv/plugins
ruby-build
mislav commented 11 years ago

Huh, so bundle install created /home/ianh/.rbenv/versions/2.0.0-p247/bin/unicorn for you. Interesting. Older Bundler versions didn't do that.

However, I still maintain my position that users weren't used to running rbenv rehash after bundle install since they were using bundle exec anyway. I was such a user, for instance (until I generated binstubs and added ./bin to my PATH)

ianheggie commented 11 years ago

RE binstubs

I read your blog article about binstubs, and think the following should allow for the different personal preferences without being too wordy:

Installation

To install rbenv-binstubs, clone this repository into your ~/.rbenv/plugins directory. (You'll need a recent version of rbenv that supports plugin bundles.)

$ mkdir -p ~/.rbenv/plugins
$ cd ~/.rbenv/plugins
$ git clone https://github.com/ianheggie/rbenv-binstubs.git

I recommend you install the gem-rehash plugin as well so you don't have to remember to use rbenv rehash after each bundle install.

Then for each application directory run:

$ bundle install --binstubs .bundle/bin

The .bundle/bin argument keeps the binstubs separate from the default bin/ since bin/ is now used for application scripts and should be included in your code repository (from rails 4.0.0 onwards). If you wish to mix application scripts and binstubs, then consider generating only those binstubs you need.

mislav commented 11 years ago

Perfect, :shipit:

On Wed, Jul 24, 2013 at 6:32 PM, Ian Heggie notifications@github.comwrote:

RE binstubs

I read your blog article about binstubs, and think the following should allow for the different personal preferences without being too wordy: Installation

To install rbenv-binstubs, clone this repository into your ~/.rbenv/plugins directory. (You'll need a recent version of rbenv that supports plugin bundles.)

$ mkdir -p ~/.rbenv/plugins $ cd ~/.rbenv/plugins $ git clone https://github.com/ianheggie/rbenv-binstubs.git

I recommend you install the gem-rehashhttps://github.com/sstephenson/rbenv-gem-rehashplugin as well so you don't have to remember to use rbenv rehash after each bundle install.

Then for each application directory run:

$ bundle install --binstubs .bundle/bin

The .bundle/bin argument keeps the binstubs separate from the default bin/ since bin/ is now used for application scripts and should be included in your code repository (from rails 4.0.0 onwards). If you wish to mix application scripts and binstubs, then consider generating only those binstubs you need https://coderwall.com/p/vhfxia.

— Reply to this email directly or view it on GitHubhttps://github.com/ianheggie/rbenv-binstubs/issues/8#issuecomment-21497641 .