Heroku + Rack App + Active Support Timezones - ruby

I have a pretty simple Rack app that's defined in a file called config.ru:
require './environment'
class Ryan
def self.call(env)
[200, { "Content-Type" => "text/html" }, [Time.zone.now]]
end
end
run Ryan
In environment.rb, there's this:
require 'active_support/core_ext/time/zones'
require 'active_support/time_with_zone'
require 'active_support/core_ext/time/conversions'
Time.zone = 'Sydney'
And in the Gemfile:
source "http://rubygems.org"
gem 'rack'
gem 'tzinfo'
gem 'activesupport'
When I run this locally, it works! Huge success.
However, when I deploy this application to Heroku it fails entirely with this showing in the logs:
2012-03-01T02:01:55+00:00 app[web.1]: [2012-03-01 02:01:55] INFO ruby 1.9.2 (2011-07-09) [x86_64-linux]
2012-03-01T02:01:55+00:00 app[web.1]: [2012-03-01 02:01:55] INFO WEBrick 1.3.1
2012-03-01T02:01:55+00:00 app[web.1]: [2012-03-01 02:01:55] INFO WEBrick::HTTPServer#start: pid=1 port=27368
2012-03-01T02:01:56+00:00 heroku[web.1]: State changed from starting to up
2012-03-01T02:01:57+00:00 app[web.1]: [2012-03-01 02:01:57] ERROR NoMethodError: undefined method `now' for nil:NilClass
2012-03-01T02:01:57+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/handler/webrick.rb:59:in `service'
2012-03-01T02:01:57+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
2012-03-01T02:01:57+00:00 app[web.1]: /app/config.ru:8:in `call'
2012-03-01T02:01:57+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
2012-03-01T02:01:57+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
So... what's the dealio here? Is Heroku running this in a different kind of process and so that's why it can't be found?

Weird, this did not run for me locally ,
Ruby 1.9.2p180 and gems,
i18n (0.6.0)
multi_json (1.1.0)
activesupport (3.2.1)
rack (1.4.1)
tzinfo (0.3.31)
bundler (1.0.18)
This did,
require './environment'
class Ryan
def self.call(env)
Time.zone = "Sydney"
[200, { "Content-Type" => "text/html" }, [Time.zone.now.to_s]]
end
end
run Ryan
More information on your local environment may shed some light on why is it happenning.

That will work with Thin instead of WEBrick.
Add Thin gem to your Gemfile then create a Procfile:
web: bundle exec thin start -p $PORT
It worked for me on cedar stack.
As to why it did work with Thin and not WEBrick: I don't have a clue!
http://ryan-cedar.herokuapp.com/

Related

Sinatra on heroku production tries to load development gems

Trying to learn Sinatra I just deployed a simple app to heroku.
My config file:
require './main'
require 'sinatra'
run Sinatra::Application
Gemfile:
source 'http://rubygems.org'
ruby '1.9.3'
gem 'sinatra'
gem 'slim'
gem 'sass'
gem 'dm-core'
gem 'dm-migrations'
gem 'thin'
gem 'pg', :group => :production
gem 'dm-postgres-adapter', :group => :production
gem 'dm-sqlite-adapter', :group => :development
I get following error in the logs:
2015-03-31T09:13:54.051645+00:00 heroku[web.1]: State changed from crashed to starting
2015-03-31T09:13:57.281158+00:00 heroku[web.1]: Starting process with command `bundle exec ruby main.rb -p 28463`
2015-03-31T09:13:59.598142+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.1/lib/dm-core/adapters.rb:163:in `require': cannot load such file -- dm-sqlite-adapter (LoadError)
2015-03-31T09:13:59.598161+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.1/lib/dm-core/adapters.rb:163:in `load_adapter'
2015-03-31T09:13:59.598164+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.1/lib/dm-core/adapters.rb:133:in `adapter_class'
2015-03-31T09:13:59.598165+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.1/lib/dm-core/adapters.rb:13:in `new'
2015-03-31T09:13:59.598167+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/dm-core-1.2.1/lib/dm-core.rb:230:in `setup'
2015-03-31T09:13:59.598169+00:00 app[web.1]: from /app/song.rb:5:in `block in <top (required)>'
2015-03-31T09:13:59.598171+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1410:in `configure'
2015-03-31T09:13:59.598172+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:1989:in `block (2 levels) in delegate'
2015-03-31T09:13:59.598174+00:00 app[web.1]: from /app/song.rb:4:in `<top (required)>'
2015-03-31T09:13:59.598178+00:00 app[web.1]: from main.rb:6:in `require'
2015-03-31T09:13:59.598187+00:00 app[web.1]: from main.rb:6:in `<main>'
2015-03-31T09:14:00.479331+00:00 heroku[web.1]: State changed from starting to crashed
2015-03-31T09:14:00.461548+00:00 heroku[web.1]: Process exited with status 1
I tried the solution proposed here but it did not work.
Thanks in advance for ideas
I think you need datamapper in your Gemfile.
gem "datamapper"

rake aborted! uninitialized constant Logging::Logger::INFO - Namespace collision with WinRM and Albacore

Ruby/Rake NOOB and have inherited set of C# projects that use ruby & rake for build/deploy.
The build quit working last week because of an old gem. In the process of updating all gems to recent versions, I've run into this uninitialized constant problem.
There were no code changes involved and I tried adding "require 'logging'" to setup.rb.
I've been working under the assumption that the problem is in our rake files, but after pounding on this for hours I'm not so sure. I haven't found anyplace in our code that uses the constant.
Any suggestions or help appreciated.
Windows Server 2008 with Ruby 2.0.0.
gem list output:
*** LOCAL GEMS ***
akami (1.2.1)
albacore (0.3.6)
aws-sdk (1.38.0)
bigdecimal (1.2.0)
builder (3.2.2)
bundler (1.6.0)
ffi (1.9.3 x86-mingw32)
gssapi (1.0.3)
gyoku (1.1.1)
httpclient (2.3.4.1)
httpi (0.9.7)
io-console (0.4.2)
json (1.8.1, 1.7.7)
little-plugger (1.1.3)
logging (1.8.2)
mini_portile (0.5.3)
minitest (4.3.2)
multi_json (1.9.2)
nokogiri (1.6.1 x86-mingw32)
nori (1.1.5)
psych (2.0.0)
rack (1.5.2)
rake (0.9.6)
rdoc (4.0.0)
rubyntlm (0.1.1)
rubyzip (0.9.9)
savon (0.9.5)
test-unit (2.0.0.0)
uuidtools (2.1.4)
wasabi (1.0.0)
win32-service (0.8.4)
winrm (1.1.3)
and the rake output:
rake aborted!
uninitialized constant Logging::Logger::INFO
C:/Ruby200/lib/ruby/2.0.0/rake/ext/module.rb:36:in `const_missing'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/albacore-0.3.6/lib/albacore/support/logging.rb:7:in `initialize'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/albacore-0.3.6/lib/albacore/support/failure.rb:7:in `initialize'
C:/Ruby200/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:13:in `initialize'
C:/Ruby200/lib/ruby/2.0.0/psych/nodes/node.rb:35:in `new'
C:/Ruby200/lib/ruby/2.0.0/psych/nodes/node.rb:35:in `to_ruby'
C:/Ruby200/lib/ruby/2.0.0/psych.rb:130:in `load'
C:/build-dir/MV-MB-JOB1/deploy/setup.rb:5:in `block in <top (required)>'
C:/build-dir/MV-MB-JOB1/deploy/setup.rb:5:in `open'
C:/build-dir/MV-MB-JOB1/deploy/setup.rb:5:in `<top (required)>'
C:/build-dir/MV-MB-JOB1/deploy/rakefile.rb:15:in `require_relative'
C:/build-dir/MV-MB-JOB1/deploy/rakefile.rb:15:in `<top (required)>'
C:/Ruby200/lib/ruby/2.0.0/rake/rake_module.rb:25:in `load'
C:/Ruby200/lib/ruby/2.0.0/rake/rake_module.rb:25:in `load_rakefile'
C:/Ruby200/lib/ruby/2.0.0/rake/application.rb:604:in `raw_load_rakefile'
C:/Ruby200/lib/ruby/2.0.0/rake/application.rb:89:in `block in load_rakefile'
C:/Ruby200/lib/ruby/2.0.0/rake/application.rb:160:in `standard_exception_handling'
C:/Ruby200/lib/ruby/2.0.0/rake/application.rb:88:in `load_rakefile'
C:/Ruby200/lib/ruby/2.0.0/rake/application.rb:72:in `block in run'
C:/Ruby200/lib/ruby/2.0.0/rake/application.rb:160:in `standard_exception_handling'
C:/Ruby200/lib/ruby/2.0.0/rake/application.rb:70:in `run'
C:/Ruby200/bin/rake:37:in `<main>'
setup.rb:
require "yaml"
#environment = ENV["environment"] || "development"
#version = ENV["version"] || "none"
#configuration = File.open(File.join("environment", #environment, "global_config.yml"), "rb") {|f| YAML::load(f)}
#configuration.merge!({:environment => #environment,
:version => #version,
:repository_path => ENV["repository_path"]})
There seems to be a namespace collision between the WinRM and Albacore gems AND WinRM uses the 'logging' gem, Albacore uses 'logger'. Both define Logger.
Using the following command:
rake -f myTest.rb --trace
This works:
require "winrm"`
require "albacore"
task :default do
end
This does not:
require "albacore"
require "winrm"
task :default do
end
Albacore implements lib\albacore\support\logging.rb:
require 'logger'
module Logging
attr_accessor :logger, :current_log_device
def initialize
create_logger(STDOUT, Logger::INFO)
super()
end
def log_device=(logdev)
level = #logger.level
create_logger(logdev, level)
end
.
.
.
end
WinRm does the following in winrm.rb:
require 'date'
require 'kconv' if(RUBY_VERSION.start_with? '1.9') # bug in rubyntlm with ruby 1.9.x
require 'logging'
module WinRM
Logging.logger.root.level = :info
Logging.logger.root.appenders = Logging.appenders.stdout
end
require 'winrm/helpers/iso8601_duration'
require 'winrm/soap_provider'
Not suggesting this as an appropriate fix, but wrapping the Albacore Logging module in another module, and updating Albacore references to Logging (Albacore::Logging), solves the problem.
Altered lib\albacore\support\logging.rb:
module Albacore
module Logging
.
.
.
end
end
Update:
I opened an Albacore issue. 2.0.0.rc.10, released today, includes a fix for the name collision issue. However, migrating from pre-2.0 Albacore to 2.0.0 is not pain-free because some of the task types have been generalized. Albacore nunit has been replaced by task_runner. Albacore msbuild is now simply 'build'.
The conflict can also be solved by moving the require down in to the task that needs it, as such:
require "albacore"
task :default do
...
end
task :some_winrm_task do
require "winrm"
...
end

