分享 rbenv 每次需要 rehash,和 rvm 比,可用性也太差了吧。

xds2000 · 2012年02月07日 · 最后由 xds2000 回复于 2012年04月09日 · 8010 次阅读

rbenv+rubybuild.目的就是取代 rvm

发现每次安装 gem 后都需要 rbenv rehash, 达到没法用级别。

谁来批批砖,给指点指点。

Ruby 社区里面不是一直说 rbenv 比 RVM 好用么

为啥每次装完都需要 rehash? 至少我没有这样做过

rbenv 是 37signals 的员工写的

不知道是不是我的配置有问题还是其他,我也需要 rehash。 我觉得 Ruby 社区认为 rbenv 好的理由是相对于 rvm,rbenv 显得相当的轻量级吧。 rbenv 和 rvm 本质上都不会给 ruby / rubygems 增加新的特性,对比的话就应该看谁更便利一些,我仍然觉得 rvm 更加方便,已经退回去使用 rvm 了。

安装新版本 ruby 和带有 shell 命令的 gem 时需要 rehash google 可以找到一些自动 rehash 的脚本

引用一下一段对 rvm/rbenv divide 的经典结论

I think, after installing both back-to-back on my own system, that their similarities outweigh their differences. One article I read about the subject compared RVM and rbenv to Rails and Sinatra . I think that comparison really fits. Sinatra is a lightweight framework whereas Rails is much more robust. Sometimes sinatra just fits, and other times you'd be a fool to not go with Rails. If you need the features in RVM then use it, if you want more control and a lighter feel then use rbenv. It's all a matter of preference.

As a rubyist I'm just glad we have people like Wayne Seguin, and Sam Stephenson contributing to the community the way they do.

同向两位作者致敬,尤其是 Wayne,每当看到 rvm 庞大繁复的特性时,我都佩服他付出的难以想象的努力

不是每次吧...是带 c 扩展得 gem 才需要...

官方回答:Rebuild the shim binaries. You should do this any time you install a new Ruby binary (for example, when installing a new Ruby version, or when installing a gem that provides a binary).

新装的 gem(以前重没装过)一定要 rehash 在.rbenv/shims 下生成可执行程序,像 zsh 要自动补全还需要 hash -r .不过因为 rbenv init - 里会调用 rbenv rehash,所有新开个窗口是不需要的.我的用法是 bundler 管理 gemset,在~/.bundle/config 里设置 BUNDLE_PATH 为 vendor/bundle , 配合 shell 的一个小函数为常用命令添加 alias,在发现 Gemset 的时候自动加上 bundle exec ( rbenv.zsh ).通过 bundler 安装 bundle exec 执行是不需要 rehash 的

喜欢 rbenv 就是因为不需要 gemset,而且 rbenv 对 debian 支持的很好

谢谢大家的讨论。受教了

安装一个 gem: rbenv-rehash 就解决我提到的困惑啦。 https://github.com/scoz/rbenv-rehash

需要 登录 后方可回复, 如果你还没有账号请 注册新账号