RubyChina 的下载,MongoDB、Redis、Memcached 等的安装略过。
下载后,bundle 好之后,ruby setup.rb
时遇到如下问题:
ruby-china git:(master) ✗ >ruby setup.rb
Now Installing Ruby China...
================================================================================
Checking Package Dependencies...
--------------------------------------------------------------------------------
Bundler [Yes]
MongoDB 2.0+ [Yes]
Redis 2.0+ [Yes]
Memcached 1.4+ [Yes]
ImageMagick 6.5+ [Yes]
--------------------------------------------------------------------------------
Configure
--------------------------------------------------------------------------------
Your MongoDB host (default: 127.0.0.1:27017):
Your Redis host (default: 127.0.0.1:6379):
--------------------------------------------------------------------------------
Install gems... [Done]
Seed default data...rake aborted!
uninitialized constant BSON
/home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/bundler/gems/mongoid-9b3bc1264032/lib/mongoid/extensions.rb:2:in `<top (required)>'
/home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/bundler/gems/mongoid-9b3bc1264032/lib/mongoid/document.rb:4:in `<top (required)>'
/home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/bundler/gems/mongoid-9b3bc1264032/lib/mongoid.rb:21:in `<top (required)>'
/home/vagrant/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require'
/home/vagrant/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
/home/vagrant/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `each'
/home/vagrant/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `block in require'
/home/vagrant/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `each'
/home/vagrant/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `require'
/home/vagrant/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.5.2/lib/bundler.rb:131:in `require'
/home/vagrant/ruby-china/config/application.rb:11:in `<top (required)>'
/home/vagrant/ruby-china/Rakefile:4:in `require'
/home/vagrant/ruby-china/Rakefile:4:in `<top (required)>'
/home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/bin/ruby_executable_hooks:15:in `eval'
/home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)
[Done]
Ruby China Successfully Installed.
看到了Ruby China Successfully Installed.
我窃以为安装成功了,然后直接运行rails s
,结果又报和上面一样的错误。日志如下:
ruby-china git:(master) ✗ >rails s
/home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/bundler/gems/mongoid-9b3bc1264032/lib/mongoid/extensions.rb:2:in `<top (required)>': uninitialized constant BSON (NameError)
from /home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/bundler/gems/mongoid-9b3bc1264032/lib/mongoid/document.rb:4:in `<top (required)>'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/bundler/gems/mongoid-9b3bc1264032/lib/mongoid.rb:21:in `<top (required)>'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `each'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `block in require'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `each'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `require'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.5.2/lib/bundler.rb:131:in `require'
from /home/vagrant/ruby-china/config/application.rb:11:in `<top (required)>'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/gems/railties-4.0.2/lib/rails/commands.rb:74:in `require'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/gems/railties-4.0.2/lib/rails/commands.rb:74:in `block in <top (required)>'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap'
from /home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
然后,搜问题解答,搜到如下解决方法:
uninitialized constant BSON::ByteBuffer (Heroku)
安装所述,在Gemfile
中,增加如下一行
gem "bson", "~> 2.2.0"
然后,运行运行bundle
命令,但是却报如下错误:
ruby-china git:(master) ✗ >bundle
Fetching source index from http://ruby.taobao.org/
Resolving dependencies...
Bundler could not find compatible versions for gem "moped":
In snapshot (Gemfile.lock):
moped (1.5.0)
In Gemfile:
mongoid (>= 0) ruby depends on
moped (~> 2.0.beta3) ruby
Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
根据提示,我运行了bundle update
命令,结果又报如下错误:
ruby-china git:(master) ✗ >bundle update
Updating git://github.com/mongoid/mongoid.git
Updating git://github.com/huacnlee/bootstrap-helper.git
Updating git://github.com/intridea/grape.git
fatal: ambiguous argument 'frontier': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
Retrying git rev-parse frontier due to error (2/3): Bundler::Source::Git::GitCommandError Git error: command `git rev-parse frontier` in directory /home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/cache/bundler/git/grape-c77c5fb0336b00082cc45f4584f3dddedc8cb513 has failed.
If this error persists you could try removing the cache directory '/home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/cache/bundler/git/grape-c77c5fb0336b00082cc45f4584f3dddedc8cb513'
fatal: ambiguous argument 'frontier': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
Retrying git rev-parse frontier due to error (3/3): Bundler::Source::Git::GitCommandError Git error: command `git rev-parse frontier` in directory /home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/cache/bundler/git/grape-c77c5fb0336b00082cc45f4584f3dddedc8cb513 has failed.
If this error persists you could try removing the cache directory '/home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/cache/bundler/git/grape-c77c5fb0336b00082cc45f4584f3dddedc8cb513'
fatal: ambiguous argument 'frontier': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
Git error: command `git rev-parse frontier` in directory /home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/cache/bundler/git/grape-c77c5fb0336b00082cc45f4584f3dddedc8cb513 has failed.
If this error persists you could try removing the cache directory '/home/vagrant/.rvm/gems/ruby-2.0.0-p247@ruby-china/cache/bundler/git/grape-c77c5fb0336b00082cc45f4584f3dddedc8cb513'
我查了一下 Grape 的 Github 页面,确实没有frontier
的分支了。但是,不知道为什么 RubyChina 的Gemfiel
文件中没有更新?
我把 Grape 的声明方式修改为gem 'grape'
了,目前执行bundle update
,但是却报如下错误:
ruby-china git:(master) ✗ >bundle update
Updating git://github.com/mongoid/mongoid.git
Updating git://github.com/huacnlee/bootstrap-helper.git
Updating git://github.com/searls/jasmine-rails.git
Fetching source index from http://ruby.taobao.org/
Resolving dependencies...
Bundler could not find compatible versions for gem "actionpack":
In Gemfile:
rails (= 4.0.2) ruby depends on
actionpack (= 4.0.2) ruby
actionpack-action_caching (= 1.0.0) ruby depends on
actionpack (4.1.0.beta1)
gem bson
解决了;bundle update
,但是目前还没有跑通过。还要再看看;gem 'grape'
,而不是走 Github 分支,可以了;求解答。