Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby Rbenv tries to run Zeus from Bundle despite it being a global gem (Using ZSH)

(Update: Problem caused by zsh, see accepted answer)

Long ago, I followed this great guide to using Rbenv with bundler https://gist.github.com/1384279 and all was well in Ruby Land. (I installed it correctly)

Bundler gem is installed globally for the current ruby version. All gems for each project are bundle installed from their respective gemfiles.

I am attempting to install Zeus globally (like how bundler is installed globally) rather than adding it to the gemfile of each project.

joe@computer:~/some_project
> rbenv versions
  1.9.3-p194
* 1.9.3-p327-perf (set by /Users/joe/some_project/.rbenv-version)

joe@computer:~/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems
> ls -a
.                   method_source-0.7.1 zeus-0.13.1
..                  rake-0.9.2.2
bundler-1.2.0.rc.2  rdoc-3.9.4

I have succeeded, as you can see zeus is installed globally along with bundler... however:

joe@computer:~/some_project
> rbenv rehash

joe@computer:~/some_project
> zeus init
Users/joe/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/bundler-1.2.0.rc.2/lib/bundler/rubygems_integration.rb:147:in `block in replace_gem': zeus is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
from /Users/joe/.rbenv/versions/1.9.3-p327-perf/bin/zeus:22:in `<main>'

As far as I can discern, zeus is being sought as if it is bundle installed, but its not bundle installed its globally installed.

How do I get the shell to look at the global gems before the bundled gems?

like image 300
xxjjnn Avatar asked Dec 19 '12 17:12

xxjjnn


2 Answers

If I got it right and you have the same problem with me and you are also running zsh, then this problem is that oh-my-zsh automatically wraps some commands using bundler if you have the bundler plugin installed.

See: https://github.com/robbyrussell/oh-my-zsh/pull/1507

https://github.com/robbyrussell/oh-my-zsh/pull/1138

https://github.com/heroku/heroku/issues/173

EDIT: This has been fixed in oh-my-zsh

like image 96
Kieran Andrews Avatar answered Oct 29 '22 15:10

Kieran Andrews


If you do have this problem with oh-my-zsh and for whatever reason you haven't updated, you could just prepend zeus with a backslash, for example:

% \zeus start
% \zeus g model Post title content:text
% \zeus rake db:migrate

What the backslash does is runs the command overriding any aliases. See this section on Wikipedia http://en.wikipedia.org/wiki/Alias_(command)#Overriding_aliases

like image 22
sudoash Avatar answered Oct 29 '22 15:10

sudoash