【问题标题】:Using Mongoid with Rails 4在 Rails 4 中使用 Mongoid
【发布时间】:2026-02-09 03:05:02
【问题描述】:

我想在我的 rails 项目中使用 Mongoid,但 gem 'mongoid' 安装了 1.0.6 版。我尝试使用gem 'mongoid', github: 'mongoid/mongoid',但运行bundle install 会产生此错误:

Fetching git://github.com/mongoid/mongoid.git
Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/source/git/git_proxy.rb:88:in ``': No such file or directo
ry - git clone "git://github.com/mongoid/mongoid.git" "C:/Ruby200/lib/ruby/gems/2.0.0/cache/bundler/git/mongoid-176c799a
8a4589043b073e277e545d697119fa82" --bare --no-hardlinks (Errno::ENOENT)
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/source/git/git_proxy.rb:88:in `git'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/source/git/git_proxy.rb:49:in `checkout'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/source/git.rb:144:in `specs'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/definition.rb:493:in `block in converge_locke
d_specs'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/definition.rb:482:in `each'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/definition.rb:482:in `converge_locked_specs'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/definition.rb:167:in `resolve'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/definition.rb:109:in `resolve_remotely!'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/installer.rb:83:in `run'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/installer.rb:14:in `install'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/cli.rb:247:in `install'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/vendor/thor/task.rb:27:in `run'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task
'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/vendor/thor.rb:344:in `dispatch'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/vendor/thor/base.rb:434:in `start'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/bin/bundle:20:in `block in <top (required)>'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/friendly_errors.rb:3:in `with_friendly_errors
'
        from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/bin/bundle:20:in `<top (required)>'
        from C:/Ruby200/bin/bundle:23:in `load'
        from C:/Ruby200/bin/bundle:23:in `<main>'

【问题讨论】:

    标签: ruby-on-rails-4 mongoid


    【解决方案1】:

    我怀疑错误是因为您没有安装 Git。有关设置的帮助,请参阅本教程:https://help.github.com/articles/set-up-git#platform-windows

    【讨论】:

      【解决方案2】:

      试试gem install mongoid它应该可以让你直接安装mongoid gem,而不需要通过bundler

      然后尝试再次运行bundle

      【讨论】:

      • 不行,还是安装1.0.6版,已经3岁了