我正在尝试2天用Rails 4设置Mongodb。 我的Gemfile中有以下宝石:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
gem 'mongoid', github: 'mongoid/mongoid'
gem 'bson_ext'
gem 'mongo_mapper'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
当我在我的osx shell上尝试bundle install
时,我有以下几行:
Updating git://github.com/mongoid/mongoid.git
Fetching source index from https://rubygems.org/
Could not fetch specs from https://rubygems.org/
我尝试了几个版本的mongoid gem,但没有任何东西使rails generate mongoid:config
命令工作。
有任何线索吗?
修改
这是捆绑安装--verbose trace
Updating git://github.com/mongoid/mongoid.git
Fetching from: https://rubygems.org/api/v1/dependencies
Fetching source index from https://rubygems.org/
Gem::RemoteFetcher::UnknownHostError: no such name (https://rubygems.org/specs.4.8.gz)
/Users/xxx/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/remote_fetcher.rb:283:in `rescue in fetch_path'
/Users/xxx/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/remote_fetcher.rb:258:in `fetch_path'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:454:in `fetch_specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:468:in `block in fetch_all_remote_specs'
/Users/xxx/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/source_list.rb:90:in `block in each'
/Users/xxx/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/source_list.rb:90:in `each'
/Users/xxx/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/source_list.rb:90:in `each'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:466:in `fetch_all_remote_specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/fetcher.rb:262:in `fetch_all_remote_specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/fetcher.rb:116:in `specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:228:in `block in remote_specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:228:in `each'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:228:in `remote_specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:163:in `fetch_specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:67:in `specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/definition.rb:192:in `block (2 levels) in index'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/definition.rb:189:in `each'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/definition.rb:189:in `block in index'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/index.rb:9:in `build'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/definition.rb:185:in `index'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/definition.rb:179:in `resolve'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/definition.rb:109:in `resolve_remotely!'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/installer.rb:83:in `run'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/installer.rb:14:in `install'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/cli.rb:247:in `install'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/vendor/thor/task.rb:27:in `run'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/vendor/thor.rb:344:in `dispatch'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/vendor/thor/base.rb:434:in `start'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/bin/bundle:20:in `block in <top (required)>'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/friendly_errors.rb:3:in `with_friendly_errors'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/bin/bundle:20:in `<top (required)>'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/bin/bundle:23:in `load'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/bin/bundle:23:in `<main>'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/bin/ruby_executable_hooks:15:in `eval'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/bin/ruby_executable_hooks:15:in `<main>'
Could not fetch specs from https://rubygems.org/
Bundler::HTTPError: Could not fetch specs from https://rubygems.org/
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/fetcher.rb:268:in `rescue in fetch_all_remote_specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/fetcher.rb:261:in `fetch_all_remote_specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/fetcher.rb:116:in `specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:228:in `block in remote_specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:228:in `each'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:228:in `remote_specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:163:in `fetch_specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:67:in `specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/definition.rb:192:in `block (2 levels) in index'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/definition.rb:189:in `each'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/definition.rb:189:in `block in index'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/index.rb:9:in `build'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/definition.rb:185:in `index'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/definition.rb:179:in `resolve'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/definition.rb:109:in `resolve_remotely!'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/installer.rb:83:in `run'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/installer.rb:14:in `install'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/cli.rb:247:in `install'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/vendor/thor/task.rb:27:in `run'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/vendor/thor.rb:344:in `dispatch'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/vendor/thor/base.rb:434:in `start'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/bin/bundle:20:in `block in <top (required)>'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/lib/bundler/friendly_errors.rb:3:in `with_friendly_errors'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/gems/bundler-1.3.5/bin/bundle:20:in `<top (required)>'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/bin/bundle:23:in `load'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/bin/bundle:23:in `<main>'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/bin/ruby_executable_hooks:15:in `eval'
/Users/xxx/.rvm/gems/ruby-1.9.3-p448@global/bin/ruby_executable_hooks:15:in `<main>'
正在运行bundle update
给我:
Using mongoid (4.0.0.beta1) from git://github.com/mongoid/mongoid.git (at master)
Gem::FilePermissionError: You don't have write permissions for the /Users/xxx/.rvm/gems/ruby-1.9.3-p448/bin directory.
An error occurred while installing mongoid (4.0.0.beta1), and Bundler cannot continue.
Make sure that `gem install mongoid -v '4.0.0.beta1'` succeeds before bundling.
答案 0 :(得分:2)
我之前遇到过这个问题。在我的情况下,我刚从该行的https
中删除了 s :
source 'http://rubygems.org'
并在gemfile中添加以下行:
source 'http://gems.github.com'
它解决了我的问题。我不知道为什么。但幸运的是它有效。 :d
答案 1 :(得分:0)
这也可能是暂时的网络问题。
尝试使用命令重新启动网络服务。
service network restart
如果是* nix机器。