heroku / heroku-buildpack-ruby Goto Github PK
View Code? Open in Web Editor NEWHeroku's buildpack for Ruby applications.
License: MIT License
Heroku's buildpack for Ruby applications.
License: MIT License
Notice the first line? This was compiled on heroku.
I then precompiled the assets and pushed which fixed it. I should be able to just push and have it precompile on the heroku side though, no?
Thoughts? app is here https://github.com/softwaregravy/aws_info
some discussion already here: jruby/heroku-buildpack-jruby#10 (comment)
To avoid ugly deprecation warnings like:
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/config/environment.rb:5)
For Rails::VERSION::MAJOR >= 3
Extract your vendor/plugins to their own gems and bundle them in your Gemfile. If they're tiny, not worthy of the own gem, fold it into your app as lib/myplugin/* and config/initializers/myplugin.rb
[1] http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released/
See: https://github.com/heroku/heroku-buildpack-ruby/blob/master/lib/language_pack/rails3.rb#L44
and: Ticket #84604
Manifest.yml's location is configurable via config.assets.prefix
. We aren't respecting that from what I can see.
The default rails 4 bin/rails that's created when you initialize a project is different than the rails binstub.
Don't symlink the rails gem into bin if bin/rails is missing(e.g. if bin/ has been added to the .gitignore file)
Changing Ruby Version Breaks Bundler since PATH and GEM_ENV are not set properly. Support is seeing increased tickets, and when more versions of ruby come out i.e. 2.0 these will increase in number. I'll make a devcenter article as a stop gap measure, but we need to gameplan what we'll be doing to fix this in the long term.
To what degree of confidence can we make the default ruby for the buildpack 1.9.3? What are the blockers?
the buildpack runs bundle install --binstubs vendor/bundle/bin
. That of course will create binstubs that find the Gemfile at ../../../Gemfile. The thing is, the buildpack then symlinks (or something?) those binstubs that are buried in vendor/bundle/bin into /app/bin instead, so the path to the Gemfile inside those stubs is wrong when you try to run heroku run rake
.
(see also Heroku support ticket 74167)
This causes issues with RBX out of the gate. It also manifests itself where on ruby 1.9.3, if you put rake
in your Gemfile
, it'll overwrite the existing rake
causing bin/rake
to not work.
~ $ rake -T
/app/vendor/ruby-1.9.3/Gemfile not found
We need to install the bundler binstubs into a different directory than the ones that ruby uses so there aren't conflicts.
Thoughts?
Pros: Committing this directory is harmful, breaks native gems, etc.
Cons: People should be able to vendor everything if they really want to. (But there's a "right way" to do that, and this isn't it... (use bundle package
))
Trying to push an app using Rubinius results in the following error:
-----> Heroku receiving push
-----> Ruby/Rails app detected
!
! Invalid RUBY_VERSION specified: ruby-1.8.7-rbx-2.0.0dev
! Valid versions: ruby-1.9.3-p0, ruby-1.9.3-p125, rbx-1.2.4, rbx-2.0.0dev-20120115-1.9, rbx-2.0.0dev-20120115-1.8, rbx-2.0.0dev-20120123-1.9, rbx-2.0.0dev-20120123-1.8, ruby-1.9.2-p290, jruby-1.6.5.1, jruby-1.6.7, ruby-1.9.3, ruby-1.9.2, ruby-1.8.7, ruby-1.9.3-jruby-1.7.0.preview1, ruby-1.8.7-jruby-1.7.0.preview1, ruby-1.9.3-rbx-2.0.0dev, ruby-1.8.7-rbx-2.0.0dev
!
! Heroku push rejected, failed to compile Ruby/rails app
Invalid RUBY_VERSION specified:
ruby-1.8.7-rbx-2.0.0dev
Valid versions:
... snip snip ... ruby-1.8.7-rbx-2.0.0dev
Gemfile:
ruby "1.8.7", :engine => "rbx", :engine_version => "2.0.0dev"
Any idea why this is?
Thanks!
"Ruby version change detected. Clearing bundler cache" is rather vague and has worried some customers. Can we be more explicit about what's changed?
For parity with other JDK buildpacks, the JRuby support in this buildpack should support the jdk-overlay
and system.properties
files to allow users to customize the JDK used with their app.
Reference:
https://devcenter.heroku.com/articles/customizing-the-jdk
https://devcenter.heroku.com/articles/add-java-version-to-an-existing-maven-app
See "fatal: Not a git repository (or any of the parent directories): .git" when pushing sometimes from @daneharrigan
-----> Heroku receiving push
-----> Ruby/Rack app detected
-----> Installing dependencies using Bundler version 1.1.rc
Running: bundle install --without development:test --path vendor/bundle --deployment
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
Fetching gem metadata from http://rubygems.org/........
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
Installing daemons (1.1.4)
Installing eventmachine (0.12.10) with native extensions
Using oauth (0.4.5)
Using rack (1.3.5)
Using rack-protection (1.1.4)
Using tilt (1.3.3)
Using sinatra (1.3.1)
Using micro (0.0.1) from source at .
Installing thin (1.2.11) with native extensions
Using bundler (1.1.rc)
Your bundle is complete! It was installed into ./vendor/bundle
Cleaning up the bundler cache.
-----> Discovering process types
Procfile declares types -> web
Default types for Ruby/Rack -> console, rake
-----> Compiled slug size is 6.6MB
-----> Launching... done, v3
http://micro-engine.heroku.com deployed to Heroku
curl is shelled out to in various places, such as here, but it's not run with --fail
and the run
method doesn't do any error checking.
When a download done with curl silently fails it can lead to surprising errors such as can't convert nil into String (TypeError)
from File.expand_path
in add_bundler_to_load_path.
The binaries and shared libraries at least in the ruby-2.0.0 tarball are not stripped. If having debug symbols for buildpack ruby builds would be useful, consider packaging them into a separate tarball.
This shows possible size reduction, which could translate into quicker build (less to download) and run (smaller slugs to fetch) times:
~ $ mkdir t
~ $ curl -o - https://s3.amazonaws.com/heroku-buildpack-ruby/ruby-2.0.0.tgz | tar -C t -zxf -
~ $ du -sh t
83M t
~ $ find t -type f | xargs file | grep 'not stripped' | awk '{ print $1 }' | cut -d: -f1 | xargs strip
~ $ du -sh t
36M t
~ $ tar -C t -czf ruby-2.0.0-smaller.tgz .
~ $ du -sh ruby-2.0.0-smaller.tgz
11M ruby-2.0.0-smaller.tgz
Node.js version 0.4.7 is installed, despite me using heroku-buildpack-node.
I have a pull request coming up.
ref #16
If I have:
gem "rails", :git => "git://github.com/rails/rails.git", :ref => "3-0-stable"
In my Gemfile I end up with a directory like:
vendor/bundle/ruby/1.9.1/bundler/gems/rails-77403a9b0407
in my slug. This directory contains a .git
directory. In a slug created from an app with the above line in its Gemfile that .git
directory is 64M. I believe this directory can be removed from the slug and things will still work.
Rails 3.2.12
issue: assets are present on the dyno but the body is not present when being served from the dyno.
config.rack_cache
to dalli or or disabling it seems to fix the issue
Need to repro to determine potential root causes.
Ticket: 78446
Bro.
I'm not getting a very helpful error message when pushing an app that has sqlite3 in the Gemfile. I know it's not supported, but I only saw a compilation error:
Warning: Permanently added 'heroku.com,50.19.85.132' (RSA) to the list of known hosts.
Counting objects: 80, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (63/63), done.
Writing objects: 100% (80/80), 28.67 KiB, done.
Total 80 (delta 10), reused 0 (delta 0)
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.2.0.pre
Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
Fetching gem metadata from https://rubygems.org/.......
Fetching git://github.com/tenderlove/rails.git
Fetching git://github.com/rails/journey.git
Fetching git://github.com/rails/active_record_deprecated_finders.git
Fetching git://github.com/rails/arel.git
Fetching git://github.com/rails/coffee-rails.git
Fetching git://github.com/rails/sprockets-rails.git
Fetching git://github.com/rails/sass-rails.git
Installing rake (0.9.2.2)
Installing i18n (0.6.0)
Installing minitest (3.2.0)
Installing multi_json (1.3.6)
Installing tzinfo (0.3.33)
Using activesupport (4.0.0.beta) from git://github.com/tenderlove/rails.git (at async)
Installing builder (3.0.0)
Installing erubis (2.7.0)
Using journey (1.0.1.20120208102204) from git://github.com/rails/journey.git (at master)
Installing rack (1.4.1)
Installing rack-cache (1.2)
Installing rack-test (0.6.1)
Using actionpack (4.0.0.beta) from git://github.com/tenderlove/rails.git (at async)
Installing mime-types (1.19)
Installing polyglot (0.3.3)
Installing treetop (1.4.10)
Installing mail (2.4.4)
Using actionmailer (4.0.0.beta) from git://github.com/tenderlove/rails.git (at async)
Using active_record_deprecated_finders (0.0.1) from git://github.com/rails/active_record_deprecated_finders.git (at master)
Using activemodel (4.0.0.beta) from git://github.com/tenderlove/rails.git (at async)
Using arel (3.0.2.20120530170952) from git://github.com/rails/arel.git (at master)
Using activerecord (4.0.0.beta) from git://github.com/tenderlove/rails.git (at async)
Installing coffee-script-source (1.3.3)
Installing execjs (1.4.0)
Installing coffee-script (2.2.0)
Installing json (1.7.3) with native extensions
Installing rdoc (3.12)
Installing thor (0.15.4)
Using railties (4.0.0.beta) from git://github.com/tenderlove/rails.git (at async)
Using coffee-rails (4.0.0.beta) from git://github.com/rails/coffee-rails.git (at master)
Installing hike (1.2.1)
Installing jquery-rails (2.0.2)
Installing puma (1.4.0) with native extensions
Using bundler (1.2.0.pre)
Installing tilt (1.3.3)
Installing sprockets (2.4.4)
Using sprockets-rails (1.0.0) from git://github.com/rails/sprockets-rails.git (at master)
Using rails (4.0.0.beta) from git://github.com/tenderlove/rails.git (at async)
Installing sass (3.1.20)
Using sass-rails (4.0.0.beta) from git://github.com/rails/sass-rails.git (at master)
Installing sqlite3 (1.3.6) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite-devel' and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/ruby
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/lib
--enable-local
--disable-local
Gem files will remain installed in /tmp/build_3pfs60ipg4429/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6 for inspection.
Results logged to /tmp/build_3pfs60ipg4429/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6/ext/sqlite3/gem_make.out
An error occurred while installing sqlite3 (1.3.6), and Bundler cannot continue.
Make sure that `gem install sqlite3 -v '1.3.6'` succeeds before bundling.
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app
To [email protected]:quiet-rain-3994.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:quiet-rain-3994.git'
When the Rails 3 asset pipeline compilation fails we fallback to runtime compilation by injecting the rails31_enable_runtime_asset_compilation plugin.
As far as I can see this is a pretty terrible default, as most applications aren't able to compile assets at runtime in production as the default Rails Gemfile doesn't even include the required asset dependencies in the production group:
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.0'
gem 'coffee-rails', '~> 3.2.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platform => :ruby
gem 'uglifier', '>= 1.0.3'
end
The end result is that most apps end up in a 500 state after deployment, throwing an error on any page render. And that it's very easy for the asset compilation to break due to misbehaving plugins (like newrelic for example) only makes the situation worse.
If the asset compilation fails it's probably better to simply error rather than injecting the runtime runtime asset compilation plugin. At least then you've a chance to debug the problem, look at the referenced dev article in the deploy hook output, and fix the compilation.
Example failure (after installing the New Relic gem in a standard Rails 3 app - via the gem, not the addon):
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
Starting the New Relic Agent.
Installed New Relic Browser Monitoring middleware
rake aborted!
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Tasks: TOP => environment
(See full trace by running task with --trace)
Precompiling assets failed, enabling runtime asset compilation
Injecting rails31_enable_runtime_asset_compilation
Please see this article for troubleshooting help:
http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting
I'm seeing this when I deployed each of my apps today, but I didn't check in vendor/bundle
.
...
-----> WARNING: Removing `vendor/bundle`.
Checking in `vendor/bundle` is not supported. Please remove this directory
and add it to your .gitignore. To vendor your gems with Bundler, use
`bundle pack` instead.
...
% git ls-files | grep bundle
%
Debugging pipeline issues can be hard and devious. If the --dry-run
fails, it looks like the pipeline support is not working at all, since there's no output. Here's what's currently required to track down issues:
$ heroku run bash
$ unset DATABASE_URL REDISTOGO_URL REDIS_URL MONGOLAB_URI SENDGRID_USERNAME SENDGRID_PASSWORD
$ time env RAILS_ENV=production DATABASE_URL=postgres://user:[email protected]/dbname rake assets:precompile --trace
That said I am not sure what the best solution is, but here's some ideas.
--trace
enabled on the --dry-run
and the task itself?File.exists?(".debug-asset-pipeline")
?--dry-run
failed and that's why the pipeline stuff isn't working? Maybe just blindly do this if sprockets
is present?-----> assets:precompile rake task not detected; asset pipeline support disabled
The error makes it look like we can't figure out what type of app they have:
$ git push heroku master
Counting objects: 94, done.
Compressing objects: 100% (64/64), done.
Writing objects: 100% (70/70), 22.96 KiB, done.
Total 70 (delta 19), reused 0 (delta 0)
! Heroku push rejected, no Cedar-supported app detected
But it really comes from an encoding error inside of their application.rb file:
$ irb
> File.exists?("config/application.rb") &&
> File.read("config/application.rb") =~ /Rails::Application/
ArgumentError: invalid byte sequence in UTF-8
from (irb):4
from /bin/irb:16:in `<main>'
They might not see it on their machine if they have their default languages set to another encoding.
Apparently not grabbing all of the logs:
Running: rake assets:precompile
I, [2013-04-30T23:03:44.600420 #826] INFO -- : Writing /tmp/build_3h426x2r89sub/public/assets/bg-body-5f5fcb2eca2ce4f9d2aa546ffbb087ff.png
I, [2013-04-30T23:03:44.605139 #826] INFO -- : Writing /tmp/build_3h426x2r89sub/public/assets/favicon-36f22e1081bda94ef5e5cc3100f56107.png
I, [2013-04-30T23:03:44.607399 #826] INFO -- : Writing /tmp/build_3h426x2r89sub/public/assets/logo-bw-251247929739ae68359d7ee4b4ee90d7.png
I, [2013-04-30T23:03:44.609745 #826] INFO -- : Writing /tmp/build_3h426x2r89sub/public/assets/logo-mark-9c2e1f494b9c3c1f12ebf38f83029951.png
I, [2013-04-30T23:03:44.612039 #826] INFO -- : Writing /tmp/build_3h426x2r89sub/public/assets/logo-bdc05941cec8e7791d61eabf7a0f208c.png
I, [2013-04-30T23:03:48.934108 #826] INFO -- : Writing /tmp/build_3h426x2r89sub/public/assets/application-fe9122b4f346603b5686e310cdc580cd.js
I, [2013-04-30T23:03:49.369551 #826] INFO -- : Writing /tmp/build_3h426x2r89sub/public/assets/application-a51886dc6f18f124a0af6e5d9492d504.css
Asset precompilation completed (6.96s)
I'd imagine those INFO
lines shouldn't be there.
I gather S3 fetching silently failed.
$ git push heroku master
Counting objects: 9, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 442 bytes, done.
Total 5 (delta 4), reused 0 (delta 0)
-----> Heroku receiving push
-----> Ruby/Rails app detected
/usr/local/lib/ruby/1.9.1/syck.rb:145:in `initialize': No such file or directory - ruby_versions.yml (Errno::ENOENT)
from /usr/local/lib/ruby/1.9.1/syck.rb:145:in `open'
from /usr/local/lib/ruby/1.9.1/syck.rb:145:in `load_file'
from /app/slug-compiler/buildpacks/ruby/lib/language_pack/ruby.rb:151:in `block (2 levels) in ruby_versions'
from /app/slug-compiler/buildpacks/ruby/lib/language_pack/ruby.rb:149:in `chdir'
from /app/slug-compiler/buildpacks/ruby/lib/language_pack/ruby.rb:149:in `block in ruby_versions'
from /usr/local/lib/ruby/1.9.1/tmpdir.rb:83:in `mktmpdir'
from /app/slug-compiler/buildpacks/ruby/lib/language_pack/ruby.rb:148:in `ruby_versions'
from /app/slug-compiler/buildpacks/ruby/lib/language_pack/ruby.rb:183:in `install_ruby'
from /app/slug-compiler/buildpacks/ruby/lib/language_pack/ruby.rb:49:in `compile'
from /app/slug-compiler/buildpacks/ruby/lib/language_pack/rails2.rb:38:in `compile'
from /app/slug-compiler/lib/../buildpacks/ruby/bin/compile:8:in `block in <main>'
from /app/slug-compiler/buildpacks/ruby/lib/language_pack/base.rb:81:in `log'
from /app/slug-compiler/lib/../buildpacks/ruby/bin/compile:7:in `<main>'
! Heroku push rejected, failed to compile Ruby/rails app
The ruby buildpack seems to fail with a user-facing stacktrace for certain Aspen pushes. For example, try pushing the master branch of this repo to an Aspen app:
$ git push [email protected]:test-aspen-push.git master
Counting objects: 46, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (32/32), done.
Writing objects: 100% (46/46), 4.07 KiB, done.
Total 46 (delta 18), reused 35 (delta 13)
-----> Heroku receiving push
-----> Ruby/Rack app detected
-----> Gemfile detected, running Bundler version 0.9.9
-----> Bundler works best on the Bamboo stack. Please migrate your app:
http://devcenter.heroku.com/articles/bamboo
Unresolved dependencies detected; Installing...
Using --without development:test
/usr/local/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 2, col 8: ` specs:' (ArgumentError)
from /usr/local/lib/ruby/1.8/yaml.rb:133:in `load'
from /usr/local/lib/ruby/1.8/yaml.rb:144:in `load_file'
from /usr/local/lib/ruby/1.8/yaml.rb:143:in `open'
from /usr/local/lib/ruby/1.8/yaml.rb:143:in `load_file'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-0.9.9/lib/bundler/definition.rb:16:in `from_lock'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-0.9.9/lib/bundler.rb:84:in `definition'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-0.9.9/lib/bundler/cli.rb:60:in `install'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-0.9.9/lib/bundler/vendor/thor/task.rb:33:in `send'
... 6 levels...
from /usr/local/lib/ruby/gems/1.8/gems/bundler-0.9.9/lib/bundler/vendor/thor.rb:124:in `start'
from /usr/local/lib/ruby/gems/1.8/gems/bundler-0.9.9/bin/bundle:11
from /usr/local/bin/bundle:19:in `load'
from /usr/local/bin/bundle:19
FAILED: http://devcenter.heroku.com/articles/bundler
! Heroku push rejected, failed to install gems via Bundler
To [email protected]:test-aspen-push.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:test-aspen-push.git'
You can specify a local path for gem in Gemfile (assuming it is in your source control):
gem 'foo', path: 'vendor/my_gems/foo'
Note the dir my_gems
has a underscore. When you push you will get an error like this:
-----> Ruby/Rails app detected
sh: /tmp/build_2sg0z9pa0ogj6/vendor/my_gems/foo: not found
!
! Invalid RUBY_VERSION specified:
The-path-`/tmp/build_2sg0z9pa0ogj6/vendor/my_gems/foo`-does-not-exist.
! Valid versions: ruby-2.0.0, ruby-1.9.3, ruby-1.9.2, ruby-1.8.7,
ruby-1.9.3-jruby-1.7.0, ruby-1.8.7-jruby-1.7.0, ruby-1.9.3-jruby-1.7.1,
ruby-1.8.7-jruby-1.7.1, ruby-1.9.3-rbx-2.0.0dev, ruby-1.8.7-rbx-2.0.0dev
!
sh: /tmp/build_2sg0z9pa0ogj6/vendor/my_gems/foo: not found
! Heroku push rejected, failed to compile Ruby/rails app
Changing the folder name from my_gems
to mygems
will work.
Service Request Number: 78948
~ $ ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]
~ $ gem install bson_ext
Fetching: bson_ext-1.8.5.gem (100%)
Building native extensions. This could take a while...
Successfully installed bson_ext-1.8.5
Parsing documentation for bson_ext-1.8.5
unable to convert "\xE0" from ASCII-8BIT to UTF-8 for ext/bson_ext/bson_ext, skipping
Installing ri documentation for bson_ext-1.8.5
Done installing documentation for bson_ext (0 sec).
1 gem installed
note the:
unable to convert "\xE0" from ASCII-8BIT to UTF-8 for ext/bson_ext/bson_ext, skipping
Looks like there was an issue with rubygems and 2.0.2 fixed it https://jira.mongodb.org/browse/RUBY-561 related to this gem, though might not be the same issue
SR: 82300
Gemfile + Gemfile.lock:
https://gist.github.com/b54c6bc9fb536503c1e5
if you have native extensions, this can cause errors when you change ruby versions.
bundle exec script/console doesn't always work; particularly for core. "bundle exec ./script/console" is needed instead. No idea if this is just a core problem that needs to be fixed, or a more generic problem.
Currently, the .profile.d/ruby.sh
script written by the buildpack assumes that the compiled app will be run in $HOME. This is the case by default on Heroku, but I'm not sure that it needs to be coded into the buildpack. It would be nice, for example, to be able to compile and run an app outside of $HOME for doing CI runs on the platform.
To support this, what do you think about replacing e.g.:
export GEM_PATH=${GEM_PATH:-$HOME/vendor/bundle/ruby/1.9.1}
export LANG=${LANG:-en_US.UTF-8}
export PATH="$HOME/bin:$HOME/vendor/bundle/ruby/1.9.1/bin:$PATH"
with e.g.:
f=$(readlink --canonicalize --no-newline $BASH_SOURCE)
APPHOME=$(cd $(dirname $(dirname $f)) && pwd)
export GEM_PATH=${GEM_PATH:-$APPHOME/vendor/bundle/ruby/1.9.1}
export LANG=${LANG:-en_US.UTF-8}
export PATH="$APPHOME/bin:$APPHOME/vendor/bundle/ruby/1.9.1/bin:$PATH"
a28ba87 implies that there was a specific reason to do this, but its not clear why. This is preventing me from running a Rails 4 app on Heroku.
According to the bundler issue rubygems/bundler#635 this hack is no longer needed as current bundler release (1.1.2 at least) handle this correctly and do not try to install windows gems on unix boxes.
When recently deploying an app to production a developer added:
require 'ci/reporter/rake/rspec'
The gem is ci_reporter
to our Rakefile. On the next push to Heroku the app was crashing because the assets were non compiling. Once we discovered what the change was the fix was quick:
unless Rails.env == 'production'
require 'ci/reporter/rake/rspec'
end
But there was no indicator from the push command that anything was wrong other than noticing that the assets compile message was missing https://gist.github.com/1942061
So the suggestion would be to output the result of the rake command, even if it barfs.
i had a script in my app called bin/logger.
here's what happened on build:
-----> Heroku receiving push
-----> Ruby app detected
/tmp/build_lrz990zohxlp/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.0.rc.2/lib/bundler/spec_set.rb:90:in block in materialize': Could not find pg-0.14.0 in any of the sources (Bundler::GemNotFound) from /tmp/build_lrz990zohxlp/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.0.rc.2/lib/bundler/spec_set.rb:83:in
map!'
from /tmp/build_lrz990zohxlp/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.0.rc.2/lib/bundler/spec_set.rb:83:in materializ e' from /tmp/build_lrz990zohxlp/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:113:in
specs'
from /tmp/build_lrz990zohxlp/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:162:in specs_f or' from /tmp/build_lrz990zohxlp/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.0.rc.2/lib/bundler/definition.rb:151:in
request
ed_specs'
from /tmp/build_lrz990zohxlp/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.0.rc.2/lib/bundler/environment.rb:23:in request ed_specs' from /tmp/build_lrz990zohxlp/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.0.rc.2/lib/bundler/runtime.rb:11:in
setup'
from /tmp/build_lrz990zohxlp/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.0.rc.2/lib/bundler.rb:116:in setup' from /tmp/build_lrz990zohxlp/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.0.rc.2/lib/bundler.rb:128:in
require'
from bin/logger:4:in <main>' -----> Installing dependencies using Bundler version 1.2.0.rc.2 Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment Fetching gem metadata from http://rubygems.org/........ Installing pg (0.14.0) with native extensions Using scrolls (0.2.1) Using sequel (3.38.0) Using bundler (1.2.0.rc.2) Your bundle is complete! It was installed into ./vendor/bundle /tmp/build_lrz990zohxlp/vendor/bundle/ruby/1.9.1/gems/sequel-3.38.0/lib/sequel/database/connecting.rb:69:in
connect': Sequel::
Database.connect takes either a Hash or a String, given: nil (Sequel::Error)
from /tmp/build_lrz990zohxlp/vendor/bundle/ruby/1.9.1/gems/sequel-3.38.0/lib/sequel/core.rb:147:in connect' from bin/logger:6:in
connect': Sequel:: Database.connect takes either a Hash or a String, given: nil (Sequel::Error) from /tmp/build_lrz990zohxlp/vendor/bundle/ruby/1.9.1/gems/sequel-3.38.0/lib/sequel/core.rb:147:in
connect'here's my Gemfile:
source :rubygems
gem 'pg'
gem 'scrolls'
gem 'sequel'
If you've got a rack app and also make a config/environment.rb
file (which is reasonable) your app will be incorrectly detected as a Rails app. The best fix for this is to not rely on arbitrary file existence but rather the Gems bundled in with the app.
While running:
bundle platform --ruby
If the user's Gemfile contains an error, it will be masked and presented as an error in ruby version.
Heroku support ticket number: 61909
In all recent projects, I am using bower
to organize and install JS dependencies.
The strategy is to put all those dependencies in a git-ignored folders and let Sprockets find those dependencies.
Do you think it would be worth/sensible adding a new step when building Rails 3+ apps that would run bower install
(right after bundle install
) automatically so that the deps are part of the compiled container? Is there another way to approach this problem that I'm missing?
Thanks in advance and thanks for your awesome work!
manifest.yml is not created in rails4 anymore, it's manifest-(fingerprint).json
https://github.com/heroku/heroku-buildpack-ruby/blob/master/lib/language_pack/rails4.rb#L40
If this was the case, this workflow wouldn't have to involve shared-database:
$ heroku create
$ heroku addons:add heroku-postgresql:crane
$ heroku pg:promote BLUE
$ heroku labs:enable user_env_compile
$ git push heroku master
I think it's a rather common scenario for a Heroku app's assets (images, css, js) to be served from an external storage/distribution network such as S3 or CDN(cloudfront) and thus not needing to be served by the application server. However to get the correct digested assets, they need to be precompiled and then synced (e.g. using asset_sync) to their eventual resting place after which point the assets are not needed in the slug. My understanding is that the slug on heroku is formed before the build-pack is run. I am wondering if there is a way to strip the assets from the slug after asset_sync that will save significant binary footprint on the slug.
Rake::Task#enhance Not Executed on Assets Precompile
Question on SO:
http://stackoverflow.com/questions/9966408/why-does-rake-task-enhancement-differ-between-my-local-environment-and-when-depl
Active Issues:
#47878
#46032
Because errors can be emitted by the compilation process, it's not always clear that the process finished successfully. Granted, if it failed, a message would be printed, I think it would be wise to also indicate that we think assets were compiled successfully.
Example of current behavior:
...
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
/usr/local/bin/ruby /tmp/build_22f3kpm37ba0o/vendor/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets
DEPRECATION WARNING:
On line 1 of "", after "*"
Starting in Sass 3.2, "html" may only be used at the beginning of a selector.
DEPRECATION WARNING:
On line 937, after "*"
Starting in Sass 3.2, "html" may only be used at the beginning of a selector.
DEPRECATION WARNING:
On line 961, after "*"
Starting in Sass 3.2, "html" may only be used at the beginning of a selector.
DEPRECATION WARNING:
On line 962, after "*"
Starting in Sass 3.2, "html" may only be used at the beginning of a selector.
DEPRECATION WARNING:
On line 1 of "", after "*"
Starting in Sass 3.2, "html" may only be used at the beginning of a selector.
DEPRECATION WARNING:
On line 937, after "*"
Starting in Sass 3.2, "html" may only be used at the beginning of a selector.
DEPRECATION WARNING:
On line 961, after "*"
Starting in Sass 3.2, "html" may only be used at the beginning of a selector.
DEPRECATION WARNING:
On line 962, after "*"
Starting in Sass 3.2, "html" may only be used at the beginning of a selector.
-----> Rails plugin injection
...
$ rails new rails-example
...
create vendor/plugins/.gitkeep
run bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/..
Installing rake (10.0.4)
...
Using rails (3.2.13)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
$ mkdir -p vendor/plugins/rails_log_stdout
mikehale@Michaels-iMac ~/dev/heroku/rails-example
$ touch vendor/plugins/rails_log_stdout/.gitkeep
$ rake tmp:clear
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app
as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /U
sers/mikehale/dev/heroku/rails-example/Rakefile:7)
$ rm -rf vendor/plugins/rails_log_stdout/.gitkeep
$ rake tmp:clear
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app
as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /U
sers/mikehale/dev/heroku/rails-example/Rakefile:7)
$ rm -rf vendor/plugins/rails_log_stdout/
$ rake tmp:clear
$
Not sure what the best fix for this is. Perhaps just rely on gems: #11. Perhaps look for a path like vendor/plugins/.rails_log_stdout/.gitkeep
, which does not seem to trigger the deprecation warning.
I noticed that the Ruby buildpack was writing database.yml for my app even though it is not using Rails or even ActiveRecord. Have you considered the possibility of writing database.yml only for apps that depend on libraries using that config file, especially given that we'd like to move away from database.yml in general?
Date.today in gemspec causes error
Date.today.strftime("%Y-%m-%d")
Ticket: 78633
It would be nice if ruby versions could also be specified with a .ruby-version
file.
Most ruby version managers support this convention now.
Save downtime and errors by providing the option to run migrations on push/deploy.
git push heroku --with-migrations
OR
detect and run new migrations automatically. (perhaps enable/disable using an ENV-var?)
Minimal downtime is critical and a though nut to solve. It's a bigger problem for the bigger apps (highest paying customers?), I hate the trade-off continuous deployment vs uptime, but it will always be there, I guess.
The total downtime of the app during deployment could be drastically reduced, especially if the environment is already loaded in one of the other rake tasks run. The migration would take a split second. Added benefit is that a failed migration would not only rollback DB but also the deploy.
The two commands are PITA. I could run 'git push heroku && heroku run rake db:migrate', but often the push never return control to my term, so I still have to watch it and most likely wasting valuable seconds of uptime. I know I'm repeating myself now: a failed migration would rollback, but the code depending on the migrations would not be rolled back. I'd have to rollback the release manually. I'd like this automated :)
If I knew how to do this myself, I'd send a pull request... Thanks guys, I appreciate your work! /fan
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.