首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何解决"TZInfo::DataSourceNotFound: tzinfo-data不存在“。

如何解决"TZInfo::DataSourceNotFound: tzinfo-data不存在“。
EN

Stack Overflow用户
提问于 2022-02-15 14:47:46
回答 1查看 1.5K关注 0票数 1

我们正在使用CircleCI实现CI。

在下面的运行中,我得到了一个关于tzinfo-数据的错误,并且我无法进入测试。

我编写了一个运行程序来安装tzinfo-数据,但是它没有工作。我完全被困住了。

config.yml

代码语言:javascript
复制
- run:
    name: Database setup
    command: |
      bundle exec rails db:create
      bundle exec rails db:migrate

错误

代码语言:javascript
复制
rake aborted!
TZInfo::DataSourceNotFound: tzinfo-data is not present. Please add gem 'tzinfo-data' to your Gemfile and run bundle install

config.yml:

代码语言:javascript
复制
version: 2.1
orbs:
  ruby: circleci/ruby@1.1.2

jobs:
  build:
    docker:
      - image: cimg/ruby:2.6.5
    working_directory: ~/myapp/web
    steps:
      - checkout:
          path: ~/myapp
      - restore_cache:
          name: bundle install restore
          keys:
            - v1-dependencies-{{ checksum "Gemfile.lock" }}
            - v1-dependencies-
      - run:
          name: default mysql client install
          command: |
            sudo apt update
            sudo apt-get install default-mysql-client
            sudo apt-get install libmysqlclient-dev
      - run:
          name: bundle Install
          command: bundle check --path=vendor/bundle || bundle install --jobs=4 --retry=3 --path vendor/bundle
      - save_cache:
          name: bundle install save
          paths:
            - ./vendor/bundle
          key: v1-dependencies-{{ checksum "Gemfile.lock" }}
  test:
    docker:
      - image: cimg/ruby:2.6.5
      - image: circleci/mysql:5.7
        environment:
          DB_DATABASE: app_test
          DB_PASSWORD: password
          DB_USER: root
          TZ: "Asia/Tokyo"
    environment:
      BUNDLE_JOBS: "3"
      BUNDLE_RETRY: "3"
      APP_DATABASE_HOST: "127.0.0.1"
      RAILS_ENV: test
      TZ: "Asia/Tokyo"
    working_directory: ~/myapp/web
    steps:
      - checkout:
          path: ~/myapp
      - restore_cache:
          name: bundle install restore
          key: v1-dependencies-{{ checksum "Gemfile.lock" }}
      - run:
          name: default mysql client install
          command: |
            sudo apt update
            sudo apt-get install default-mysql-client
            sudo apt-get install libmysqlclient-dev
      - run:
          name: bundle install
          command: bundle check --path=vendor/bundle || bundle install --path vendor/bundle --clean --jobs 4 --retry 3
      - run:
          name: Database setup
          command: |
            bundle exec rails db:create
            bundle exec rails db:migrate
      - run:
          name: Echo Test
          command: echo "CircleCI Test"
      - run:
          name: test
          command: bundle exec rake test

workflows:
  version: 2
  build_and_test:
    jobs:
      - build
      - test:
          requires:
            - build

Gemfile:

代码语言:javascript
复制
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.6.5'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.7'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.4.4'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# jQuery
gem "jquery-rails"
gem 'rails-i18n', '~> 6'
# enum i18n
gem "enum_help"
gem "config"
gem 'faraday'

gem 'acts_as_paranoid', '~> 0.6.0'

gem 'http-cookie'

gem 'kaminari'

gem 'devise'
gem 'devise_token_auth'
gem 'devise-security'
gem 'devise-two-factor', '~> 3.1'

# AWS
gem 'aws-sdk'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

gem 'composite_primary_keys'

gem 'clamav-client', require: 'clamav/client'

gem 'wovnrb'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
end

group :test do
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '>= 2.15'
  gem 'selenium-webdriver'
  # Easy installation and use of web drivers to run system tests with browsers
  gem 'webdrivers'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

我试过(1)

我试图将tzinfo添加到Gemfile中,如下所示,但是我得到了相同的错误。

代码语言:javascript
复制
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'tzinfo', '1.2.9'

捆绑安装

Gemfile.lock

代码语言:javascript
复制
DEPENDENCIES
...
  tzinfo (= 1.2.9)
  tzinfo-data

与circleCI一起运行

相同误差

我试过(2)

将tzinfo宝石安装为运行config.yml

代码语言:javascript
复制
- run:
    name: tzinfo install
    command: |
      gem install tzinfo -v "~> 1.2.9"
      gem install tzinfo-data

与circleCI一起运行

相同误差

EN

回答 1

Stack Overflow用户

发布于 2022-02-16 06:30:51

在包安装之后,我添加了以下内容并能够运行

代码语言:javascript
复制
- run:
  name: RUN apt install tzdata
  command: sudo apt install tzdata
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71128463

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档