Nice programing

Windows에서 Rails v4.1.0 서버를 시작하는 동안 TZInfo :: DataSourceNotFound 오류

nicepro 2020. 11. 22. 20:35
반응형

Windows에서 Rails v4.1.0 서버를 시작하는 동안 TZInfo :: DataSourceNotFound 오류


Ruby on Rails v4.1.0을 사용하여 새 애플리케이션을 만들었습니다. Windows에서 서버 또는 콘솔을 시작하려고 할 때 다음 오류가 발생합니다.

$ rails server
Booting WEBrick
Rails 4.1.0 application starting in development on ....

Exiting
c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/data_source.rb:199:
in `rescue in create_default_data_source': 
No timezone data source could be found. To resolve this, either install 
TZInfo::Data (e.g. by running `gem install tzinfo-data`) or specify a zoneinfo 
directory using `TZInfo::DataSource.set(:zoneinfo, zoneinfo_path)`.
(TZInfo::DataSourceNotFound) 
from c:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/tzinfo-1.1.0/lib/tzinfo/data_source.rb:196:
in `create_default_data_source'

이 오류를 어떻게 해결할 수 있습니까?


오류 해결

이 오류를 해결하려면 tzinfo-data gem이 Gemfile.

먼저에 Gemfile대한 기존 참조가 있는지 확인하십시오 tzinfo-data. 아직 참조가 없으면 다음 줄을 추가합니다.

gem 'tzinfo-data'

다음과 같은 줄이 이미 있음을 알 수 있습니다.

gem 'tzinfo-data', platforms: [:mingw, :mswin]

Windows에서 64 비트 버전의 Ruby를 사용하는 경우 :x64_mingw다음과 같이 플랫폼 목록에 추가 합니다.

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]

또는 platforms옵션을 모두 제거 할 수 있습니다 .

그런 bundle update다음 명령 줄에서 실행 하여 tzinfo-data gem을 설치하면 Rails 서버 또는 콘솔을 시작할 수 있습니다.


배경

TZInfo::DataSourceNotFound오류는 Rails의 Active Support 구성 요소의 종속성 인 TZInfo에 의해 발생합니다. TZInfo가 시스템에서 시간대 데이터 소스를 찾고 있지만 찾지 못했습니다.

많은 Unix 기반 시스템 (예 : Linux)에서 TZInfo는 시스템 zoneinfo 디렉토리를 데이터 소스로 사용할 수 있습니다 . 그러나 Windows에는 이러한 디렉토리가 포함되어 있지 않으므로 대신 tzinfo-data gem을 설치해야합니다. tzinfo-data gem은 Ruby 모듈 세트로 패키지 된 동일한 zoneinfo 데이터를 포함합니다.

Rails Gemfile는 애플리케이션이 처음 생성 될 때 기본값을 생성합니다. 애플리케이션이 Windows에서 생성 된 경우 tzinfo-data에 대한 종속성이 포함됩니다. 그러나 (Rails 버전 4.1.0부터) 이것은 :x64_mingw플랫폼 목록에서 생략 되었으므로 64 비트 Windows 버전의 Ruby에서는 제대로 작동하지 않습니다. 이것은 고정해야 미래 레일 릴리스에서.


서버를 시작하려면 두 개의 gem을 추가해야했습니다 ..

gem 'tzinfo-
data'gem 'tzinfo'

그런 다음 번들 설치.


다음을 앱 터미널에 넣으십시오.

gem install tzinfo-data

그런 다음 gemfile 행을 다음과 같이 변경하십시오.

gem 'tzinfo-data', platforms: [:x64_mingw, :mingw, :mswin]

그런 다음 다시 터미널에서 :

bundle update

그러면 문제가 직접 해결됩니다.


Gem 파일에 다음 행을 추가하십시오.

gem 'tzinfo-data', 플랫폼 : [: x64_mingw, : mingw, : mswin]


Docker 컨테이너에 Redmine을 설치하려고 할 때 오류가 발생했습니다.

RAILS_ENV=production bundle exec rake db:migrate

gave me the error because package tzdata was not installed in my Ubuntu image.

apt-get update && apt-get install tzdata -y

did the trick.


Maybe tzinfo is not installed on your system, try to install it:

 gem install tzinfo
 gem install tzinfo-data

I had this problem too and fixed it by adding BOTH the :x64_mingw to the list of platforms for tzinfo-data, AND the gem 'tzinfo' to the gemfile. Then bundle install.


I ran into this issue on macOs Mojave 10.14.5 and I found out that it was something with how my symlink in macOs wasn't reading the correct provided zone info files.

I was able to track this down with where the files should be using the command TZInfo::ZoneinfoDataSource.search_path and that provided the output of ["/usr/share/zoneinfo", "/usr/share/lib/zoneinfo", "/etc/zoneinfo"].

I began looking into /usr/share/zoneinfo and there were files available to read. However rails still wasn't finding them, reading them, executing them..? So I then created a symlink from the other file in /usr/share/zoneinfo.default/ to /etc/zoneinfo (the last path TZInfo looks up)

So finally the command that worked for me to fix this issue was ln -s /usr/share/zoneinfo.default /etc/zoneinfo

Hopefully this information is helpful to someone in the future.


so, the gems didn't quite seem to install properly, i had to do the following

gem 'tzinfo-data' gem 'tzinfo'

then

bundle show to see all gems

bundle gem tzinfo will get you the gem's directory

then, go to that directory. you will need to splice tzinfo-data into tzinfo. in the tzinfo-data file, go to.. local_pathname/tzinfo-data-1.2014.5/lib/tzinfo copy all the contents of this directory into... local_pathname/tzinfo-1.2.1/lib/tzinfo (for me this meant copying 'data' the file and 'data' the directory)

then go to local_pathname/tzinfo-1.2.1/lib and open the file, tzinfo, (not the directory) and add this line require 'tzinfo/data'

this was such a pain to figure out

참고URL : https://stackoverflow.com/questions/23022258/tzinfodatasourcenotfound-error-starting-rails-v4-1-0-server-on-windows

반응형