rake db:迁移错误。请求tzinfo-1.2.1

时间:2017-09-15 15:04:01

标签: ruby-on-rails ruby rake ruby-on-rails-5 tzinfo

我是rails的新手,所以请随时提出可能有用的建议

Gemfile如下

source 'https://rubygems.org'
git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include("/")
  "https://github.com/#{repo_name}.git"
end
gem 'rails', '~> 5.1.4'
gem 'mysql2', '0.4.9'
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'bootstrap-sass'
gem 'devise'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'bcrypt', '~> 3.1.7'
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]
gem 'tzinfo',       '1.2.1'


group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

当我在终端上运行sudo rake db:migrate [出于某种原因,每次运行rake命令时我都需要sudo],我得到了

  

在任何来源中找不到tzinfo-1.2.1运行bundle install   安装缺少的宝石。

我已经尝试删除Gemfile.lock并再次运行bundle install,但它没有帮助。我用Google搜索,没有找到任何帮助。

当我运行bundle info tzinfo时,它确实给了我一个位置

* tzinfo (1.2.1)
    Summary: Daylight savings aware timezone library
    Homepage: http://tzinfo.github.io
    Path: /home/t430/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/tzinfo-1.2.1

我在this question上尝试了所有建议的内容,但它没有帮助

Ubuntu 16.04

1 个答案:

答案 0 :(得分:2)

不要使用sudo ......

检查config / database.yml设置。这就是你如何访问MySQL。确保信息正确无误。例子....

development:
  adapter: mysql2
  encoding: utf8
  database: my_db_name
  username: root
  password: my_password
  host: 127.0.0.1
  port: 3306

来源:https://stackoverflow.com/a/5872284