rake db:migrate aborted! on US-ASCII using rake 0.9.2.2 and rails 3.0.10 - ruby-on-rails-3

Recently I upgraded my gems and started adding new stuff to my app like authentication by third party social websites using omniauth gem. On development environment everything is fine and works like a charm.
I am deploying to staging and production servers using capistrano. Basic deployment is fine and working so far, but I have got really strange problems when I want to do migrations when deploying.
I get the following error messages from capistrano:
[my.server.com] executing command
*** [err :: my.server.com] rake aborted!
*** [err :: my.server.com] "\xC5" on US-ASCII
*** [err :: my.server.com]
*** [err :: my.server.com] (See full trace by running task with --trace)
command finished in 2472ms
I was googling all around and couldn't find any relevant solution. I also tried to downgrade rake gem back to 0.8.7 but with no success on the end - the same errors.

After hours of googling and digging in I found the solution that (I hope) may by helpful for someone with a similar or the same problem.
I did bundle exec rake --trace db:migrate on the staging server and got the following error messages:
rake aborted!
"\xC5" on US-ASCII
/var/www/myapp/test.myapp.com/releases/20111230233802/config/application.rb:5:in `read'
/var/www/myapp/test.myapp.com/releases/20111230233802/config/application.rb:5:in `<top (required)>'
/var/www/myapp/test.myapp.com/releases/20111230233802/Rakefile:4:in `require'
/var/www/myapp/test.myapp.com/releases/20111230233802/Rakefile:4:in `<top (required)>'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/bin/rake:19:in `load'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/bin/rake:19:in `<main>'
So I jumped in to the config/application.rb file to find out what could rise the error. Line 5 of that file loads an external config file:
require 'yaml'
APP_CONFIG = YAML.load(File.read(File.expand_path('../app_config.yml', __FILE__)))
and that external file contains UTF-8 chars, not US-ASCII. So I tried a couple of different solutions to solve that problem.
The only one which worked for me was to add an extra few lines of code on top of config/application.rb file:
if RUBY_VERSION =~ /1.9/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end
just to tell rake to load external files using utf-8 encoding. After that change everything went smooth and exactly as expected. Problem solved!
PS.
I really don't know why developers of rake 0.9 have changed previous behavior of rake 0.8 which worked fine for me and probably for you as well for a long time. Maybe you have an idea why? I am very curious.

Related

LoadError: incompatible library version with nokogiri 1.6.8.1

I am working on quite old project which is running on old version of Ruby and Rails.
Ruby Version = 1.9.3p551
Rails verison = 3.1.10
So when i am trying to configure this project on new machine the it shows
the error related to NOKOGIRI.
"LoadError: incompatible library version - /home/global/.rvm/gems/ruby-1.9.3-p551/gems/nokogiri-1.6.8.1/lib/nokogiri/nokogiri.so
/home/global/.rvm/gems/ruby-1.9.3-p551/gems/nokogiri-1.6.8.1/lib/nokogiri.rb:32:in require'
/home/global/.rvm/gems/ruby-1.9.3-p551/gems/nokogiri-1.6.8.1/lib/nokogiri.rb:32:inrescue in '
/home/global/.rvm/gems/ruby-1.9.3-p551/gems/nokogiri-1.6.8.1/lib/nokogiri.rb:28:in <top (required)>'
/var/www/glo/config/application.rb:7:in'
/var/www/glo/Rakefile:4:in <top (required)>'
LoadError: cannot load such file -- nokogiri/2.3/nokogiri
/home/global/.rvm/gems/ruby-1.9.3-p551/gems/nokogiri-1.6.8.1/lib/nokogiri.rb:30:inrequire'
/home/global/.rvm/gems/ruby-1.9.3-p551/gems/nokogiri-1.6.8.1/lib/nokogiri.rb:30:in <top (required)>'
/var/www/glo/config/application.rb:7:in'
/var/www/glo/Rakefile:4:in `'
(See full trace by running task with --trace)
global#del1-lhp-N01167:/var/www/glo$ ruby -v
ruby 1.9.3p551 (2014-11-13 revision 48407) [x86_64-linux]
"
I have tried many things but still this problem is not solved.
So please help me out from this.
Thanks

