While working on standing up a Rails app I ran into a pretty weird error that really had me scratching my head.
[mike@longshot identity-idp]$ rake db:create PG::InvalidParameterValue: ERROR: invalid value for parameter "TimeZone": "UTC" : SET time zone 'UTC' Couldn't create database for {"pool"=>5, "timeout"=>5000, "host"=>"localhost", "adapter"=>"postgresql", "encoding"=>"utf8", "database"=>"upaya_development", "port"=>5432} rake aborted! ActiveRecord::StatementInvalid: PG::InvalidParameterValue: ERROR: invalid value for parameter "TimeZone": "UTC" : SET time zone 'UTC' PG::InvalidParameterValue: ERROR: invalid value for parameter "TimeZone": "UTC" Tasks: TOP => db:create (See full trace by running task with --trace)
The output of timedatectl status
looked OK, but just to be sure, I updated them to EDT. No difference. When I tried rake db:migrate
I got a far more instructive error:
[mike@longshot identity-idp]$ rake db:migrate rake aborted! ArgumentError: Invalid Timezone: UTC /home/mike/projects/identity-idp/config/environment.rb:5:in `<top (required)>' TZInfo::InvalidTimezoneIdentifier: Expected 44 bytes reading '/usr/share/zoneinfo/UTC', but got 0 bytes /home/mike/projects/identity-idp/config/environment.rb:5:in `<top (required)>' TZInfo::InvalidZoneinfoFile: Expected 44 bytes reading '/usr/share/zoneinfo/UTC', but got 0 bytes /home/mike/projects/identity-idp/config/environment.rb:5:in `<top (required)>' Tasks: TOP => log => environment (See full trace by running task with --trace)
/usr/share/zoneinfo/UTC
is 0 bytes? A quick looks shows it to be true, and the package that supplied this file is tzdata
.
[mike@longshot identity-idp]$ cat /usr/share/zoneinfo/UTC [mike@longshot identity-idp]$ ls -l /usr/share/zoneinfo/UTC -rw-r--r-- 6 root root 0 Jul 26 18:01 /usr/share/zoneinfo/UTC [mike@longshot identity-idp]$ pacman -Qo /usr/share/zoneinfo/UTC /usr/share/zoneinfo/UTC is owned by tzdata 2017b-1
That doesn’t seem right, let’s reinstall…
[mike@longshot identity-idp]$ sudo pacman -S tzdata warning: tzdata-2017b-1 is up to date -- reinstalling resolving dependencies... looking for conflicting packages... Packages (1) tzdata-2017b-1 Total Installed Size: 1.81 MiB Net Upgrade Size: 0.00 MiB :: Proceed with installation? [Y/n] y (1/1) checking keys in keyring [###########################################] 100% (1/1) checking package integrity [###########################################] 100% (1/1) loading package files [###########################################] 100% (1/1) checking for file conflicts [###########################################] 100% (1/1) checking available disk space [###########################################] 100% :: Processing package changes... (1/1) reinstalling tzdata [###########################################] 100% :: Running post-transaction hooks... (1/1) Arming ConditionNeedsUpdate... [mike@longshot identity-idp]$ ls -l /usr/share/zoneinfo/UTC -rw-r--r-- 6 root root 127 Mar 24 12:38 /usr/share/zoneinfo/UTC [mike@longshot identity-idp]$ cat /usr/share/zoneinfo/UTC TZif2UTCTZif2�UTC UTC0
After that, creating and migrating worked again without problems. I’m not sure what happened there, but hopefully this will prevent people (or future me) wasting a bunch more time on it.
Advertisements