Skip to content

Instantly share code, notes, and snippets.

@pglombardo
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pglombardo/9135087 to your computer and use it in GitHub Desktop.
Save pglombardo/9135087 to your computer and use it in GitHub Desktop.
Notes on Redhat's OpenShift with Ruby

Newly created applications have pre-populated git repositories so you can't just at another remote to your existing repository and push to openshift - this is an unnecessary step. This occurs even though I didn't request an pre-existing application.

The pre-existing code had a pre-populated config.ru.

Ruby 2.0 not available

Having ruby '2.0.0' doesn't nicely tell you that you're not running Ruby 2.0 (I had the Ruby 1.9 cartridge installed), it instead barfs out an error like this:

pglombardo@themightyshogun:~/Projects/pwpush-heroku $ git push openshift master
Counting objects: 1253, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (698/698), done.
Writing objects: 100% (1251/1251), 542.64 KiB | 0 bytes/s, done.
Total 1251 (delta 600), reused 1117 (delta 508)
remote: Stopping Ruby cartridge
remote: Waiting for stop to finish
remote: waiting for server to shut down.... done
remote: server stopped
remote: Stopping Postgres cartridge
remote: Building git ref 'master', commit 4505d25
remote: Building Ruby cartridge
remote: bundle install --deployment --path ./app-root/repo/vendor/bundle
remote: NOTE: You can prevent installing certain Gemfile group using: rhc env set BUNDLE_WITHOUT=groupname
remote: /var/lib/openshift/53067ad05973ca379900007d/app-root/runtime/repo/Gemfile:4:in `evaluate': undefined method         `ruby' for #<Bundler::Dsl:0x0000000144d670> (NoMethodError)
remote:        /opt/rh/ruby193/root/usr/share/gems/gems/bundler-1.1.4/lib/bundler/dsl.rb:7:in `instance_eval'
remote:        /opt/rh/ruby193/root/usr/share/gems/gems/bundler-1.1.4/lib/bundler/dsl.rb:7:in `evaluate'
remote:        /opt/rh/ruby193/root/usr/share/gems/gems/bundler-1.1.4/lib/bundler/definition.rb:18:in `build'
remote:        /opt/rh/ruby193/root/usr/share/gems/gems/bundler-1.1.4/lib/bundler.rb:135:in `definition'
remote:        /opt/rh/ruby193/root/usr/share/gems/gems/bundler-1.1.4/lib/bundler/cli.rb:220:in `install'
remote:        /opt/rh/ruby193/root/usr/share/gems/gems/thor-0.15.4/lib/thor/task.rb:27:in `run'
remote:        /opt/rh/ruby193/root/usr/share/gems/gems/thor-0.15.4/lib/thor/invocation.rb:120:in `invoke_task'
remote:        /opt/rh/ruby193/root/usr/share/gems/gems/thor-0.15.4/lib/thor.rb:275:in `dispatch'
remote:        /opt/rh/ruby193/root/usr/share/gems/gems/thor-0.15.4/lib/thor/base.rb:425:in `start'
remote:        /opt/rh/ruby193/root/usr/share/gems/gems/bundler-1.1.4/bin/bundle:13:in `<top (required)>'
remote:        /opt/rh/ruby193/root/usr/bin/bundle:23:in `load'
remote:        /opt/rh/ruby193/root/usr/bin/bundle:23:in `<main>'
remote: There was an error in your Gemfile, and Bundler cannot continue.
remote: An error occurred executing 'gear postreceive' (exit code: 4)
remote: Error message: CLIENT_ERROR: Failed to execute: 'control build' for /var/lib/openshift/53067ad05973ca37990000d/ruby
remote:
remote: For more details about the problem, try running the command again with the '--trace' option.

...and then another bundler error:

