我提前为我的无知道歉,但是当我跑步时我遇到了这个问题
"rake db:create:all"
在我的终端。
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/shared_helpers.rb:3.
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/source.rb:162.
NOTE: Gem::SourceIndex#each is deprecated with no replacement. It will be removed on or after 2011-11-01.
Gem::SourceIndex#each called from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/source.rb:162.
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/shared_helpers.rb:84.
WARNING: This version of mysql2 (0.3.7) doesn't ship with the ActiveRecord adapter bundled anymore as it's now part of Rails 3.1
WARNING: Please use the 0.2.x releases if you plan on using it in Rails <= 3.0.x
WARNING: 'require 'rake/rdoctask'' is deprecated. Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
at /usr/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Couldn't create database for {"username"=>"root", "adapter"=>"mysql", "database"=>"testApp", "host"=>"localhost", "password"=>"mysql"}, charset: utf8, collation: utf8_unicode_ci
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Couldn't create database for {"username"=>"root", "adapter"=>"mysql", "database"=>"testApp", "host"=>"localhost", "password"=>"mysql"}, charset: utf8, collation: utf8_unicode_ci
我跟随列昂尼德谢夫佐夫
我的第二个问题:当我bundle update
时,它会是这样的:
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/shared_helpers.rb:3.
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/source.rb:162.
NOTE: Gem::SourceIndex#each is deprecated with no replacement. It will be removed on or after 2011-11-01.
Gem::SourceIndex#each called from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/source.rb:162.
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/source.rb:162.
NOTE: Gem::SourceIndex#each is deprecated with no replacement. It will be removed on or after 2011-11-01.
Gem::SourceIndex#each called from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/source.rb:162.
Fetching source index for http://rubygems.org/
Enter your password to install the bundled RubyGems to your system:
/usr/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:122:in `initialize': no metadata found in /usr/lib/ruby/gems/1.8/cache/rake-0.9.2.2.gem (Gem::Package::FormatError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:20:in `new'
from /usr/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.rb:20:in `open'
from /usr/lib/ruby/site_ruby/1.8/rubygems/package.rb:44:in `open'
from /usr/lib/ruby/site_ruby/1.8/rubygems/format.rb:62:in `from_io'
from /usr/lib/ruby/site_ruby/1.8/rubygems/format.rb:46:in `from_file_by_path'
from /usr/lib/ruby/1.8/open-uri.rb:32:in `open_uri_original_open'
from /usr/lib/ruby/1.8/open-uri.rb:32:in `open'
from /usr/lib/ruby/site_ruby/1.8/rubygems/format.rb:45:in `from_file_by_path'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/source.rb:73:in `fetch'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/installer.rb:45:in `run'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/installer.rb:44:in `run'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/installer.rb:8:in `install'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/cli.rb:226:in `install'
from /usr/lib/ruby/gems/1.8/gems/thor-0.14.6/lib/thor/task.rb:22:in `send'
from /usr/lib/ruby/gems/1.8/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
from /usr/lib/ruby/gems/1.8/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
from /usr/lib/ruby/gems/1.8/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
from /usr/lib/ruby/gems/1.8/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/bin/bundle:13
from /usr/bin/bundle:19:in `load'
from /usr/bin/bundle:19'
我似乎无法在没有错误的情况下运行捆绑更新。我用Fedora 15和Mysql 5.5运行我的机器。
再次感谢,我为自己的无知而道歉;我是Rails的新手。
提前致谢! :)
答案 0 :(得分:3)
看起来您应该在Gemfile中限制mysql2
版本:
gem 'mysql2', '~>0.2.0'
[编辑] ...然后执行bundle install
,当然
答案 1 :(得分:0)
正如我们在日志中看到的,我认为你已经在config / database.yml中指定了mysql作为适配器
将其更改为:
adapter: mysql2
编辑:
关于你的FormatError,我知道我必须使用:
bundle exec rake db:<command>
为了现在执行rake,你能尝试一下吗?
编辑2:
好吧,我建议您使用RVM来使用ruby 1.9.2设置项目。 Read RVM Doc可以轻松指导如何操作。
然后进行捆绑安装
之后,请确保:
ruby -v
它应该是1.9.2
然后重试你的db:像这样创建:
bundle exec rake db:create:all
希望它最终会奏效。 ; - )
答案 2 :(得分:0)
要删除rubygems弃用警告更新到最新的RubyGems版本并运行
gem pristine --all --no-extensions
。
至于你的mysql错误。确保已启用MySQL服务/守护程序,并确保您的database.yml配置文件正确。