0

I am new to rails, so please feel free to suggest anything that might help

Gemfile is as follows

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

When I run sudo rake db:migrate on the terminal [for some reason, I need sudo everytime the time I run rake command], I get

Could not find tzinfo-1.2.1 in any of the sources Run bundle install to install missing gems.

I have tried removing the Gemfile.lock and running bundle install again, but it hasn't helped. I googled around and found no help.

When I ran bundle info tzinfo , it did give me a location

* 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

I tried all the suggested things as on this question but it didn't help

Ubuntu 16.04

sa77
  • 3,563
  • 3
  • 24
  • 37
ssumukh
  • 5
  • 4
  • Do you really need `sudo rake`? Have u tried without sudo ? – lcguida Sep 15 '17 at 15:21
  • You have a different environment when using sudo, your gempath may be different or unset. You shouldn't have to use sudo for rake to work, what error do you get from `rake db:migrate` without sudo? – Jacob Vanus Sep 15 '17 at 15:22
  • @JacobVanus I get this when I try without sudo rake aborted! Mysql2::Error: Access denied for user 'root'@'localhost' (using password: NO) Tasks: TOP => db:migrate (See full trace by running task with --trace) – ssumukh Sep 15 '17 at 15:54
  • @lcguida It says access denied. I am the only user. – ssumukh Sep 15 '17 at 15:55

1 Answers1

2

Don't use sudo...

Check you config/database.yml settings. That is how you get access to MySQL. Make sure the info is correct. example ....

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

Source: https://stackoverflow.com/a/5872284

Scott Monceaux
  • 349
  • 1
  • 6
  • When I execute rake db:migrate I get rake aborted! Mysql2::Error: Access denied for user 'root'@'localhost' (using password: YES) Tasks: TOP => db:migrate – ssumukh Sep 15 '17 at 19:02
  • I just built a test app with the specs above changing passwords and usernames. I created it successfully. I was able to generate your error message by using the wrong password. Make sure you have the correct password. Try accessing MySQL from the command line using mysql -u root -p and enter the password. If you can't access this way then you have the wrong password or the password isn't set. – Scott Monceaux Sep 15 '17 at 19:39