Bundler无法使用rbenv,找不到[gem] [英] Bundler not working with rbenv, could not find [gem]
问题描述
我刚刚从rvm切换到了 rbenv ,我正尝试使用捆绑软件进行gem管理。运行捆绑安装
并尝试运行一个简单的sinatra应用程序( ruby app.rb
)后,我得到以下信息: / p>
I've just made the switch from rvm to rbenv and I'm trying to use bundler for gem management. After running bundle install
and trying to run a simple sinatra app (ruby app.rb
), I get this:
Could not find haml-3.1.4 in any of the sources
Run `bundle install` to install missing gems.
运行捆绑安装
再次无效。还尝试了捆绑更新
,这是另一个问题答复所建议的。
Running bundle install
again had no effect. Also tried bundle update
as suggested by another question response.
这是我的Gemfile:
This is my Gemfile:
source "http://rubygems.org"
gem "sinatra"
gem "haml"
这就是捆绑节目
产生的结果
* bundler (1.0.22)
* haml (3.1.4)
* rack (1.4.1)
* rack-protection (1.2.0)
* sinatra (1.3.2)
* tilt (1.3.3)
这是我的应用程序所需要的:
This is what my app requires:
require "rubygems"
require "bundler/setup"
require 'sinatra'
我确信这是捆绑程序和rbenv不能一起使用的某种路径问题。我尝试浏览rbenv的文档,但找不到任何内容。
I'm convince that this is some kind of path issue where bundler and rbenv aren't playing along. I've tried looking through rbenv's documentation but was not able to find to anything.
注意:在其他sinatra应用中,尝试运行时得到以下信息它:
Could not find addressable-2.2.7 in any of the sources
Run `bundle install` to install missing gems.
补充信息
echo $ PATH
/Users/uri/.rbenv/shims:/Users/uri /.rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
捆绑了
/Users/uri/.rbenv/shims/bundle
如果我做捆绑安装--system
它有效。尽管我认为这不是一个可行的解决方案。
If I do bundle install --system
it works. Although I can't see this as being a viable solution.
推荐答案
我遇到了同样的问题。一个提示是 rbenv exec bundle exec命令
起作用,而 rbenv exec bundle install --path vendor / bundle
起作用,
I was having the same issue. One hint was that rbenv exec bundle exec command
worked and that rbenv exec bundle install --path vendor/bundle
worked, but their prefixed equivalents failed.
我擦除了〜/ .rbenv
,〜/ .gem
Gemfile.lock
和 vendor / bundle
几次尝试重新开始。一旦清除了这些,我将尝试以下操作:
I wiped my ~/.rbenv
, ~/.gem
Gemfile.lock
and vendor/bundle
a few times trying to start fresh. Once these were cleaned away I tried the following:
rbenv install 1.9.3-p194
rbenv rehash # for paranoia's sake
rbenv global 1.9.3-p194
gem env # to check that everything was pointing at 1.9 and not the system
gem install --no-ri --no-rdoc bundler
rbenv rehash # necessary to load up the bundle executable
bundle --path=vendor/bundle
它奏效了!
我认为重要的事情是,从我的主目录中删除了.gem文件,因为我尝试了几次。似乎有碍。
I think the important thing, since I tried this a few times, is to remove the .gem file from your home directory. It seems to get in the way.
这篇关于Bundler无法使用rbenv,找不到[gem]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!