#ruby-on-rails #ruby #git #heroku #ruby-on-rails-4
#ruby-on-rails #ruby #git #heroku #ruby-on-rails-4
Вопрос:
Я застрял на этом в течение нескольких часов и, похоже, не могу заставить его работать.
Я следую руководству и пытаюсь перенести свое приложение в Heroku.
Мой gemfile выглядит так:
source 'https://rubygems.org'
ruby '2.0.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.1'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
gem 'coffee-rails'
gem 'uglifier', '1.2.3'
end
# Use jquery as the JavaScript library
gem 'jquery-rails'
group :development, :test do
gem 'sqlite3'
gem 'rspec-rails', '2.10.0'
end
group :production do
gem 'pg'
end
Когда я нажимаю на Heroku, я получаю это:
Lisa:sample_app admin-lisa$ git push heroku master
Initializing repository, done.
Counting objects: 81, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (68/68), done.
Writing objects: 100% (81/81), 17.36 KiB, done.
Total 81 (delta 12), reused 0 (delta 0)
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.6.3
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Installing i18n 0.6.9
Installing rake 10.3.2
Installing minitest 5.3.5
Installing thread_safe 0.3.4
Installing builder 3.2.2
Installing rack 1.5.2
Installing erubis 2.7.0
Installing polyglot 0.3.5
Installing mime-types 1.25.1
Installing coffee-script-source 1.7.0
Installing arel 5.0.1.20140414130214
Installing execjs 2.2.1
Installing hike 1.2.3
Installing thor 0.19.1
Installing multi_json 1.10.1
Using bundler 1.6.3
Installing json 1.8.1
Installing tilt 1.4.1
Installing tzinfo 1.2.1
Installing sass 3.2.19
Installing rack-test 0.6.2
Installing coffee-script 2.2.0
Installing treetop 1.4.15
Installing uglifier 1.2.3
Installing sprockets 2.11.0
Installing activesupport 4.1.1
Installing mail 2.5.4
Installing actionview 4.1.1
Installing activemodel 4.1.1
Installing actionpack 4.1.1
Installing activerecord 4.1.1
Installing actionmailer 4.1.1
Installing sprockets-rails 2.1.3
Installing railties 4.1.1
Installing jquery-rails 3.1.1
Installing coffee-rails 4.0.1
Installing sass-rails 4.0.3
Installing rails 4.1.1
Installing pg 0.17.1
Your bundle is complete!
Gems in the groups development and test were not installed.
It was installed into ./vendor/bundle
Bundle completed (27.18s)
Cleaning up the bundler cache.
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
Sprockets::FileNotFound: couldn't find file 'turbolinks'
(in /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/app/assets/javascripts/application.js:15)
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/context.rb:106:in `resolve'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/context.rb:146:in `require_asset'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:217:in `process_require_directive'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:167:in `block in process_directives'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:165:in `each'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:165:in `process_directives'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:99:in `evaluate'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/context.rb:197:in `block in evaluate'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/context.rb:194:in `each'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/context.rb:194:in `evaluate'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/processed_asset.rb:12:in `initialize'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:374:in `new'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:374:in `block in build_asset'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:395:in `circular_call_protection'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:373:in `build_asset'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:94:in `block in build_asset'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/caching.rb:58:in `cache_asset'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:93:in `build_asset'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:287:in `find_asset'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:61:in `find_asset'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/bundled_asset.rb:16:in `initialize'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:377:in `new'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:377:in `build_asset'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:94:in `block in build_asset'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/caching.rb:58:in `cache_asset'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:93:in `build_asset'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:287:in `find_asset'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:61:in `find_asset'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:211:in `block in find_asset'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:257:in `benchmark'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:210:in `find_asset'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:119:in `block in compile'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:118:in `each'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:118:in `compile'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.1.3/lib/sprockets/rails/task.rb:61:in `block (3 levels) in define'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/rake/sprocketstask.rb:146:in `with_logger'
/tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.1.3/lib/sprockets/rails/task.rb:60:in `block (2 levels) in define'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
!
! Precompiling assets failed.
!
! Push rejected, failed to compile Ruby app
To git@heroku.com:polar-wave-2691.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:polar-wave-2691.git'
И когда я захожу на сайт Heroku, он говорит: ошибка приложения
В приложении произошла ошибка, и ваша страница не может быть обслужена. Пожалуйста, повторите попытку через несколько минут.
Если вы являетесь владельцем приложения, проверьте свои журналы для получения подробной информации.
Итак, я проверил свои журналы, в которых говорится:
Lisa:sample_app admin-lisa$ heroku logs
2014-06-27T00:07:21.685434 00:00 heroku[api]: Enable Logplex by somebody.lisa@gmail.com
2014-06-27T00:07:21.685490 00:00 heroku[api]: Release v2 created by somebody.lisa@gmail.com
2014-06-27T00:07:29 00:00 heroku[slug-compiler]: Slug compilation started
2014-06-27T00:07:33 00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
2014-06-27T00:07:40.377399 00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=polar-wave-2691.herokuapp.com request_id=5b29dca1-29e3-4410-8efb-99c74f1b14ec fwd="50.143.161.142" dyno= connect= service= status=503 bytes=
2014-06-27T00:07:40.673553 00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=polar-wave-2691.herokuapp.com request_id=39df86cb-8d9c-418f-afb9-8242fc5f311e fwd="50.143.161.142" dyno= connect= service= status=503 bytes=
2014-06-27T00:08:03.130094 00:00 heroku[api]: Starting process with command `rake db:migrate` by somebody.lisa@gmail.com
2014-06-27T00:08:04.869272 00:00 heroku[run.1405]: State changed from starting to up
2014-06-27T00:08:06.629224 00:00 heroku[run.1405]: State changed from up to complete
2014-06-27T00:08:04.809756 00:00 heroku[run.1405]: Starting process with command `rake db:migrate`
2014-06-27T00:08:06.612075 00:00 heroku[run.1405]: Process exited with status 1
2014-06-27T00:08:04.774227 00:00 heroku[run.1405]: Awaiting client
2014-06-27T00:08:10.068439 00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=polar-wave-2691.herokuapp.com request_id=a6c649ff-2b4b-4a67-9bfa-c2e06b623c8a fwd="50.143.161.142" dyno= connect= service= status=503 bytes=
2014-06-27T00:08:10.354925 00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=polar-wave-2691.herokuapp.com request_id=60a03227-4cfa-4ba3-b2e5-f84b63b0db07 fwd="50.143.161.142" dyno= connect= service= status=503 bytes=
2014-06-27T00:08:13.488700 00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=polar-wave-2691.herokuapp.com request_id=21eb1930-2b7e-4e57-b0df-3fffaeffae29 fwd="50.143.161.142" dyno= connect= service= status=503 bytes=
2014-06-27T00:08:13.851121 00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=polar-wave-2691.herokuapp.com request_id=9b015c1f-e710-4866-acba-0f215ea5938d fwd="50.143.161.142" dyno= connect= service= status=503 bytes=
2014-06-27T00:08:40.685450 00:00 heroku[run.2450]: Awaiting client
2014-06-27T00:08:40.746839 00:00 heroku[run.2450]: Starting process with command `rake db:migrate`
2014-06-27T00:08:39.220494 00:00 heroku[api]: Starting process with command `rake db:migrate` by jonsson.lisa@gmail.com
2014-06-27T00:08:40.730443 00:00 heroku[run.2450]: State changed from starting to up
2014-06-27T00:08:42.454908 00:00 heroku[run.2450]: State changed from up to complete
2014-06-27T00:08:42.363758 00:00 heroku[run.2450]: Process exited with status 1
2014-06-27T00:08:55.126228
00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=polar-wave-2691.herokuapp.com request_id=5f1ec80d-7dc1-4810-91a1-1f61b7f1dc66 fwd="50.143.161.142" dyno= connect= service= status=503 bytes=
2014-06-27T00:08:55.685930 00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=polar-wave-2691.herokuapp.com request_id=03a9fa47-7148-4a12-b7ec-ffe2100f4161 fwd="50.143.161.142" dyno= connect= service= status=503 bytes=
2014-06-27T00:16:47.224352 00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=polar-wave-2691.herokuapp.com request_id=fccc625d-9bd2-4d2b-8d95-a51fe4d210eb fwd="50.143.161.142" dyno= connect= service= status=503 bytes=
2014-06-27T00:16:47.589404 00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=polar-wave-2691.herokuapp.com request_id=336a9fd4-47c7-4342-a7c2-3815eb0b84d3 fwd="50.143.161.142" dyno= connect= service= status=503 bytes=
2014-06-27T00:17:01 00:00 heroku[slug-compiler]: Slug compilation started
2014-06-27T00:17:05 00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
2014-06-27T00:18:13 00:00 heroku[slug-compiler]: Slug compilation started
2014-06-27T00:19:08 00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
2014-06-27T00:20:16 00:00 heroku[slug-compiler]: Slug compilation started
2014-06-27T00:21:03 00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
2014-06-27T00:22:11 00:00 heroku[slug-compiler]: Slug compilation started
2014-06-27T00:22:39 00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
2014-06-27T00:23:31 00:00 heroku[slug-compiler]: Slug compilation started
2014-06-27T00:23:56 00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
2014-06-27T00:24:37 00:00 heroku[slug-compiler]: Slug compilation started
2014-06-27T00:25:06 00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
2014-06-27T00:26:09 00:00 heroku[slug-compiler]: Slug compilation started
2014-06-27T00:26:37 00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
2014-06-27T00:39:14 00:00 heroku[slug-compiler]: Slug compilation started
2014-06-27T00:39:51 00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app
Я не понимаю, что именно он пытается мне сказать, но я попытался запустить
rake assets:precompile
также
heroku run rake db:migrate
Я также проверил свой статус git, и все было зафиксировано.
Я попытался удалить свой gemfile.снова заблокируйте и запустите bundle и rake db: migrate и повторите все заново, но безуспешно.
Я только изучаю Rails, и журнал heroku не совсем понятен для меня.
Спасибо.
Ответ №1:
Что делает ваш application.js как выглядит файл? Если вы используете turbolinks, избавьтесь от нее. Возможно, Rails пытается предварительно скомпилировать ваши ресурсы для вас и уменьшить их, но это может сбить вас с толку. Также проверьте https://github.com/heroku/rails_12factor , возможно, вы захотите установить этот драгоценный камень.
Комментарии:
1. Спасибо за ваш ответ. Мой application.js я включил turoblinks, поэтому я попытался избавиться от него, а также добавил rails_12factor и снова запустил bundle и перенес его в git и heroku, но он по-прежнему делает то же самое. Хм..
Ответ №2:
У меня была похожая проблема несколько недель назад при создании моего первого приложения rails; Я бы удалил ваш драгоценный камень sass-rails вместе с активами группы do, повторно связал и дал ему еще один шанс.
Должно выглядеть так:
gem 'coffee-rails'
gem 'uglifier', '1.2.3'
не
group :assets do
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
gem 'coffee-rails'
gem 'uglifier', '1.2.3'
end
Ответ №3:
В вашем gemfile попробуйте добавить gem ‘rails_12factor’ в production. Таким образом, код должен измениться с
...
group :production do
gem 'pg'
end
Для
...
group :production do
gem 'pg'
gem 'rails_12factor'
end
Редактировать: вот что означает весь мой Gemfile
source 'https://rubygems.org'
gem 'rails', '4.1.1'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
# Deploying to Heroku
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :development, :test do
gem 'sqlite3'
end
Комментарии:
1. Спасибо за ваш комментарий, я не думаю, что раньше у меня был гем с фактором rails_12 в нужном месте. У меня все та же проблема, но я думаю, что вы, вероятно, решили для меня другую проблему. 🙂
Ответ №4:
Вот некоторые из вещей, которые решили это для меня (спасибо @plondon, это был хороший глаз!)
Поскольку я удалил turbolinks из своего Gemfile, я также должен был убедиться, что мой application.css/.js не пользовался им. Я очистил оба файла.
Я также удалил свой Gemlock.файл и пакет снова установлены.
Наконец, после принудительного нажатия он прошел, особенно потому, что мой application.js использовал Turbolinks, когда он у меня больше не был установлен.
Ответ №5:
Вы можете выполнить следующие действия:
- Удалите
gem 'turbolinks'
строку из вашего Gemfile. - Удалите
//= require turbolinks
из своего app/assets/javascripts/application.js . - Удалите две
"data-turbolinks-track" => true
пары хэш-ключ / значение из вашего app / views/layouts/application.html.erb
В вашем Gemfile
gem "foreman"
group :production, :staging do
gem "rails_12factor"
gem "rails_stdout_logging"
gem "rails_serve_static_assets"
end
Подробнее удалить turbolink