Невозможно развернуть приложение rails на Heroku - PullRequest
0 голосов
/ 13 мая 2018

Я пытаюсь развернуть приложение rails на heroku, но из-за постоянных ошибок когда я делаю "git push heroku master", я не смог этого сделать. Ошибка появляется следующим образом:

$ git push heroku master
Counting objects: 8942, done.

Delta compression using up to 4 threads.
Compressing objects: 100% (8320/8320), done.
Writing objects: 100% (8942/8942), 38.02 MiB | 1.59 MiB/s, done.
Total 8942 (delta 1019), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote:  !     Warning: Multiple default buildpacks reported the abi
lity to handle this app. The first buildpack in the list below will
be used.
remote:                         Detected buildpacks: Ruby,Node.js
remote:                         See https://devcenter.heroku.com/art
icles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.3.7
remote: -----> Installing dependencies using bundler 1.15.2
remote:        Running: bundle install --without development:test --
path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Warning: the running version of Bundler (1.15.2) is o
lder than the version that created the lockfile (1.16.1). We suggest
 you upgrade to the latest version of Bundler by running `gem instal
l bundler`.
remote:        Fetching gem metadata from https://rubygems.org/.....
...
remote:        Fetching version metadata from https://rubygems.org/.
.
remote:        Fetching dependency metadata from https://rubygems.or
g/.
remote:        Fetching rake 12.3.1
remote:        Fetching concurrent-ruby 1.0.5
remote:        Fetching minitest 5.11.3
remote:        Installing rake 12.3.1
(...)
remote:        Installing activesupport 5.1.6
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem nati
ve extension.
remote:
remote:        current directory:
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/bu
ndle/ruby/2.3.0/gems/sqlite3-1.3.13/ext/sqlite3
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/ru
by-2.3.7/bin/ruby -r
remote:        ./siteconf20180513-253-1utdlov.rb extconf.rb
remote:        checking for sqlite3.h... no
remote:        sqlite3.h is missing. Try 'brew install sqlite3',
remote:        'yum install sqlite-devel' or 'apt-get install libsql
ite3-dev'
remote:        and check your shared library search path (the
remote:        location where your sqlite3 shared library is located
).
remote:        *** extconf.rb failed ***
remote:        Could not create Makefile due to some reason, probabl
y lack of necessary
remote:        libraries and/or headers.  Check the mkmf.log file fo
r more details.  You may
remote:        need configuration options.
remote:
remote:        Provided configuration options:
remote:         --with-opt-dir
remote:         --without-opt-dir
remote:         --with-opt-include
remote:         --without-opt-include=${opt-dir}/include
remote:         --with-opt-lib
remote:         --without-opt-lib=${opt-dir}/lib
remote:         --with-make-prog
remote:         --srcdir=.

remote:         --curdir
remote:        --ruby=/tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/ve
ndor/ruby-2.3.7/bin/$(RUBY_BASE_NAME)
remote:         --with-sqlite3-config
remote:         --without-sqlite3-config
remote:         --with-pkg-config
remote:         --without-pkg-config
remote:         --with-sqlite3-dir
remote:         --without-sqlite3-dir
remote:         --with-sqlite3-include
remote:         --without-sqlite3-include=${sqlite3-dir}/include
remote:         --with-sqlite3-lib
remote:         --without-sqlite3-lib=${sqlite3-dir}/lib
remote:
remote:        To see why this extension failed to compile, please c
heck the mkmf.log which can
remote:        be found here:
remote:
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/bu
ndle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/mkmf.lo
g
remote:
remote:        extconf failed, exit code 1
remote:
remote:        Gem files will remain installed in
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/bu
ndle/ruby/2.3.0/gems/sqlite3-1.3.13
remote:        for inspection.
remote:        Results logged to
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/bu
ndle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/gem_mak
e.out
remote:
remote:        An error occurred while installing sqlite3 (1.3.13),
and Bundler cannot
remote:        continue.
remote:        Make sure that `gem install sqlite3 -v '1.3.13'` succ
eeds before bundling.
remote:
remote:        In Gemfile:
remote:          sqlite3
remote:        Bundler Output: Warning: the running version of Bundl
er (1.15.2) is older than the version that created the lockfile (1.1
6.1). We suggest you upgrade to the latest version of Bundler by run
ning `gem install bundler`.
remote:        Fetching gem metadata from https://rubygems.org/.....
...
remote:        Fetching version metadata from https://rubygems.org/.
.
remote:        Fetching dependency metadata from https://rubygems.or
g/.
remote:        Fetching rake 12.3.1
remote:        Fetching concurrent-ruby 1.0.5
(...)
remote:        Installing activesupport 5.1.6
remote:        Gem::Ext::BuildError: ERROR: Failed to build gem nati
ve extension.
remote:
remote:        current directory:
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/bu
ndle/ruby/2.3.0/gems/sqlite3-1.3.13/ext/sqlite3
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/ru
by-2.3.7/bin/ruby -r
remote:        ./siteconf20180513-253-1utdlov.rb extconf.rb
remote:        checking for sqlite3.h... no
remote:        sqlite3.h is missing. Try 'brew install sqlite3',
remote:        'yum install sqlite-devel' or 'apt-get install libsql
ite3-dev'
remote:        and check your shared library search path (the
remote:        location where your sqlite3 shared library is located
).
remote:        *** extconf.rb failed ***
remote:        Could not create Makefile due to some reason, probabl
y lack of necessary
remote:        libraries and/or headers.  Check the mkmf.log file fo
r more details.  You may
remote:        need configuration options.
remote:
remote:        Provided configuration options:
remote:         --with-opt-dir
remote:         --without-opt-dir
remote:         --with-opt-include
remote:         --without-opt-include=${opt-dir}/include
remote:         --with-opt-lib
remote:         --without-opt-lib=${opt-dir}/lib
remote:         --with-make-prog
remote:         --without-make-prog
remote:         --srcdir=.
remote:         --curdir
remote:        --ruby=/tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/ve
ndor/ruby-2.3.7/bin/$(RUBY_BASE_NAME)
remote:         --with-sqlite3-config
remote:         --without-sqlite3-config
remote:         --with-pkg-config
remote:         --without-pkg-config
remote:         --with-sqlite3-dir
remote:         --without-sqlite3-dir
remote:         --with-sqlite3-include
remote:         --without-sqlite3-include=${sqlite3-dir}/include
remote:         --with-sqlite3-lib
remote:         --without-sqlite3-lib=${sqlite3-dir}/lib
remote:
remote:        To see why this extension failed to compile, please c
heck the mkmf.log which can
remote:        be found here:
remote:
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/bu
ndle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/mkmf.lo
g
remote:
remote:        extconf failed, exit code 1
remote:
remote:        Gem files will remain installed in
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/bu
ndle/ruby/2.3.0/gems/sqlite3-1.3.13
remote:        for inspection.
remote:        Results logged to
remote:        /tmp/build_cffd92476daf50cbcc0ddddd7e5ac406/vendor/bu
ndle/ruby/2.3.0/extensions/x86_64-linux/2.3.0/sqlite3-1.3.13/gem_mak
e.out
remote:
remote:        An error occurred while installing sqlite3 (1.3.13),
and Bundler cannot
remote:        continue.
remote:        Make sure that `gem install sqlite3 -v '1.3.13'` succ
eeds before bundling.
remote:
remote:        In Gemfile:
remote:          sqlite3
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !     Detected sqlite3 gem which is not supported on Heroku
:
remote:  !     https://devcenter.heroku.com/articles/sqlite3
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to XXXXX.
remote:
To https://git.heroku.com/XXXXX.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/XXXXX.git'

