1

Running Rails 4 on Apache2 using Phusion Passenger and Ruby 2.1 installed via RVM. When I access the Rails app in the browser, I get this error:

Gemfile syntax error compile error
on line 24: syntax error, unexpected ':', expecting $end
gem 'sdoc', '~> 0.4.0',          group: :doc
                                       ^ (Bundler::GemfileError)
  /home/romistrub/.rvm/gems/ruby-2.1.3@global/gems/bundler-1.7.3/lib/bundler/dsl.rb:35:in `eval_gemfile'
  /home/romistrub/.rvm/gems/ruby-2.1.3@global/gems/bundler-1.7.3/lib/bundler/dsl.rb:10:in `evaluate'
  /home/romistrub/.rvm/gems/ruby-2.1.3@global/gems/bundler-1.7.3/lib/bundler/definition.rb:25:in `build'
  /home/romistrub/.rvm/gems/ruby-2.1.3@global/gems/bundler-1.7.3/lib/bundler.rb:154:in `definition'
  /home/romistrub/.rvm/gems/ruby-2.1.3@global/gems/bundler-1.7.3/lib/bundler.rb:117:in `setup'
  /home/romistrub/.rvm/gems/ruby-2.1.3@global/gems/bundler-1.7.3/lib/bundler/setup.rb:17
  /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:59:in `gem_original_require'
  /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:59:in `require'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:263:in `run_load_path_setup_code'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:366:in `running_bundler'
  /usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:261:in `run_load_path_setup_code'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app'
  /usr/share/passenger/helper-scripts/rack-preloader.rb:158

Error ID
506682d5

Rails app gemfile:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.6'
# 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

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

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

# Use debugger
# gem 'debugger', group: [:development, :test]

the command

cat $(which bundle)

gives

#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'bundler' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'rubygems'

version = ">= 0"

if ARGV.first
  str = ARGV.first
  str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
  if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
    version = $1
    ARGV.shift
  end
end

gem 'bundler', version
load Gem.bin_path('bundler', 'bundle', version)

command

rake about

gives

About your application's environment
Ruby version              2.1.3-p242 (x86_64-linux)
RubyGems version          2.2.2
Rack version              1.5
Rails version             4.1.6
JavaScript Runtime        Node.js (V8)
Active Record version     4.1.6
Action Pack version       4.1.6
Action View version       4.1.6
Action Mailer version     4.1.6
Active Support version    4.1.6
Middleware                Rack::Sendfile, ActionDispatch::Static, Rack::Lock, #    <ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x00000004ec86d8>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag
Application root          /var/www/board/demo
Environment               development
Database adapter          sqlite3
Database schema version   0

I have no idea where to even start with this one.

Any help is greatly appreciated. Thanks in advance.

Romi
  • 123
  • 10

1 Answers1

0

Turns out it was an issue with Passenger on RVM, wherein Passenger was using the wrong ruby binary.

After making sure I was using the right Ruby in RVM via

ruby use 2.1

then checking that I was using the proper PassengerRuby directive in Apache using

passenger-config --ruby-command

then changing the Apache configuration to the result of the above command:

PassengerRuby /home/<user>/.rvm/gems/ruby-2.1.3/wrappers/ruby

everything worked.

Well, almost. I encountered another error: a missing SECRET_KEY_BASE ENV. To fix that, I added to the /etc/apache2/envvars the following line:

export SECRET_KEY_BASE=<thisisthesupersecretsecretkeypleasedontcopy>

And restarted apache. Now my only problem is the following error, which I hope has a basic fix:

The page you were looking for doesn't exist.
Romi
  • 123
  • 10