避免每次输入bundler Exec命令
2013-09-19 00:04
253 查看
避免每次输入bundler Exec命令
bundle在ruby的世界里是个好东西,它可以用来管理应用程序的依赖库。它能自动的下载和安装指定的gem,也可以随时更新指定的gem。rvm则是一个命令行工具,能帮助你轻松的安装,管理多个ruby环境。每个环境可以指定一系列的gem。它允许你为每一个项目指定其ruby的版本,需要的gem的版本。这能最大限度的避免由于ruby环境的差异,或者不同版本的gem造成的各种问题。
当我在项目中引入了rvm后,使用rake命令时,每次都会出现这样的异常。
1 2 3 4 5 6 7 8 | rake aborted! You have already activated rake 10.0.0, but your Gemfile requires rake 0.9.2.2. Using bundle exec may solve this. /usr/local/rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.3/lib/bundler/runtime.rb:31:in `block in setup' /usr/local/rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.3/lib/bundler/runtime.rb:17:in `setup' /usr/local/rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.3/lib/bundler.rb:116:in `setup' /usr/local/rvm/gems/ruby-1.9.3-p194/gems/bundler-1.2.3/lib/bundler/setup.rb:7:in `<top (required)>' /Users/twer/sourcecode/octopress/Rakefile:2:in `<top (required)>' (See full trace by running task with --trace) |
10.0.0版本,但是这个项目中配置的rake版本却是
0.9.2.2,所以在执行rake命令时应该使用Gemfile的。
而
bundle exec可以在当前bundle的上下文中执行一段脚本。通过它可以调用本项目中指定的rake版本来执行命令。
下面是官方文档的说明。
In some cases, running executables without bundle exec may work, if the executable happens to be installed in your system and does not pull in any gems that conflict with your bundle. However, this is unreliable and is the source of considerable pain. Even if it looks like it works, it may not work in the future or on another machine.
所以我们只要每次执行命令的时候加上
bundle exec的前缀就可以额。但是这样搞的很烦人,试想每天都要敲上百次这样的字符,而且还常常忘记。
有一个方法可以避免每次都要键入
bundle exec作为前缀。
安装rubygems-bundler。
1 | $ gem install rubygems-bundler |
1 | $ gem regenerate_binstubs |
12 | $ rvm get head && rvm reload $ chmod +x $rvm_path/hooks/after_cd_bundler |
12 | $ cd your_project_path $ bundle install --binstubs=./bundler_stubs |
bundler exec前缀。
如果想禁用次bundler的话,只需要在命令前面加上
NOEXEC_DISABLE=1前缀。更详细的信息可以看[rubygems-bundler]的文档。
相关文章推荐
- 避免每次输入bundler Exec命令
- 执行 sudo 命令下避免输入密码的两个方法
- 让git push命令不再每次都输入密码
- mstsc连接服务器时如何避免每次在登陆窗口输入密码(rdp passwd decrypted )
- ssh避免每次输入用户名密码的方式
- 如何避免git每次提交都输入密码
- git避免每次输入密码
- 解决mac 下的 命令或Sourcetree 每次拉取提交都需要输入密码
- ssky-keygen + ssh-copy-id避免ssh/scp每次输入密码
- Git Bash提交代码避免每次输入用户密码
- mac下git push避免每次都输入用户名和密码的配置
- windows下git 如何避免每次push都要输入用户名和密码
- gitbash避免每次push都输入密码
- mac下git push避免每次都输入用户名和密码的配置
- git避免每次提交输入密码
- git杂记:如何避免每次输入密码
- Git避免每次远程交互都需要输入密码的设置
- git push命令每次都要输入用户名和密码的问题处理
- ssh 避免每次都输入登陆密码
- 使用git时避免每次提交输入密码