Ruby on Rails - Problems Solution

Solved


Problem: How to disable warnings like this (deprecation warnings):
DEPRECATION WARNING: Kernel#returning has been deprecated in favor of Object#tap. (called from inflections at D:/Webpages.SVN/community-buy.com/vendor/rails/actionpack/lib/action_controller/routing.rb:377)
DEPRECATION WARNING: ActiveSupport::Dependencies.load_once_paths  is deprecated

Solution:

Problem: when running rake sunspot:solr:run :
2011-11-14 15:39:36.402::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
2011-11-14 15:39:36.530::INFO:  jetty-6.1.3
2011-11-14 15:39:36.623::INFO:  Extract jar:file:/home3/chamelf5/ruby/gems/gems/sunspot-1.1.0/solr/webapps/solr.war!/ to /tmp/Jetty_0_0_0_0_8982_solr.war__solr__-2c5peu/webapp
2011-11-14 15:39:36.810::INFO:  NO JSP Support for /solr, did not find org.apache.jasper.servlet.JspServlet
2011-11-14 15:39:36.961::WARN:  failed SolrRequestFilter
java.lang.NoClassDefFoundError: org.apache.solr.core.SolrResourceLoader
   at java.lang.Class.initializeClass(libgcj.so.7rh)
Solution:
Install Java : JRE 1.5.0_22. 
The server had java version 4.1.2 20080704 (Red Hat 4.1.2-51) which was not in solr's liking

Problem: Gems don't install anymore, in ruby 1.8.7
Solution: type gem list and you will see something like
Invalid gemspec in [C:/Ruby187/lib/ruby/gems/1.8/specifications/geo_calc-0.7.6.gemspec]: invalid date format in specification: "2011-06-21 00:00:00.000000000Z"
Invalid gemspec in [C:/Ruby187/lib/ruby/gems/1.8/specifications/geo_point-0.2.5.gemspec]: invalid date format in specification: "2011-06-20 00:00:00.000000000Z"

OR 

Could not find jquery-rails-1.0.19 in any of the sources?[0m
Run `bundle install` to install missing gems.?[0m


Go into: C:\Ruby187\lib\ruby\gems\1.8\specifications, open the gemspec files of the gems that won't install with invalid date.
Search:" 00:00:00.000000000Z"
replace with nothing

Problem: undefined method `ckeditor_textarea' for #
Solution: You have just installed a plugin and it doesn't seems to be installed. You are running WebBrick. You just need to restart WebBrick.



Problem: When sending email on bluehost:
OpenSSL::SSL::SSLError (hostname was not match with the server certificate):
  /home3/chamelf5/ruby/lib/ruby/1.8/openssl/ssl-internal.rb:123:in `post_connection_check'
  /home3/chamelf5/ruby/lib/ruby/1.8/net/smtp.rb:582:in `tlsconnect'
  /home3/chamelf5/ruby/lib/ruby/1.8/net/smtp.rb:562:in `do_start'
  /home3/chamelf5/ruby/lib/ruby/1.8/net/smtp.rb:525:in `start'
  app/models/user_mailer.rb:35:in `deliver!'

Solution:
Remove SSL, add this to your production.rb (or another .rb):
ActionMailer::Base.smtp_settings[:enable_starttls_auto] = false

Problem:
register_controller.rb:44: syntax error, unexpected ')', expecting 
tASSOC 
Solution:
Add [] around your query and attributes:
 - @existingSupplier = Supplier.first(:conditions => "name = ?", supplier_name)
 + @existingSupplier = Supplier.first(:conditions => ["name = ?", supplier_name])

Problem: gem install json_pure installs, but after it doesnt appear in the gem list, and require "json" doesnt work
Problem:
Copied default spellings.txt to D:/Webpages.SVN/community-buy.com/solr/conf
Copied default stopwords.txt to D:/Webpages.SVN/community-buy.com/solr/conf
Copied default synonyms.txt to D:/Webpages.SVN/community-buy.com/solr/conf
Exception in thread "main" java.lang.NoClassDefFoundError: '-Djava/util/logging/config/file=C:/DOCUME~1/Eucloid/Temp/logging/properties20111108-19340-1t7qt7i-0'
Caused by: java.lang.ClassNotFoundException: '-Djava.util.logging.config.file=C:.DOCUME~1.Eucloid.Temp.logging.properties20111108-19340-1t7qt7i-0'
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: '-Djava.util.logging.config.file=C:/DOCUME~1/Eucloid/Temp/logging.properties20111108-19340-1t7qt7i-0'.  Program will exit.

Solution:
Patch [RUBY_INSTALL]\lib\ruby\gems\1.8\gems\sunspot-1.2.1\lib\sunspot\server.rb, line 74
      -  exec(Escape.shell_command(command))
      +  exec(Escape.shell_command(command).gsub("'",'"'))

Problem:
rake aborted!
Anonymous modules have no name to be referenced by
D:/Webpages.SVN/community-buy.com/vendor/rails/activesupport/lib/active_support/dependencies.rb:611:in `to_constant_name'
My ActiveSupport version = 2.3.12, also tried
My Sunspot version = 1.2.0

Solution:
Upgrade activesupport ?!? Or fix the calling gem that triggered this. In my case it was sunspot, downgrading to v=1.1.0 for both sunspot and sunspot_rails worked.

Problem:
=> Booting Mongrel
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
C:/Ruby187/lib/ruby/gems/1.8/gems/sunspot_rails-1.1.0/lib/sunspot/rails/tasks.rb:1: undefined method `namespace' for main:Object (NoMethodError)
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:57:in `gem_original_require'
        from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:57:in `require'
        from D:/Webpages.SVN/community-buy.com/vendor/rails/activesupport/lib/active_support/dependencies.rb:182:in `require'

and also:

C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
script/server:5
Missing these required gems:
  sunspot_rails

You're running:
  ruby 1.8.7.352 at C:/Ruby187/bin/ruby.exe
  rubygems 1.7.2 at /home/oligny/private/ruby/lib/ruby/gems/1.8:/home/oligny/private/gem:/home/oligny/private/ruby/lib/rubygems, /home/oligny/private/ruby/gems/

Run `rake gems:install` to install the missing gems.


Solution:
In environment.rb, after the Rails::Initializer.run do |config| section, add EXACTLY:
  config.gem 'sunspot', :lib => 'sunspot'
  config.gem 'sunspot_rails', :lib => 'sunspot/rails'

Note that on the second line, the first part is sunspot_rails and the lib part is sunspot SLASH rails, otherwise it won't work.

Problem:
/home3/chamelf5/ruby/gems/gems/activerecord-2.3.12/lib/active_record/base.rb:1998:in `method_missing': undefined method `searchable' for # (NoMethodError)
        from /home3/chamelf5/public_html/cbuy/app/models/user.rb:15
Solution:
In my case when I do gem list, I get:
(...)
sunspot (1.2.1, 1.1.0)
sunspot_rails (1.2.1, 1.1.0)
Since I use ruby 1.8.7 with rails 2.3.12, only 1.1.0 works, so the solution is to uninstall 1.2.1 for both.




Problem:
/home/oligny/private/gem/gems/actionmailer-2.3.12/lib/action_mailer/base.rb:433:in `method_missing': undefined method `default' for Mailer:Class (NoMethodError)
        from /home/oligny/www/cbuy/app/models/mailer.rb:3

Solution:
You are using a too old version of actionmailer

Problem:
/home/oligny/www/premailer/premailer/lib/premailer/adapter.rb:41:in `default': No suitable adapter for Premailer was found, please install hpricot or nokogiri (RuntimeError)
        from /home/oligny/www/premailer/premailer/lib/premailer/adapter.rb:21:in `use'
        from /home/oligny/www/premailer/premailer/lib/premailer/premailer.rb:129:in `initialize'
        from premailer/bin/premailer:87:in `new'
        from premailer/bin/premailer:87
Solution:
 
Problem:
undefined local variable or method `logger' for FileColumn::ImgProcessorExtension:Module

Solution:
logger.info("text here") => Rails.logger.info("text here")

Problem:
Gem::LoadError in ProductsController#index
RubyGem version error: rmagick(2.7.1 not >= 0)
gem list shows that I have installed rmagick (2.7.1 mswin32)

Solution:
I had the very same problem in Ruby 1.8.7 as you with 1.9.1. This is a way I've resolved it:

Uninstall the rmagick gem if you have it (gem uninstall rmagick)
Download http://rubyforge.org/frs/download.php/64917/RMagick-2.12.0-ImageMagick-6.5.6-8-Q8.zip
Unpack the zip to separate folder (e.g. C:\temp\rmagick)
Install the ImageMagick-6.5.6-8-Q8-windows-dll.exe
Unpack the rmagick-2.12.0-x86-mswin32.gem to separate folder (e.g. C:\temp\rmagick\gem)
Extract the data.tar.gz to separate folder (e.g. C:\temp\rmagick\gem\data)
Open rmagick.gemspec and remove the line with s.platform = "mswin32"
Use "gem build rgmagick.gemspec" to build the gem again (a "rmagick-2.12.0.gem" will be generated)
Use "gem install rmagick --local" to install it.
Credits to Martin Cohen
Problem:
NameError in ProductsController#index

uninitialized constant FileColumn::ClassMethods::Inflector
RAILS_ROOT: D:/Webpages.SVN/community-buy.com
Solution: Add ActiveSupport:: in front of Inflector.underscore(self.name).to_s, in file file_column.rb:
      my_options = FileColumn::init_options(options, 
                                            ActiveSupport::Inflector.underscore(self.name).to_s,
                                            attr.to_s)



Problem:
NoMethodError in ProductsController#index

undefined method `file_column' for #
RAILS_ROOT: D:/Webpages.SVN/community-buy.com

Application Trace | Framework Trace | Full Trace
D:/Webpages.SVN/community-buy.com/vendor/rails/activerecord/lib/active_record/base.rb:1964:in `method_missing'

Solution: You need to install file_column as a plugin, not only as a gem
Problem:
gem install rmagick
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
        ERROR: Failed to build gem native extension.

        C:/Ruby187/bin/ruby.exe extconf.rb
checking for Ruby version >= 1.8.5... yes
Invalid drive specification.
Unable to get ImageMagick version
*** 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=C:/Ruby187/bin/ruby


Gem files will remain installed in C:/Ruby187/lib/ruby/gems/1.8/gems/rmagick-2.13.1 for inspection.
Results logged to C:/Ruby187/lib/ruby/gems/1.8/gems/rmagick-2.13.1/ext/RMagick/gem_make.out

Solution: On windows, dont install gem rmagick, but install gem rmagick-win32

Problem: The DevKit does not install correctly. I follow exactly the instructions but aftewards all gem install requiring DevKit fails with :
gem install rdiscount --platform=ruby
ERROR:  Error installing rdiscount:
        The 'rdiscount' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'

Solution: erase these files:
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/defaults/operating_system.rb
C:/Ruby187/lib/ruby/site_ruby/devkit.rb

Then re-run the DevKit install:
C:\Ruby187\devkit>ruby dk.rb install
[INFO] Installing C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/defaults/operating_system.rb
[INFO] Installing C:/Ruby187/lib/ruby/site_ruby/devkit.rb

C:\Ruby187\devkit>gem install rdiscount --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed rdiscount-1.6.8
1 gem installed
Installing ri documentation for rdiscount-1.6.8...
Installing RDoc documentation for rdiscount-1.6.8...

Yeah!!

Problem:
How to install RMagick on Linux for a Ruby 1.8.7 installation, in a custom install dir.


Solution:
Download rmagick-2.13.1.gem
gem install rmagick --install-dir /home/oligny/private/gem
Problem: NameError (uninitialized constant UsersController::Mailer): app/controllers/users_controller.rb:14:in `create' dispatch.cgi:23 Solution: Problem: $ rake generate_session_store (in /home/oligny/www/tracker) Missing the i18n 0.4.2 gem. Please `gem install -v=0.4.2 i18n` Solution: Upload your .gem to a specific folder (/home/oligny/private/gem), then use the --install-dir option $ gem install -v=0.4.2 i18n --install-dir /home/oligny/private/gem Then $ rake generate_session_store passes ALSO!! export GEM_PATH=$HOME/.gem:/home/oligny/private/gem export PATH=/home/oligny/private/ruby/bin/:$PATH export GEM_HOME=/home/oligny/private/gem/ - download and extract ruby gem, ruby setup.rb --prefix=/home/oligny/private/gem Problem: oligny@s483:/home/oligny/www/tracker/public$ ruby ./dispatch.cgi /home/oligny/www/tracker/vendor/rails/activesupport/lib/active_support/whiny_nil.rb:52:in `method_missing': undefined method `env_table' for nil:NilClass (NoMethodError) from /home/oligny/www/tracker/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:22:in `__send__' from /home/oligny/www/tracker/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:22:in `dispatch_cgi' from /home/oligny/www/tracker/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:101:in `dispatch_cgi' from /home/oligny/www/tracker/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:27:in `dispatch' from ./dispatch.cgi:10 Solution:? gem install passenger-2.2.0.gem --install-dir /home/oligny/private/gem gem uninstall passenger-2.2.0 --install-dir /home/oligny/private/gem other solution << I tracked the problem to a point where it seems that cgi object that needs to be passed to rails/actionpack/lib/action_controller/cgi_process.rb:22 just isn't created somehow. Creating it manually in dispatch.cgi and passing it on, like this: require 'cgi' Dispatcher.dispatch(CGI.new). Also this patch to cgi_process.rb (in redmine) --- ../src/redmine-1.2.0/./vendor/rails/actionpack/lib/action_controller/cgi_process.rb 2011-05-31 02:53:34.000000000 +1000 +++ ./vendor/rails/actionpack/lib/action_controller/cgi_process.rb 2011-06-12 16:09:27.000000000 +1000 @@ -19,7 +19,7 @@ end def self.dispatch_cgi(app, cgi, out = $stdout) - env = cgi.__send__(:env_table) + env = cgi.__send__(:env_table).to_hash env.delete "HTTP_CONTENT_LENGTH" cgi.stdinput.extend ProperStream @@ -48,7 +48,7 @@ headers['Status'] = status.to_s - if headers.include?('Set-Cookie') + if headers.include?('Set-Cookie') and headers['Set-Cookie'] != nil headers['cookie'] = headers.delete('Set-Cookie').split("\n") end and the following patch to ruby: --- ../src/ruby-1.8.7-p334/lib/cgi.rb 2009-12-14 13:40:07.000000000 +1100 +++ ../lib/ruby/1.8/cgi.rb 2011-06-12 19:23:41.000000000 +1000 @@ -551,7 +551,7 @@ options["type"] = "text/html" end - if options.has_key?("charset") + if options.has_key?("charset") and options["charset"] != nil options["type"] += "; charset=" + options.delete("charset") end @@ -588,13 +588,19 @@ buf += "Connection: " + options.delete("connection") + EOL end - buf += "Content-Type: " + options.delete("type") + EOL + if options.has_key?("type") and options["type"] != nil + buf += "Content-Type: " + options.delete("type") + EOL + elsif options.has_key?("Content-Type") and options["Content-Type"] != nil + buf += "Content-Type: " + options.delete("Content-Type") + EOL + else + buf += "Content-Type: " + "text/plain" + EOL + end if options.has_key?("length") buf += "Content-Length: " + options.delete("length").to_s + EOL end - if options.has_key?("language") + if options.has_key?("language") and options["language"] != nil buf += "Content-Language: " + options.delete("language") + EOL end >> -- http://www.redmine.org/issues/4610 Problem: Rails 2.3.11 is required and my host only has Rails 2.2.3 Solution: gem install -v=2.3.11 rails --install-dir /home/oligny/private/gem update: gem install -v=2.3.12 rails --install-dir /home/oligny/private/gem Problem: chamelf5@chameleonsoasis.com [~/public_html/cbuy]# ./public/dispatch.cgi /home3/chamelf5/ruby/lib/ruby/1.8/cgi.rb:555:in `+': can't convert nil into String (TypeError) from /home3/chamelf5/ruby/lib/ruby/1.8/cgi.rb:555:in `header' from /home3/chamelf5/ruby/gems/gems/actionpack-2.3.12/lib/action_controller/cgi_process.rb:55:in `dispatch_cgi' from /home3/chamelf5/ruby/gems/gems/actionpack-2.3.12/lib/action_controller/dispatcher.rb:101:in `dispatch_cgi' from /home3/chamelf5/ruby/gems/gems/actionpack-2.3.12/lib/action_controller/dispatcher.rb:27:in `dispatch' from ./public/dispatch.cgi:24 Solution: Patch cgi.rb (written elsewhere in this page) Problem: C:/Ruby192/lib/ruby/1.9.1/net/http.rb:678:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError) Solution: Problem: C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:53:in `require': no such file to load -- initializer (LoadError) from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:53:in `require' Solution: No idea Problem: Status: 500 Internal Server Error You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.split /home/oligny/www/tracker/vendor/rails/actionpack/lib/action_controller/request.rb:337:in `query_string' Solution: export REQUEST_URI=http://tracker.oligny.com/?hello=world Problem: Ruby needs to be patched but I am on a hosted server and does not control the ruby installation. Solution: Install ruby in your home folder by compiling it from sources, full instructions: (package ruby-1.8.7-p352.zip) ./configure --prefix=/home/oligny/private/ruby make make install (package rubygems-1.6.2.zip) Install rubygem: (!! also the one to use in ssh, this is the one to use in linux !!) export GEM_PATH=/home/oligny/private/ruby/lib/ruby/gems/1.8:/home/oligny/private/gem export PATH=/home/oligny/private/ruby/bin/:/home/oligny/private/ruby/gem/bin:$PATH export GEM_HOME=/home/oligny/private/ruby/gems/ export RUBYLIB=/home/oligny/private/ruby/lib/ruby:/home/oligny/private/ruby/lib:/home/oligny/private/ruby/lib/ruby/site_ruby/1.8 - download and extract ruby gem, # dont do that, dont use prefix here!!! :ruby setup.rb --prefix=/home/oligny/private/ruby, just do: ruby setup.rb (package mysql, no pre-download: live-download: mysql-2.8.1.gem) gem install mysql --install-dir /home/oligny/private/gem Problem: /home3/chamelf5/ruby/gems/gems/actionpack-2.3.12/lib/action_controller/cgi_process.rb:29:in `update': can't convert IO into String (TypeError) Solution: Patch actionpack's cgi_process.rb like said at another place in this page, which is : line 20: - env = cgi.__send__(:env_table) + env = cgi.__send__(:env_table).to_hash Problem: (with Rack 1.1.2) Status: 500 Internal Server Error Illegal seek /home/oligny/private/gem/gems/rack-1.1.2/lib/rack/request.rb:155:in `rewind' /home/oligny/private/gem/gems/rack-1.1.2/lib/rack/request.rb:155:in `POST' /home/oligny/private/gem/gems/rack-1.1.2/lib/rack/methodoverride.rb:15:in `call' /home/oligny/www/tracker/vendor/rails/actionpack/lib/action_controller/params_parser.rb:15:in `call' /home/oligny/www/tracker/vendor/rails/actionpack/lib/action_controller/session/cookie_store.rb:99:in `call' /home/oligny/www/tracker/vendor/rails/actionpack/lib/action_controller/failsafe.rb:26:in `call' /home/oligny/private/gem/gems/rack-1.1.2/lib/rack/lock.rb:11:in `call' /home/oligny/private/gem/gems/rack-1.1.2/lib/rack/lock.rb:11:in `synchronize' /home/oligny/private/gem/gems/rack-1.1.2/lib/rack/lock.rb:11:in `call' /home/oligny/www/tracker/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:114:in `call' /home/oligny/www/tracker/vendor/rails/actionpack/lib/action_controller/reloader.rb:34:in `run' /home/oligny/www/tracker/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:108:in `call' /home/oligny/www/tracker/vendor/rails/actionpack/lib/action_controller/cgi_process.rb:44:in `dispatch_cgi' /home/oligny/www/tracker/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:101:in `dispatch_cgi' /home/oligny/www/tracker/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:27:in `dispatch' dispatch.cgi:42 Solution: Patch on request.rb line 155 - @env["rack.input"].rewind + @env["rack.input"].rewind if @env["rack.input"].is_a? StringIO || !@env["rack.input"].stat.chardev? Patch on utils.rb line 451 - input.rewind + input.rewind if input.rewind.is_a? StringIO || !input.rewind.stat.chardev? Problem: Redmine on Apache with dispatch.cgi is VERY SLOW !!! Like 10 seconds par page Top 1 solution :) ruby script/server webrick -e production -p 2525 then redirect .htaccess to this port Solution not working: Install fastcgi gem install -v=2.4.0 fcgi --install-dir /home/oligny/private/gem ./configure --prefix=/home/oligny/private/ruby/fcgi --exec-prefix=/home/oligny/private/ruby/fcgi make make install if you get the following error, add #include to start of fcgio.cpp. g++ -DHAVE_CONFIG_H -I. -I. -I.. -I../include -g -O2 -c fcgio.cpp -MT fcgio.lo -MD -MP -MF .deps/fcgio.TPlo -fPIC -DPIC -o .libs/fcgio.lo fcgio.cpp: In destructor 'virtual fcgi_streambuf::~fcgi_streambuf()': fcgio.cpp:50: error: 'EOF' was not declared in this scope fcgio.cpp: In member function 'virtual int fcgi_streambuf::overflow(int)': fcgio.cpp:70: error: 'EOF' was not declared in this scope fcgio.cpp:75: error: 'EOF' was not declared in this scope fcgio.cpp: In member function 'virtual int fcgi_streambuf::sync()': fcgio.cpp:86: error: 'EOF' was not declared in this scope fcgio.cpp:87: error: 'EOF' was not declared in this scope fcgio.cpp: In member function 'virtual int fcgi_streambuf::underflow()': fcgio.cpp:107: error: 'EOF' was not declared in this scope make[2]: *** [fcgio.lo] Error 1 make[2]: Leaving directory `/home/oligny/private/fcgi-2.4.0/libfcgi' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/home/oligny/private/fcgi-2.4.0' make: *** [all] Error 2 Then: #gem install fcgi --install-dir /home/oligny/private/gem --with-fcgi-include /home/oligny/private/ruby/fcgi/include gem install fcgi --install-dir /home/oligny/private/gem -r -- --with-fcgi-lib=/home/oligny/private/ruby/fcgi/lib --with-fcgi-include=/home/oligny/private/ruby/fcgi/include Install gem login gem install --install-dir /home/oligny/private/gem -v=2.1.6 authlogic https://github.com/binarylogic/authlogic.git Problem: On rails 2.3.X oligny@s483:/home/oligny/www/cbuy$ script/generate session user_session ./script/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:99:in `requirement': undefined local variable or method `version_requirements' for # (NameError) from /home/oligny/private/ruby/lib/rubygems/source_index.rb:269:in `search' from ./script/../config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:119:in `search' from /home/oligny/private/ruby/lib/rubygems.rb:247:in `activate' from /home/oligny/private/ruby/lib/rubygems.rb:1276:in `gem' from ./script/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:57:in `add_load_paths' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:299:in `add_gem_load_paths' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:299:in `each' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:299:in `add_gem_load_paths' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:132:in `process' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in `send' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in `run' from /home/oligny/www/cbuy/config/environment.rb:13 from /home/oligny/private/ruby/lib/rubygems/custom_require.rb:36:in `gem_original_require' from /home/oligny/private/ruby/lib/rubygems/custom_require.rb:36:in `require' from /home/oligny/www/cbuy/vendor/rails/railties/lib/commands/generate.rb:1 from /home/oligny/private/ruby/lib/rubygems/custom_require.rb:36:in `gem_original_require' from /home/oligny/private/ruby/lib/rubygems/custom_require.rb:36:in `require' Solution: in environment.rb if Gem::VERSION >= "1.3.6" module Rails class GemDependency def requirement r = super (r == Gem::Requirement.default) ? nil : r end end end end Problem: on Rails 2.3.X oligny@s483:/home/oligny/www/cbuy$ script/generate session user_session /home/oligny/www/cbuy/vendor/rails/activesupport/lib/active_support/dependencies.rb:55: uninitialized constant ActiveSupport::Dependencies::Mutex (NameError) from /home/oligny/private/ruby/lib/rubygems/custom_require.rb:36:in `gem_original_require' from /home/oligny/private/ruby/lib/rubygems/custom_require.rb:36:in `require' from /home/oligny/www/cbuy/vendor/rails/activesupport/lib/active_support.rb:56 from /home/oligny/private/ruby/lib/rubygems/custom_require.rb:36:in `gem_original_require' from /home/oligny/private/ruby/lib/rubygems/custom_require.rb:36:in `require' from /home/oligny/www/cbuy/vendor/rails/activerecord/lib/active_record.rb:25 from /home/oligny/private/ruby/lib/rubygems/custom_require.rb:36:in `gem_original_require' from /home/oligny/private/ruby/lib/rubygems/custom_require.rb:36:in `require' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:266:in `require_frameworks' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:266:in `each' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:266:in `require_frameworks' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:134:in `process' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in `send' from ./script/../config/../vendor/rails/railties/lib/initializer.rb:113:in `run' from /home/oligny/www/cbuy/config/environment.rb:24 from /home/oligny/private/ruby/lib/rubygems/custom_require.rb:36:in `gem_original_require' from /home/oligny/private/ruby/lib/rubygems/custom_require.rb:36:in `require' from /home/oligny/www/cbuy/vendor/rails/railties/lib/commands/generate.rb:1 from /home/oligny/private/ruby/lib/rubygems/custom_require.rb:36:in `gem_original_require' from /home/oligny/private/ruby/lib/rubygems/custom_require.rb:36:in `require' from script/generate:3 Solution: Add require thread before require boot: require 'thread' # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') Problem: "authlogic" is already installed but script/generate keeps complaining. oligny@s483:/home/oligny/www/cbuy$ script/generate session user_session Missing these required gems: authlogic You're running: ruby 1.8.7.352 at /home/oligny/private/ruby/bin/ruby rubygems 1.6.2 at /home/oligny/private/ruby/lib/ruby/gems/1.8, /home/oligny/private/gem, /home/oligny/private/ruby/lib/rubygems, /home/oligny/private/ruby/gems/ Run `rake gems:install` to install the missing gems. Solution: in environment.rb gem 'authlogic', '=2.1.6' config.gem "authlogic" Problem: oligny@s483:/home/oligny/www/cbuy/public$ ./dispatch.cgi ./../config/environment.rb:19: uninitialized constant Gem (NameError) from ./dispatch.cgi:3:in `require' from ./dispatch.cgi:3 Solution: Remove the Gem:: stuff in your environment.rb (partial solution because it breaks the scripts/generate) Problem: /home/oligny/private/gem/gems/actionpack-2.3.12/lib/action_controller/cgi_process.rb:22:in `__send__': undefined method `env_table' for nil:NilClass (NoMethodError) from /home/oligny/private/gem/gems/actionpack-2.3.12/lib/action_controller/cgi_process.rb:22:in `dispatch_cgi' from /home/oligny/private/gem/gems/actionpack-2.3.12/lib/action_controller/dispatcher.rb:101:in `dispatch_cgi' from /home/oligny/private/gem/gems/actionpack-2.3.12/lib/action_controller/dispatcher.rb:27:in `dispatch' from ./dispatch.cgi:17 Solution: Do the patch as above to cgi_process.rb Problem: Status: 500 Internal Server Error private method `split' called for nil:NilClass /home/oligny/private/gem/gems/actionpack-2.3.12/lib/action_controller/request.rb:337:in `query_string' /home/oligny/private/gem/gems/rack-1.1.2/lib/rack/request.rb:127:in `GET' Solution: Problem: oligny@s483:/home/oligny/www/cbuy/script$ /home/oligny/private/gem/gems/rake-0.9.2/bin/rake db:migrate RAILS_ENV=production (in /home/oligny/www/cbuy) rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+) rake aborted! uninitialized constant RDoc Solution: gem install --install-dir /home/oligny/private/gem rdoc gem install --install-dir /home/oligny/private/gem rdoc-data Then edit Rakefile: replace require 'rake/rdoctask' with require 'rdoc/task' Problem: On windows, Ruby 1.8.7 from (rubyinstaller-1.8.7-p352.exe) With rails 3.1.0 C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:53:in `gem_original_require': no such file to load -- initializer (LoadError) from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:53:in `require' from ./../config/boot.rb:55:in `load_initializer' from ./../config/boot.rb:38:in `run' from ./../config/boot.rb:11:in `boot!' from ./../config/boot.rb:110 from server:2:in `require' from server:2 Solution: Put in vendor railties Problem: D:/Webpages.SVN/community-buy.com/vendor/rails/activesupport/lib/active_support/dependencies.rb:55: uninitialized constant ActiveSupport::Dependencies::Mutex (NameError) from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require' from D:/Webpages.SVN/community-buy.com/vendor/rails/activesupport/lib/active_support.rb:56 from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require' from D:/Webpages.SVN/community-buy.com/vendor/rails/railties/lib/commands/server.rb:1 from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require' from server:3 Solution: Add require 'thread' a little bit above the require that crashes, in my case in script/server, before require boot Problem: ./../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:99:in `requirement': undefined local variable or method `version_requirements' for # (NameError) from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:281:in `search' from ./../config/../vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:119:in `search' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:243:in `activate_dep' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:236:in `activate' from C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems.rb:1307:in `gem' from ./../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:57:in `add_load_paths' from ./../config/../vendor/rails/railties/lib/initializer.rb:299:in `add_gem_load_paths' from ./../config/../vendor/rails/railties/lib/initializer.rb:299:in `each' from ./../config/../vendor/rails/railties/lib/initializer.rb:299:in `add_gem_load_paths' from ./../config/../vendor/rails/railties/lib/initializer.rb:132:in `process' from ./../config/../vendor/rails/railties/lib/initializer.rb:113:in `send' from ./../config/../vendor/rails/railties/lib/initializer.rb:113:in `run' from D:/Webpages.SVN/community-buy.com/config/environment.rb:35 Solution: Put this in the top part of environment.rb, unfortunately that breaks some other environment where Gem:: is not resolved if Gem::VERSION >= "1.3.6" module Rails class GemDependency def requirement r = super (r == Gem::Requirement.default) ? nil : r end end end end Howto install html5 boilerplate with compass and cie gem install --install-dir /home/oligny/private/gem compass gem install --install-dir /home/oligny/private/gem haml gem install --install-dir /home/oligny/private/gem html5-boilerplate Problem: ActionView::TemplateError (undefined method `html_safe' for #) on line #3 of app/views/layouts/application.html.haml: 1: !!! 5 2: -# http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither 3: -ie_html :class => 'no-js', :lang => 'en' do 4: %head 5: -# To render a different stylesheet partial inside the head (i.e. for admin layout) 6: -# just copy _stylesheets.html.haml, and point to that partial instead. C:/Ruby187/lib/ruby/gems/1.8/gems/html5-boilerplate-1.0.0/lib/app/helpers/html5_boilerplate_helper.rb:6:in `ie_tag' C:/Ruby187/lib/ruby/gems/1.8/gems/html5-boilerplate-1.0.0/lib/app/helpers/html5_boilerplate_helper.rb:17:in `ie_html' Solution: You require this file activesupport/lib/active_support/core_ext/string/output_safety.rb Which you can obtain by doing: Install activesupport gem -v=2.3.12, and the copy/paste it put it in app_root/vendors/rails/activesupport Problem: ActionView::TemplateError (undefined local variable or method `csrf_meta_tag' for #) on line #26 of app/views/layouts/_head.html.haml: 23: -# Modernizr enables HTML5 elements & feature detects; Respond is a polyfill for min/max-width CSS3 Media Queries 24: = javascript_include_tag 'modernizr.min', 'respond.min' 25: 26: = csrf_meta_tag app/views/layouts/_head.html.haml:26:in `_run_haml_app47views47layouts47_head46html46haml_locals_head_object_stylesheet_partial' Solution: If you are using Rails 2.3.X, remove csrf_meta_tag in your view/layout. I haven't find the correct fix yet, please let me know. Problem: In rails 2.3.X, haml files are not compiled nor used. Solution: Create a config/application.rb, and add it in: config.generators do |g| g.template_engine :haml # you can also specify a different test framework or ORM here # g.test_framework :rspec # g.orm :mongoid end Problem: While compiling ruby I get Search tclConfig.sh and tkConfig.sh............................... Fail to find [tclConfig.sh, tkConfig.sh] Use X11 libraries (or use TK_XINCLUDES/TK_XLIBSW information on tkConfig.sh). Search tcl.h..... Search tk.h......Can't find "tcl.h". Can't find "tk.h". Can't find proper Tcl/Tk libraries. So, can't make tcltklib.so which is required by Ruby/Tk. compiling tk/tkutil compiling win32ole Solution: Problem: on Apache Status: 500 Internal Server Error File to import not found or unreadable: html5-boilerplate. Load path: /home/oligny/www/cbuy/public/stylesheets/sass /home/oligny/www/cbuy/public/stylesheets/sass/style.scss:5 /home/oligny/private/gem/gems/sass-3.1.10/rails/../lib/sass/../sass/tree/import_node.rb:64:in `import' Problem: I want to read the documentation for rails 2.3.X version, but all I find is about 3.X Solution: http://guides.rubyonrails.org/v2.3.11/ Genera Info: If you got problems when running a "rake" command (e.g. rake db:migrate:reset), the file that affects the environment is Rakefile If you got problems when it's running the webserver, it's in environment.rb and one of the production/testing.rb Problem: /home/oligny/private/ruby/lib/rubygems.rb:284:in `activate': Unable to activate geo_calc-0.7.7.1, because activesupport-2.3.12 conflicts with activesupport (>= 3.0.1) (Gem::LoadError) Solution: * patch geo_calc to allow old activesupport (in the gems/specifications/geo_calc-0.7.6.gemspec), change at several places - s.add_runtime_dependency(%q, [">= 3.0.1"]) + s.add_runtime_dependency(%q, [">= 2.0.1"]) # was 3.0.1 Problem: /home/oligny/private/ruby/lib/rubygems/custom_require.rb:36:in `gem_original_require': /home/oligny/private/gem/gems/geo_units-0.3.1.1/lib/geo_units.rb:45: syntax error, unexpected '=', expecting '|' (SyntaxError) define_singleton_method "#{unit_type}_to" do |unit, number = 0| Solution: ?? Problem : root@bronze:/var/cbuy# gem install geo-distance -v=0.2.0 ERROR: While executing gem ... (Gem::DependencyError) Unable to resolve dependencies: geo_calc requires geo_units (>= 0.3.1.1) Solution: The order to install gems for geo-distance is crucial to not get dependancies error. The working order is only : gem install sugar-high -v=0.4.6.3 gem install geo_units -v=0.2.4.1 gem install geo_calc -v=0.7.6 gem install geo_units -v=0.3.1.1 gem install geo-distance -v=0.2.0 Problem: gem install mysql root@bronze:/home# gem install mysql Fetching: mysql-2.9.1.gem (100%) Building native extensions. This could take a while... ERROR: Error installing mysql: ERROR: Failed to build gem native extension. /usr/bin/ruby1.8 extconf.rb checking for mysql_query() in -lmysqlclient... no checking for main() in -lm... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lz... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lsocket... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lnsl... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lmygcc... no checking for mysql_query() in -lmysqlclient... no *** 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. In /var/lib/gems/1.8/gems/mysql-2.9.1/ext/mysql_api/mkmf.log we can find this error among others : /usr/bin/ld: error: cannot find -lmysqlclient Solution : $> sudo apt-get install libmysqlclient-dev Then installation goes smoothly : root@bronze:~# gem install mysql Building native extensions. This could take a while... Successfully installed mysql-2.9.1 1 gem installed Installing ri documentation for mysql-2.9.1... Installing RDoc documentation for mysql-2.9.1... Problem : NoMethodError: undefined method `empty?' for :needs:Symbol Line of code in /var/lib/gems/1.8/gems/sunspot_rails-1.1.0/lib/sunspot/rails/tasks.rb:41 : task :reindex, :batch_size, :models, :needs => :environment do |t, args| Explanation : WARNING: 'task :t, arg, :needs => [deps]' is deprecated. Please use 'task :t, [args] => [deps]' instead. Solution: task :reindex, [:batch_size, :models] => :environment do |t, args| Problem: MissingSourceFile: no such file to load -- compass/app_integration/rails Solution: Your version of compass is wrong. Uninstall current one and install an older one. for example : gem uninstall compass -v=1.0.1 gem install compass -v=0.11.5 Problem: MissingSourceFile: no such file to load -- sass/script/node Solution: Your version of sass is wrong. Uninstall current one and install an older one. It will also uninstall compass. So you will have to reinstall. For example : $> gem uninstall sass -v=3.4.6 You have requested to uninstall the gem: sass-3.4.6 compass-0.11.5 depends on [sass (~> 3.1)] compass-core-1.0.1 depends on [sass (< 3.5, >= 3.3.0)] compass-import-once-1.0.5 depends on [sass (< 3.5, >= 3.2)] If you remove this gems, one or more dependencies will not be met. Continue with Uninstall? [Yn] Y $> gem install sass -v=3.1.10 $> gem install compass -v=0.11.5 ** Execute sunspot:reindex rake aborted! Errno::ECONNREFUSED: Connection refused - connect(2)


September 2011, Montreal