remote: /opt/rh/ruby193/root/usr/share/gems/gems/bundler-1.1.4/lib/bundler/spec_set.rb:90:in `block in materialize':         Could not find rake-10.1.0 in any of the sources (Bundler::GemNotFound)
remote: 	from /opt/rh/ruby193/root/usr/share/gems/gems/bundler-1.1.4/lib/bundler/spec_set.rb:83:in `map!'
remote: 	from /opt/rh/ruby193/root/usr/share/gems/gems/bundler-1.1.4/lib/bundler/spec_set.rb:83:in `materialize'
remote: 	from /opt/rh/ruby193/root/usr/share/gems/gems/bundler-1.1.4/lib/bundler/definition.rb:127:in `specs'
remote: 	from /opt/rh/ruby193/root/usr/share/gems/gems/bundler-1.1.4/lib/bundler/definition.rb:172:in `specs_for'
remote: 	from /opt/rh/ruby193/root/usr/share/gems/gems/bundler-1.1.4/lib/bundler/definition.rb:161:in `requested_specs'
remote: 	from /opt/rh/ruby193/root/usr/share/gems/gems/bundler-1.1.4/lib/bundler/environment.rb:23:in `requested_specs'
remote: 	from /opt/rh/ruby193/root/usr/share/gems/gems/bundler-1.1.4/lib/bundler/runtime.rb:11:in `setup'
remote: 	from /opt/rh/ruby193/root/usr/share/gems/gems/bundler-1.1.4/lib/bundler.rb:107:in `setup'
remote: 	from /opt/rh/ruby193/root/usr/share/gems/gems/bundler-1.1.4/lib/bundler/setup.rb:17:in `<top (required)>'
remote: 	from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
remote: 	from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/custom_require.rb:36:in `require'
remote: Starting Ruby cartridge

This error was fixed by changing the Gemfile rubygems source to https:

source 'https://rubygems.org'

After another git push openshift master, the deploy proceeded further until...

remote: Installing kaminari (0.14.1)
remote: Installing kgio (2.9.2) with native extensions ............
remote: ................................................................................
remote: ..
remote:
remote: Installing libv8 (3.16.14.3)
remote: Installing ruby_core_source (0.1.5)
remote: Installing linecache19 (0.5.12) with native extensions .................
remote:
remote: Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
remote:
remote:         /opt/rh/ruby193/root/usr/bin/ruby extconf.rb
remote: checking for vm_core.h... no
remote: /var/lib/openshift/53067ad05973ca379900007d/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:39: Use RbConfig instead of obsolete and deprecated Config.
remote: checking for vm_core.h... no
remote: *** extconf.rb failed ***
remote: Could not create Makefile due to some reason, probably lack of
remote: necessary libraries and/or headers.  Check the mkmf.log file for more
remote: details.  You may 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}/
remote: 	--with-make-prog
remote: 	--without-make-prog
remote: 	--srcdir=.
remote: 	--curdir
remote: 	--ruby=/opt/rh/ruby193/root/usr/bin/ruby
remote: 	--with-ruby-dir
remote: 	--without-ruby-dir
remote: 	--with-ruby-include
remote: 	--without-ruby-include=${ruby-dir}/include
remote: 	--with-ruby-lib
remote: 	--without-ruby-lib=${ruby-dir}/
remote: /opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:247:in `mkdir': Permission denied - /opt/rh/ruby193/root/usr/include/ruby-1.9.3-p448 (Errno::EACCES)
remote: 	from /opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:247:in `fu_mkdir'
remote: 	from /opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:221:in `block (2 levels) in mkdir_p'
remote: 	from /opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:219:in `reverse_each'
remote: 	from /opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:219:in `block in mkdir_p'
remote: 	from /opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:205:in `each'
remote: 	from /opt/rh/ruby193/root/usr/share/ruby/fileutils.rb:205:in `mkdir_p'
remote: 	from /var/lib/openshift/53067ad05973ca379900007d/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:59:in `block in create_makefile_with_core'
remote: 	from /opt/rh/ruby193/root/usr/share/ruby/tempfile.rb:320:in `open'
remote: 	from /var/lib/openshift/53067ad05973ca379900007d/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:51:in `create_makefile_with_core'
remote: 	from extconf.rb:19:in `<main>'
remote: Requesting http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p448.tar.gz
remote: Downloading http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p448.tar.gz
remote:
remote:
remote: Gem files will remain installed in /var/lib/openshift/53067ad05973ca379900007d/app-root/runtime/repo/vendor/bundle/ruby/1.9.1/gems/linecache19-0.5.12 for inspection.
remote: Results log

Ok I shouldn't have debug gems in a production environment but I would have thought that the Ruby 1.9 cartridge would have the Ruby source so at least some binaries could build against it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment