Ruby on Rails Passenger on Apache gemfile syntax Error ID 506682d5 - apache

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.

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.

Related

What is the correct way to fix bundler not finding compatible versions

I have an old rails 3 application which I want to update to rails 4 at the moment. I removed the Gemfile.lock manually and changed the Gemfile to require rails in version "4.0.0" before running a fresh "bundle install". I was getting several messages that bundler was not able to find compatible versions.
I am using ruby 2.0.0 here installed with rvm on a linux system.
I installed rails 4.0.0 manually using
gem install rails -v 4.0.0
And then I tried again with
bundle install
This is one example of the messages that pop up:
Bundler could not find compatible versions for gem "activerecord":
In Gemfile:
activerecord-import (~> 0.4.1) was resolved to 0.4.1, which depends on
activerecord (>= 3.0)
authlogic (~> 3.3.0) was resolved to 3.3.0, which depends on
activerecord (>= 3.2)
delayed_job_active_record (~> 4.0.0) was resolved to 4.0.3, which depends on
activerecord (>= 3.0, < 5.0)
rails (= 4.0.0) was resolved to 4.0.0, which depends on
activerecord (= 4.0.0)
This is my Gemfile:
source 'https://rubygems.org'
# the rails framework: September 14, 2016
gem 'rails', '4.0.0'
# the postgres db connector
gem 'pg', '~> 0.18.0'
# a templating engine for html
gem 'haml', '~> 3.1.7'
# authentication solution
gem 'authlogic', '~> 3.3.0'
# role-based authorization system
gem 'acl9', '~> 0.12.1'
# helper methods for rails 3 models
gem 'dynamic_form', '~> 1.1.4'
# upload management for active record
gem 'paperclip', '~> 4.2.2'
# tag a single model on several contexts
gem 'acts-as-taggable-on', '~> 2.4.1'
# read and write spreadsheet documents
gem 'spreadsheet', '0.9.7'
# active record backend for Delayed::Job
gem 'delayed_job_active_record', '~> 4.0.0'
# wrap ruby scripts executed as deamon
gem 'daemons', '~> 1.1.9'
# writing and deploying cron jobs
gem 'whenever', '~> 0.8.2', require: false
# bulk inserting data using active record
gem 'activerecord-import', '~> 0.4.1'
# named scoples for postgres fulltext search
gem 'pg_search', '~> 0.5.7'
# jQuery and the jQuery-ujs driver for your Rails
gem 'jquery-rails', '~> 3.1.3'
# jQuery UI's JavaScript, CSS, and image files
gem 'jquery-ui-rails', '~> 3.0.1'
# paginated queries with Active Record
gem 'will_paginate', '~> 3.0.5'
# group :production do
# performance management system
# gem 'newrelic_rpm'
# end
# Profiling toolkit
# gem 'rack-mini-profiler', :group => :development
group :test, :development do
# unit testing framework
gem 'test-unit', '~> 2.5.4'
# process manager
gem 'foreman', '~> 0.61.0'
# code profiler
# gem 'ruby-prof'
# bindings for the GNOME Libxml2
gem 'libxml-ruby', '~> 2.4.0'
# wrapper for Linux inotify
gem 'rb-inotify', '~> 0.9.1'
# web server
gem 'thin', '~> 1.5.0'
# gem 'debugger'
gem 'better_errors', '~> 0.3.2'
# retrieve the binding of a method's caller
gem 'binding_of_caller', '~> 0.8.0'
# hosted test coverage service (badge)
gem 'coveralls', '~> 0.8.23', require: false
# gem 'codecov', :require => false, :group => :test
end
group :assets do
# sass adapter
gem 'sass-rails', '~> 3.2.3'
# coffee script adapter
gem 'coffee-rails', '~> 3.2.1'
# call java script code and manipulate java script
# gem 'therubyracer', :platforms => :ruby
# uglifier minifies java script
gem 'uglifier', '~> 2.7.2'
end
group :tools do
# code formatter
gem 'rubocop', require: false
# report vulnerable gems
gem 'gemsurance', '~> 0.9.0'
# handle events on file system modifications
gem 'guard', '~> 1.6.1'
# automatically run your tests on file modification
gem 'guard-test', '~> 0.7.0'
# html parser
gem 'hpricot', '~> 0.8.6'
# ruby parser written in pure ruby
gem 'ruby_parser', '~> 3.1.2'
end
Due to the manual install of rails 4 I have activerecord in version 4.0.0 in my gems available. Why does it come up with that message? From my interpretation of the listed activerecord versions the dependency should be fulfilled with version 4.0.0? It is in the listed range between 3.0 and less than 5.

Could not find gem 'uglifier' in the current bundle

My simple web app runs ok on Windows 7. Now I am moving it to bluehost.
Getting this error when starting the app:
ActionView::Template::Error (cannot load such file -- uglifier
Trying to resolve it I have run 'gem install uglifier' and seems to mostly work:
SSH# gem install uglifier
Successfully installed uglifier-1.3.0
1 gem installed
Installing ri documentation for uglifier-1.3.0...
unable to convert "\xC2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for README.md, skipping
Installing RDoc documentation for uglifier-1.3.0...
unable to convert "\xC2" to UTF-8 in conversion from ASCII-8BIT to UTF-8 to US-ASCII for README.md, skipping
But when I try to locate the gem, it is not found:
bundle show uglifier
yields:
Could not find gem 'uglifier' in the current bundle
Gemfile includes the following:
group :assets do
gem 'therubyracer'
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
and Gemfile.lock shows that the uglifier gem is installed:
uglifier (1.3.0)
$PATH information:
/usr/local/jdk/bin:/home4/mychairs/perl5/bin:/usr/lib64/qt-3.3/bin:/home4/mychairs/perl5/bin:/ramdisk/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11R6/bin:/home4/mychairs/ruby/gems/bin:/home4/mychairs/ruby/gems:/home4/mychairs/bin
For starters you need to add the gem to your Gemfile at the root of your Rails application. See Bundler.
Simply include the uglifier gem somewhere in the assets group of your Gemfile:
Gemfile
group :assets do
gem 'uglifier'
end
Then you run the bundle install command to install all of the required gems. You can confirm exactly what gems are installed including version information by looking at the Gemfile.lock file.
If you don't already have an assets group then make one. I highly recommend reading up on bundler.
try it with following in the app directory
#first
bundle
#then
bundle install

Rails bundle install production only

I'm still new to rails/ruby/bundler and am a little confused.
In our config/application.rb file there's this bundler segment:
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
and in our Gemfile we use different groups, e.g.
group :development, :test do
gem "rspec-rails", ">= 2.7.0", :group => [:development, :test]
gem 'shoulda-matchers'
gem 'watchr'
gem 'spork', '~> 1.0rc'
gem 'spectator'
gem 'debugger'
gem 'wirble'
end
But when I run RAILS_ENV=production bundle install (or bundle install --deployment), it still installs gems from the development/test group...
Why does this happens or how can I make this work properly?
THIS ANSWER IS OUTDATED
Take a look at --without option:
bundle install --without development test
By default Bundler installs all gems and your application uses the gems that it needs. Bundler itself knows nothing about Rails and the current environment.
An alternative solution is to use the bundle-only ruby gem. It can be used as follows:
> gem install bundle-only
> bundle-only production
This library does not pollute your bundler configs or augment Gemfile.lock; it is a simple alternative to the built in bundle --without every other group option that bundler provides.

Deploying to Rails project to Heroku: Could not find activemodel

I am relatively new to rails and have been working my way through the Michael Hartl Tutorial. Throughout I have been deploying my projects to Heroku, however now I am at the end of chapter 5, I am getting an "application error". Specifically I am getting the following errors when I look into my Heroku logs:
2012-01-04T03:05:04+00:00 app[web.1]: Could not find activemodel-3.2.0.rc1 in any of the sources
2012-01-04T03:05:06+00:00 heroku[web.1]: State changed from starting to crashed
2012-01-04T03:05:06+00:00 heroku[web.1]: Process exited
2012-01-04T03:05:11+00:00 heroku[router]: Error H10 (App crashed) -> GET floating-stone 5077.heroku.com/ dyno= queue= wait= service= status=503 bytes=
Earlier in the log I see the following errors as well:
WARNING: Invalid .gemspec format in '/app/.bundle/gems/ruby/1.9.1/specifications/rails-3.2.0.rc1.gemspec'
WARNING: Invalid .gemspec format in '/app/.bundle/gems/ruby/1.9.1/specifications/actionmailer-3.2.0.rc1.gemspec'
WARNING: Invalid .gemspec format in '/app/.bundle/gems/ruby/1.9.1/specifications/actionpack-3.2.0.rc1.gemspec'
my gemfile is as follows:
source 'https://rubygems.org'
gem 'rails', '3.2.0.rc1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
# 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'
#gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :development do
gem 'rspec-rails', '2.7.0'
gem 'ZenTest', '4.6.2'
gem 'autotest-growl'
gem 'autotest-fsevent'
gem 'webrat', '0.7.3'
end
group :test do
gem 'rspec', '2.7.0'
gem 'webrat', '0.7.3'
end
I am having trouble debugging the issue and looked through almost all of the rails/heroku posts I could find but nothing on this specific issue. I was looking for some help...apologies if this is something quite basic.
I should also mention that the app works fine on my local machine and here is my database information (I am using mysql). Here is the DB info.
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: sample_app_development
pool: 5
username: root
password:
socket: /tmp/mysql.sock
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: sample_app_test
pool: 5
username: root
password:
socket: /tmp/mysql.sock
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: sample_app_production
pool: 5
username: root
password:
socket: /tmp/mysql.sock
Thanks!
The live version of new rails is available now ... i think you should give a try to rails 3.1.3 mature version ... this seem to come configuration issue as i am running my apps perfectly with rails 3.1.3 in heroku.
Does your Gemfile.lock file mention this version of ActiveModel? Have you done a full bundle update rails / bundle install, then committed the file and re-deployed?
I had this same problem. What worked in development locally, did not work when I deployed to Heroku. It is likely that you have a gem that is locked to an older version of Rails (or ActiveSupport as was my case.) Review your Gemfile.lock file. You may will likely find a reference to an older version of a Rails component.
Should you find this to be true, try commenting out the gem and see if your app will run when you deploy to Heroku. If so, then review the GitHub forks of the offending gem to see if someone has a solution. If you find an alternative, specify the git repository in your gem file and then run bundle install.
e.g.
gem 'tinymce-rails', :git => 'git://github.com/spohlenz/tinymce-rails.git'

Installing PostgreSQL with Ruby on Rails on Mac OS X

I have everything installed. But when I run "rake db:create", I get the following:
Ken-Vogts-MacBook:sixmonths ken$ rake db:create
(in /Users/ken/sixmonths)
rake aborted!
no such file to load -- pg
Here is my database.yml:
development:
adapter: postgresql
encoding: unicode
database: sixmonths_development
pool: 5
username: postgres
password: xxxxxxxx
test:
adapter: postgresql
encoding: unicode
database: sixmonths_test
pool: 5
username: sixmonths
password: xxxxxxxx
production:
adapter: postgresql
encoding: unicode
database: sixmonths_production
pool: 5
username: sixmonths
password: xxxxxxxx
I can see pg is installed when I run: gem list
I tried replacing "postgresql" with "pg" per another post on stackoverflow, but it resulted in this:
Ken-Vogts-MacBook:sixmonths ken$ rake db:create
(in /Users/ken/sixmonths)
Seems cool, right?
Nope. Next, I try "rake db:schema:dump" and I get this:
Ken-Vogts-MacBook:sixmonths ken$ rake db:schema:dump
(in /Users/ken/sixmonths)
rake aborted!
Please install the pg adapter: `gem install activerecord-pg-adapter` (no such file to load -- active_record/connection_adapters/pg_adapter)
Of course there is no "activerecord-pg-adapter". What do I have to do to make this work?
Gemfile Contents:
source 'rubygems.org'
gem 'rails', '3.0.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'unicorn'
# gem 'capistrano'
# gem 'ruby-debug'
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
# gem 'webrat'
# end
Rails 3 will only let you access the gems you specify in your Gemfile, so even if you have it installed in your system-wide gems by doing a gem install pg, it won't be able to find it.
Add gem 'pg' to your Gemfile, run bundle install, and you should be good to go.
I tried many things that I saw as solutions elsewhere, but the only thing that worked for me was replacing
gem 'sqlite3'
with
gem 'pg'
in Gemfile. My database.yml looks the same as yours.
Now both >rake db:create and >rake db:migrate work.
This is on OSX Snow Lepoard, Rails 3.0.7, Postgres 9.0.
And the output from:
gem list --local
is
pg (0.11.0)
polyglot (0.3.1)
postgres-pr (0.6.3)
rack (1.2.2, 1.0.1)
rack-mount (0.7.2, 0.7.1, 0.6.14)
rack-test (0.6.0, 0.5.7)
rails (3.0.7, 3.0.5, 2.3.5, 2.2.2, 1.2.6)