gpt4 book ai didi

ruby - Bundler 无法与 rbenv 一起工作,找不到 [gem]

转载 作者:数据小太阳 更新时间:2023-10-29 06:22:47 24 4
gpt4 key购买 nike

我刚刚从 rvm 切换到 rbenv,我正在尝试使用 bundler 进行 gem 管理。在运行 bundle install 并尝试运行一个简单的 sinatra 应用程序 (ruby app.rb) 之后,我得到了这个:

Could not find haml-3.1.4 in any of the sources
Run `bundle install` to install missing gems.

再次运行 bundle install 没有效果。还按照另一个问题回复的建议尝试了 bundle update

这是我的 Gemfile:

source "http://rubygems.org"

gem "sinatra"
gem "haml"

这就是 bundle show 产生的结果

* 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)

这是我的应用所需要的:

require "rubygems"
require "bundler/setup"
require 'sinatra'

我确信这是某种路径问题,其中 bundler 和 rbenv 没有一起玩。我尝试查看 rbenv 的文档,但没有找到任何内容。

注意:在不同的 sinatra 应用程序中,我在尝试运行它时得到以下信息:

Could not find addressable-2.2.7 in any of the sources
Run `bundle install` to install missing gems.

补充信息

回显 $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

更新

如果我执行 bundle install --system 它会起作用。尽管我认为这不是一个可行的解决方案。

最佳答案

我遇到了同样的问题。一个提示是 rbenv exec bundle exec command 有效并且 rbenv exec bundle install --path vendor/bundle 有效,但它们的前缀等价物失败了。

我删除了我的 ~/.rbenv~/.gem Gemfile.lockvendor/bundle几次尝试重新开始。清除这些后,我尝试了以下操作:

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 文件,因为我尝试了几次。它似乎妨碍了。

关于ruby - Bundler 无法与 rbenv 一起工作,找不到 [gem],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9602806/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com