rails 3.2.9 bundler error

I am doing simple hello world project with rails but it seems it it throwing bundler error to me. I want to see how to remove the bundler errors that comes after i type
rails new helloproject
the errors in the console are:
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/source.rb:271:in `<class:Path>': uninitialized constant Bundler::GemInstaller (NameError)
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/source.rb:270:in `<module:Source>'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/source.rb:10:in `<module:Bundler>'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/source.rb:9:in `<top (required)>'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/dsl.rb:21:in `initialize'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/dsl.rb:6:in `new'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/dsl.rb:6:in `evaluate'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/definition.rb:18:in `build'
/usr/lib/ruby/vendor_ruby/bundler.rb:136:in `definition'
/usr/lib/ruby/vendor_ruby/bundler/cli.rb:222:in `install'
/usr/lib/ruby/vendor_ruby/bundler/vendor/thor/task.rb:22:in `run'
/usr/lib/ruby/vendor_ruby/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
/usr/lib/ruby/vendor_ruby/bundler/vendor/thor.rb:246:in `dispatch'
/usr/lib/ruby/vendor_ruby/bundler/vendor/thor/base.rb:389:in `start'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/bin/bundle:14:in `block in <main>'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/friendly_errors.rb:4:in `with_friendly_errors'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/bin/bundle:14:in `<main>'
There was an error in your Gemfile, and Bundler cannot continue.
I wonder how can i get past this error and bundle the application properly?
I do manage to run the server and run the hello world app but every new project seems to throw this bundler error.
I have checked similar questions but this one seems to be unique type of the error.
How to get rid of these bundler install errors?
Check the following steps,
gem install bundler
and after adding:
gem 'bundler'
in line 2 in config/boot.rb (just after require 'rubygems')
let me know if not solved.

Could not find cache store adapter for memory_store

For some reason anytime I'm running a Rails 3.0.3 application with Ruby 1.8.7. It's been running fine and I haven't set any cache_store settings anywhere. Now anytime I try to run rake tasks or rails command I get this:
$:rails console production
/home/marc_m3pt0/.gems/gems/activesupport-3.0.3/lib/active_support/cache.rb:65:in `lookup_store': Could not find cache store adapter for memory_store (no such file to load -- active_support/cache/memory_store) (RuntimeError)
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application/bootstrap.rb:48
from /home/marc_m3pt0/.gems/gems/activesupport-3.0.3/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
from /home/marc_m3pt0/.gems/gems/activesupport-3.0.3/lib/active_support/core_ext/kernel/reporting.rb:22:in `with_warnings'
from /home/marc_m3pt0/.gems/gems/activesupport-3.0.3/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application/bootstrap.rb:48
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `run_initializers'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `send'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
from /home/marc_m3pt0/m3pt0.com/config/environment.rb:5
from /home/marc_m3pt0/.gems/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
from /home/marc_m3pt0/.gems/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
from /home/marc_m3pt0/.gems/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
from /home/marc_m3pt0/.gems/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /home/marc_m3pt0/.gems/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
from /home/marc_m3pt0/.gems/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:239:in `require'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:103:in `require_environment!'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:22
from script/rails:6:in `require'
from script/rails:6
Any ideas on what I could be missing?
Thanks so much. My clients site is down right now so any help soon would be appreciated.
UPDATE
When I run rake tasks I get this:
Could not find cache store adapter for memory_store (no such file to load -- active_support/cache/memory_store)
I saw this error recently when a shared host moved an application to a new server. I ended up blowing away the application's bundle and reinstalling it, and it seemed to work.
I use Capistrano for deployment, so if you use something else, YMMV. If your application root is this:
/home/jeff/myapp/
with the following subdirectories:
/home/jeff/myapp/current
/home/jeff/myapp/releases
/home/jeff/myapp/shared
the gem bundle is here:
/home/jeff/myapp/shared/bundle
Then I did:
rm -rf /home/jeff/myapp/shared/bundle
then
cd /home/jeff/myapp
bundle install
Once I did this, it seemed to work for me.

"\xC4" from ASCII-8BIT to UTF-8 when running rake db:migrate on Heroku

When I try to run heroku run rake db:migrate in my application, I get the following error
"\xC4" from ASCII-8BIT to UTF-8
with a stacktrace of
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:150:in `write'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:150:in `puts'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:150:in `display_error_message'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:142:in `rescue in standard_exception_handling'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:132:in `standard_exception_handling'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `'
/app/.bundle/gems/ruby/1.9.1/bin/rake:19:in `load'
/app/.bundle/gems/ruby/1.9.1/bin/rake:19:in `'
I've tried setting encoding manually in config/environment.rb via
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
But it doesn't seem to help. The problem might be, that I'm using slim as a templating engine with many unicode characters directly in the templates, but I'm not sure if there's a better way of doing that.
Simply add this to the top of your file
# encoding: UTF-8
this error is frequent with migration when you insert data. For exemple I've got this with a simple migration adding Québec
Province.create(:name => 'Québec (Canada)')

Thin LoadError: no such file to load thin_parser

I have installed thin and try to do thin start, which end up with this error
C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': no such file to load -- C:/Ruby192/lib/ruby/gems/1.9.1/gems/thin-1.2.8-x86-mingw32/lib/1.9/thin_parser (LoadError)
from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thin-1.2.8-x86-mingw32/lib/thin.rb:48:in `rescue in <top (required)>'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thin-1.2.8-x86-mingw32/lib/thin.rb:43:in `<top (required)>'
from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/thin-1.2.8-x86-mingw32/bin/thin:5:in `<top (required)>'
from C:/Ruby192/bin/thin:19:in `load'
from C:/Ruby192/bin/thin:19:in `<main>'
Can someone help me out please, thanks in advance
the output denotes a directory called 1.9 i.e.
<ruby_install_dir>/lib/ruby/gems/1.9.1/gems/thin-1.2.8-x86-mingw32/lib/1.9/
Note: My thin version is 1.2.10. In the following i will use the path as it appears on my system.
For some reason the thin gem doesn't come with this directory. But a file called thin_parser.so resides in the parent directory <ruby_install_dir>/lib/ruby/gems/1.9.1/gems/thin-1.2.10/lib/
So my first solution was to create a directory 1.9 and copy the file thin_parser.so to it.
Now thin start works for me.
Alternatively you can edit the file <ruby_install_dir>/lib/ruby/gems/1.9.1/gems/thin-1.2.10/lib/thin.rb and change
if Thin.win?
# Select proper binary under Windows
major_ruby_version = RUBY_VERSION[/^(\d+\.\d+)/]
require "#{Thin::ROOT}/#{major_ruby_version}/thin_parser"
else
require "#{Thin::ROOT}/thin_parser"
end
to
if Thin.win?
# Select proper binary under Windows
major_ruby_version = RUBY_VERSION[/^(\d+\.\d+)/]
require "#{Thin::ROOT}/thin_parser"
else
require "#{Thin::ROOT}/thin_parser"
end
or even simpler
require "#{Thin::ROOT}/thin_parser"
I'm not sure what workaround is the better one, since i don't know what else files thin expects in the not existing directory. I don't know either where the Thin.win? fork becomes important.
I decided in favor of the first solution. But both ways fixed the Problem for me.
Best regards,
Tim
I ran into this same error when running rake db:migrate (I suspect thin start would have given me the same error.)
I'm running on Amazon Linux (rpm based, so similar to CentOS and Redhat). I had previously installed thin as root (gem install thin). Although it may be irrelevant to your situation, just for completeness, I had also installed eventmachine using:
gem install eventmachine --platform=ruby
Here is the error I got:
% rake db:migrate
rake aborted!
LoadError: cannot load such file -- thin_parser
/home/rails/.gem/ruby/1.9.1/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
etc. etc.
Based on the above information, I ran rake under strace and discovered that it was looking for thin_parser.so in the wrong place. I was able to fix the problem by installing this symbolic link (I did this as root since I installed thin as root). Obviously, adjust the path to where your version of thin is installed:
cd /usr/local/share/gems1.9/gems/thin-1.6.3/lib
ln -s ../ext/thin_parser/thin_parser.so .
Poof! That fixed it for me.