Can't start Mongoid with Sinatra

I'm trying to get started with Mongoid in a Sinatra app, but it looks like I'm running into dependency issues. If it helps, I'm on a Macbook Pro using RVM and running Ruby 1.9.3.
Here are the errors I'm getting after running $ ruby config.ru:
/Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/specification.rb:1637:in `raise_if_conflicts': Unable to activate mongoid-3.0.23, because activemodel-4.0.0 conflicts with activemodel (~> 3.1) (Gem::LoadError)
from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/specification.rb:746:in `activate'
from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems.rb:212:in `rescue in try_activate'
from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems.rb:209:in `try_activate'
from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from /Users/duncanmalashock/Penumbra/penumbra.rb:4:in `<top (required)>'
from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from config.ru:2:in `<main>'
Can anyone help?
Here are the files involved:
mongoid.yml:
development:
sessions:
default:
database: mongoid
hosts:
- localhost:27017
config.ru:
require 'sinatra'
require './penumbra'
run Sinatra::Application
Gemfile:
source :rubygems
source :rubyforge
# Thin Server
gem 'thin'
# Sinatra
gem 'sinatra'
gem 'sinatra-contrib', :require => 'sinatra/multi_route'
gem 'sinatra-partial', :require => 'sinatra/partial'
gem 'sinatra-reloader'
# MongoDB
gem "mongoid"
# Shopify
gem 'shopify_api'
penumbra.rb:
require 'sinatra'
require 'shopify_api'
require 'mongo'
require 'mongoid'
require 'json'
require "sinatra/reloader" if development?
Mongoid.load!("./mongoid.yml", :production)
def isactivepage(link_name)
if (link_name == #page_name)
return ' activelink'
else return ''
end
end
get '/' do
#page_name = "Home"
erb :"pages/index"
end
get '/about' do
#page_name = "About"
erb :"pages/about"
end
After running $ bundle exec rackup:
/Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/mongoid-1.0.6/lib/mongoid.rb:68:in `method_missing': undefined method `load!' for #<Mongoid::Config:0x007fc0838cb1d0> (NoMethodError)
from /Users/duncanmalashock/Penumbra/penumbra.rb:9:in `<top (required)>'
from /Users/duncanmalashock/Penumbra/config.ru:2:in `require'
from /Users/duncanmalashock/Penumbra/config.ru:2:in `block in <main>'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from /Users/duncanmalashock/Penumbra/config.ru:in `new'
from /Users/duncanmalashock/Penumbra/config.ru:in `<main>'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/server.rb:250:in `start'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/server.rb:141:in `start'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/bin/rackup:4:in `<top (required)>'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/bin/rackup:23:in `load'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/bin/rackup:23:in `<main>'
You have a Gemfile, but you’re not starting your app using Bundler, and that’s why you have the conflict.
The current version of shopify_api (3.0.3) has a dependency on activemodel via activeresource with the version requirements set to >=3.0.0. On your system you have Rails 4 installed, so activemodel 4.0 is loaded.
The current version of mongoid also has a dependency on activemodel, but this time the version requirement is ~> 3.2.
These two version requirements are not compatible, so you get the error activemodel-4.0.0 conflicts with activemodel (~> 3.1).
To fix it, simply use Bundler to start your app. You say you are running with $ ruby config.ru but this isn’t the correct way to use a config.ru (you would get errors later even if you fixed your dependency issues). You should use rackup. In this case you should run:
$ bundle exec rackup

Redmine Installation with activerecord-mysql-adapter

I'm working on a CentOS 6.3 Linux server with the Ruby version: 1.8.7 and the Gem version: 1.8.25
I'm trying to run the command: ruby script/rails server webrick -e production
It spits out this error:
=> Booting WEBrick
=> Rails 3.2.8 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/lib64/ruby/gems/1.8/gems/bundler-1.2.3/lib/bundler/rubygems_integration.rb:157:in `gem': Please install the mysql adapter: `gem install activerecord-mysql-adapter` (can't activate mysql (~> 2.8.1), already activated mysql-2.9.0. Make sure all dependencies are added to Gemfile.) (LoadError)
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/mysql_adapter.rb:5
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:25:in `spec'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:129:in `establish_connection'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/railtie.rb:82
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:43:in `run_load_hooks'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/base.rb:721
from /var/www/redmine/lib/plugins/acts_as_activity_provider/init.rb:2
from /var/www/redmine/config/initializers/00-core_plugins.rb:12
from /var/www/redmine/config/initializers/00-core_plugins.rb:2:in `each'
from /var/www/redmine/config/initializers/00-core_plugins.rb:2
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:588
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:587:in `each'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:587
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `run_initializers'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `send'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /var/www/redmine/config/environment.rb:14
from /var/www/redmine/config.ru:4:in `require'
from /var/www/redmine/config.ru:4
from /usr/lib64/ruby/gems/1.8/gems/rack-1.4.0/lib/rack/builder.rb:51:in `instance_eval'
from /usr/lib64/ruby/gems/1.8/gems/rack-1.4.0/lib/rack/builder.rb:51:in `initialize'
from /var/www/redmine/config.ru:1:in `new'
from /var/www/redmine/config.ru:1
This is my Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.2.8'
gem "jquery-rails", "~> 2.0.2"
gem "i18n", "~> 0.6.0"
gem "coderay", "~> 1.0.6"
gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby]
gem "builder", "3.0.0"
gem "rake", "0.8.7"
gem "rack", "1.4.0"
gem "rubytree", "0.5.2", :require => "tree"
gem "RedCloth", "~>4.2.3", :require => "redcloth" # for CodeRay
gem "mysql", "2.9.0"
# Optional gem for LDAP authentication
group :ldap do
gem "net-ldap", "~> 0.3.1"
end
# Optional gem for OpenID authentication
group :openid do
gem "ruby-openid", "~> 2.1.4", :require => "openid"
gem "rack-openid"
end
# Optional gem for exporting the gantt to a PNG file, not supported with jruby
platforms :mri, :mingw do
group :rmagick do
# RMagick 2 supports ruby 1.9
# RMagick 1 would be fine for ruby 1.8 but Bundler does not support
# different requirements for the same gem on different platforms
gem "rmagick", ">= 2.0.0"
end
end
# Database gems
platforms :mri, :mingw do
group :postgresql do
gem "pg", ">= 0.11.0"
end
group :sqlite do
gem "sqlite3"
end
end
platforms :mri_18, :mingw_18 do
group :mysql do
gem "mysql", "2.9.0"
end
end
platforms :mri_19, :mingw_19 do
group :mysql do
gem "mysql2", "~> 0.3.11"
end
end
platforms :jruby do
gem "jruby-openssl"
group :mysql do
gem "activerecord-jdbcmysql-adapter"
end
group :postgresql do
gem "activerecord-jdbcpostgresql-adapter"
end
group :sqlite do
gem "activerecord-jdbcsqlite3-adapter"
end
end
group :development do
gem "rdoc", ">= 2.4.2"
gem "yard"
end
group :test do
gem "shoulda", "~> 2.11"
# Shoulda does not work nice on Ruby 1.9.3 and seems to need test-unit explicitely.
gem "test-unit", :platforms => [:mri_19]
gem "mocha", "0.12.3"
end
local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local")
if File.exists?(local_gemfile)
puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v`
instance_eval File.read(local_gemfile)
end
# Load plugins' Gemfiles
Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file|
puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v`
instance_eval File.read(file)
end
I've installed activerecord-mysql-adapter -- it had no errors...
I've tried to change the Gemfile to match the error it's spitting out, the (~> 2.8.1) version but that did not work either...
Any help would really be appreciated...
UPDATE!!
I uninstalled MySQL 2.9.0 and installed MySQL 2.8.1 and changed my Gemfile to reflect the proper version, but now I'm getting this error:
=> Booting WEBrick
=> Rails 3.2.8 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query': Mysql::Error: Table 'redmine.users' doesn't exist: SHOW FULL FIELDS FROM `users` (ActiveRecord::StatementInvalid)
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `execute'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `log'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `execute'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/mysql_adapter.rb:324:in `execute_and_free'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:426:in `columns'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/connection_adapters/schema_cache.rb:12:in `initialize'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:228:in `call'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:228:in `default'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:228:in `[]'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:228:in `columns'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:237:in `columns_hash'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/inheritance.rb:19:in `descends_from_active_record?'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/inheritance.rb:25:in `finder_needs_type_condition?'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/base.rb:455:in `relation'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/scoping/named.rb:37:in `scoped'
from /usr/lib64/ruby/gems/1.8/gems/activerecord-3.2.8/lib/active_record/querying.rb:9:in `order'
from /var/www/redmine/app/models/group.rb:32
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:359:in `require_or_load'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:313:in `depend_on'
from /usr/lib64/ruby/gems/1.8/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:225:in `require_dependency'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:439:in `eager_load!'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:438:in `each'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:438:in `eager_load!'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:436:in `each'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/engine.rb:436:in `eager_load!'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/application/finisher.rb:53
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `run_initializers'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `send'
from /usr/lib64/ruby/gems/1.8/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /var/www/redmine/config/environment.rb:14
from /var/www/redmine/config.ru:4:in `require'
from /var/www/redmine/config.ru:4
from /usr/lib64/ruby/gems/1.8/gems/rack-1.4.0/lib/rack/builder.rb:51:in `instance_eval'
from /usr/lib64/ruby/gems/1.8/gems/rack-1.4.0/lib/rack/builder.rb:51:in `initialize'
from /var/www/redmine/config.ru:1:in `new'
from /var/www/redmine/config.ru:1
EDIT: I figured it out... I needed to run the command: RAILS_ENV=production bundle exec rake db:migrate
DOH!
Try
bundle exec ruby script/rails server webrick -e production
Also, why are you using script/rails? This should work:
bundle exec rails server webrick -e production
HTH