Мой 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


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.6'

group :production do
  gem 'pg'
end

# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# 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.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

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]
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '~> 2.13'
  gem 'selenium-webdriver'

  gem 'pry-rails'  
  gem 'pry-doc'    
  gem 'pry-byebug' 
  gem 'pry-stack_explorer' 
  gem 'hirb'         
  gem 'hirb-unicode' 
  gem 'better_errors'
  gem "binding_of_caller"

  # Use sqlite3 as the database for Active Record
  gem 'sqlite3', require: false
end

group :development do
  # Access an IRB console on exception pages or by using <%= 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

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

gem 'devise'

gem 'omniauth-facebook'

gem 'dotenv-rails', require: 'dotenv/rails-now'

gem 'thin'

gem 'carrierwave'

gem 'rails-erd'

gem 'jquery-rails'

Я начинающий разработчик ruby-on-rails и совершенно не знаю, что делать, чтобы решить эту проблему. Любая помощь так ценится!

Ответы [ 3 ]

0 голосов
/ 14 мая 2018

Задокументировано на сайте Heroku. (https://devcenter.heroku.com/articles/sqlite3#getting-a-sqlite-error-even-though-it-is-not-in-the-gemfile). Ваш файл database.yml должен выглядеть следующим образом:

development:
 adapter: postgresql
 database: my_database_development
 pool: 5
 timeout: 5000

test:
 adapter: postgresql
 database: my_database_test
 pool: 5
 timeout: 5000

production:
 adapter: postgresql
 database: my_database_production
 pool: 5
 timeout: 5000

После внесения этих изменений обязательно выполните следующие команды:

rake db:create
rake db:migrate

Теперь вам нужно git add и git commit -m postgres. Если после выполнения всех этих шагов вы все еще получаете ошибку, вам, возможно, придется испачкать руки и провести некоторое расследование, поскольку один из драгоценных камней, имеющихся в вашем гемфайле, вполне может использовать SQL в качестве зависимости. Начните с просмотра вашего Gemfile.lock. Пожалуйста, смотрите ниже:

Получение ошибки SQLite, даже если ее нет в Gemfile: Если вы удалили строку gem 'sqlite3' из своего Gemfile и по-прежнему получаете ошибки при развертывании в Heroku, вполне вероятно, что другой используемый вами гем имеет sqlite3 в качестве зависимости. Чтобы найти источник этой зависимости, загляните в свой Gemfile.lock для sqlite3. Найдите гем с зависимостью от sqlite3 и удалите его из своего Gemfile. Выполнив эту установку, запустите пакет и убедитесь, что sqlite3 больше не существует в вашем Gemfile.lock.

Надеюсь, это поможет.

0 голосов
/ 14 мая 2018

О, наконец, получается, что проблема решена! Я был в отделе разработки моего git, и когда я слил его в master и провел git push heroku master, все прошло хорошо. Я не понимал, что проблема была вызвана простым фактором, пока я не прочитал ниже. Большое спасибо за вашу помощь!

c.f. Heroku устанавливает sqlite3, хотя это не является зависимостью

0 голосов
/ 13 мая 2018

Сначала убедитесь, что у вас есть правильный гемфайл, он должен выглядеть примерно так:

group :production do  
  gem 'pg'
end

run

bundle install

Editin config / database.yml

development:
 adapter: sqlite3
 database: db/development.sqlite3
 pool: 5
 timeout: 5000

test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: postgresql
  database: my_database_production
  pool: 5
  timeout: 5000

и наконец зафиксируйте изменения

git commit -am 'changes'

загрузите изменения в heroku

git push heroku master

Убедитесь, что вы создали bd в heroku

heroku addons:create heroku-postgresql

, эта статья может помочь вам https://devcenter.heroku.com/articles/sqlite3

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...