What is wrong with my installation of Ruby Watir::WebDriver?

I'm trying to run Watir for Ruby on Ubuntu 10.04. I've installed Chrome and ChromeDriver on my (displayless) server, and installed the selenium-webdriver Gem. But when I try to create a browser in Watir, I get:
$ irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'watir-webdriver'
=> true
irb(main):003:0> browser = Watir::Browser.new :chrome
NoMethodError: undefined method `closed?' for nil:NilClass
from /usr/lib/ruby/1.8/net/http.rb:1060:in `request'
from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/http/default.rb:83:in `response_for'
from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/http/default.rb:39:in `request'
from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/bridge.rb:598:in `raw_execute'
from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/bridge.rb:92:in `create_session'
from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/bridge.rb:68:in `initialize'
from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/chrome/bridge.rb:29:in `initialize'
from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/common/driver.rb:37:in `new'
from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/common/driver.rb:37:in `for'
from /usr/lib/ruby/gems/1.8/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver.rb:65:in `for'
from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.5.5/lib/watir-webdriver/browser.rb:35:in `initialize'
from (irb):3:in `new'
from (irb):3
from :0
irb(main):004:0>
Long pause after the "Watir::Browser.new" call, I'm assuming some sort of timeout? Maybe trying to talk with Chromedriver? I'm running these versions of the relevant Gems:
$ gem list
*** LOCAL GEMS ***
addressable (2.3.2)
childprocess (0.3.6)
fastercsv (1.5.5)
ffi (1.2.0, 1.0.11)
libwebsocket (0.1.3)
multi_json (1.3.7, 1.0.4)
rubygems-update (1.8.24)
rubyzip (0.9.9)
selenium-webdriver (2.26.0, 2.18.0)
watir-webdriver (0.5.5)
websocket (1.0.3)
yajl-ruby (1.1.0)
I'm trying to run Chrome headless, and I didn't have an X server running. Xvfb did the trick, and I'm working now:
http://en.wikipedia.org/wiki/Xvfb
http://blog.kagesenshi.org/2007/06/running-x-applications-headless-using.html

Resources