ruby 1.9.2 strange warning when running cucumber specs - ruby

I just updated to try rails 3, using rvm with ruby 1.9.2-p0.
When I run my cucumber specs then I get following strange warnings
/home/ubuntu/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/utils.rb:16: warning: regexp match /.../n against to UTF-8 string
/home/ubuntu/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/utils.rb:16: warning: regexp match /.../n against to UTF-8 string
/home/ubuntu/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/utils.rb:16: warning: regexp match /.../n against to UTF-8 string
My bundle contains following gems...
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.0)
Using builder (2.1.2)
Using i18n (0.4.1)
Using activemodel (3.0.0)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.4)
Using tzinfo (0.3.23)
Using actionpack (3.0.0)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.8)
Using mail (2.2.5)
Using actionmailer (3.0.0)
Using arel (1.0.1)
Using activerecord (3.0.0)
Using activeresource (3.0.0)
Using bundler (1.0.0)
Using culerity (0.2.12)
Using nokogiri (1.4.3.1)
Using ffi (0.6.3)
Using json_pure (1.4.6)
Using rubyzip (0.9.4)
Using selenium-webdriver (0.0.28)
Using capybara (0.3.9)
Using configuration (1.1.0)
Using diff-lcs (1.1.2)
Using trollop (1.16.2)
Using gherkin (2.1.5)
Using term-ansicolor (1.0.5)
Using cucumber (0.8.5)
Using cucumber-rails (0.3.2)
Using database_cleaner (0.5.2)
Using launchy (0.3.7)
Using mysql2 (0.2.3)
Using rspec-core (2.0.0.beta.20)
Using rspec-expectations (2.0.0.beta.20)
Using rspec-mocks (2.0.0.beta.20)
Using rspec (2.0.0.beta.20)
Using yard (0.6.0)
Using pickle (0.4.2)
Using thor (0.14.0)
Using railties (3.0.0)
Using rails (3.0.0)
Using rspec-rails (2.0.0.beta.20)
Using spork (0.8.4)
Using webrat (0.7.1)
does anyone know how to get rid of these warnings? And where they are coming from?

There is a good solution available to this that I found on a blog post by Enrico Stahn:
http://blog.enricostahn.com/warning-regexp-match-n-against-to-utf-8-strin
The problem is in Rack and has apparently already been fixed in 1.3.0 but you may not be able to upgrade to it yet.
So until you can upgrade to Rack 1.3.0, create the file config/initializers/rack_hotfix.rb with the following content:
# TODO: Can be removed after updating to rack 1.3.0
module Rack
module Utils
def escape(s)
CGI.escape(s.to_s)
end
def unescape(s)
CGI.unescape(s)
end
end
end
This worked a charm for me and then I supplemented it with a pending test to on of my RSpec files as a gentle reminder to drop the initializer once Rack's been upgraded.
describe ApplicationController do
...
it "should not include the rack_hotfix.rb initializer after upgrading to rack 1.3.0"
end

See:
https://github.com/jnicklas/capybara/issues/87 and https://github.com/jnicklas/capybara/issues/243
for some discussion of the issue. The resolution seems to be that both Capybara and Rack needed to change some things to arrive at a good solution.
If I'm understanding correctly, Rack 1.3 and Capybara 1.0 should solve the issue. At the moment though, Rails 3.0.8 still requires Rack ~> 1.2.1, ignoring Rack 1.3 even if you have it installed. So I think Rails (specifically actionpack) will need to upgrade its dependency to have a clean fix.

There is a gem called "escape_utils" that takes care of this problem. Here is the link to an article explaining the problem.

Add this to a file in features/support or put it in the env.rb file:
# Stop endless errors like
# ~/.rvm/gems/ruby-1.9.2-p0#global/gems/rack-1.2.1/lib/rack/utils.rb:16:
# warning: regexp match /.../n against to UTF-8 string
$VERBOSE = nil
This will suppress those warnings, though I am not sure what is causing them in the first place. I am getting them, also

Maybe your scripts are encoded in ASCII or a different format from UTF-8?

Related

How to debug Middleman 3 gem installation issues on Windows.

I have installed Middleman 3.1.5 as described on my Windows 8 Machnine along with Ruby using rubyinstaller-2.0.0-p247.exe and followed the steps to get started with success. I am now building my first site with some success (coding some pages, starting the server, building the site) but when I try to use some advanced third party components like middleman-navigation or middleman-deploy I seem to hit a wall. At first I thought of a mistake by myself but as more and more things seem to be buggy I want to figure out what is wrong with my setup or at least confirm nothing is.
Some example output that seems buggy to me:
$ middleman help
WARN: Unresolved specs during Gem::Specification.reset:
rack (>= 1.0, >= 1.4.5)
thor (< 2.0, >= 0.15.2)
activesupport (~> 3.2.6)
listen (~> 1.2.2)
i18n (~> 0.6.1)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
Tasks:
...
When i try to install middleman-deploy as described, adding gem "middleman-deploy" to my Gemfile and run bundle install there is no indication that anything changed:
$ bundle install
Using i18n (0.6.5)
Using multi_json (1.8.0)
Using activesupport (3.2.14)
Using chunky_png (1.2.8)
Using coffee-script-source (1.6.3)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using fssm (0.2.10)
Using sass (3.2.10)
Using compass (0.12.2)
Using eventmachine (1.0.3)
Using http_parser.rb (0.5.3)
Using em-websocket (0.5.0)
Using ffi (1.9.0)
Using tilt (1.3.7)
Using haml (4.0.3)
Using hike (1.2.3)
Using kramdown (1.1.0)
Using rb-fsevent (0.9.3)
Using rb-inotify (0.9.2)
Using rb-kqueue (0.2.0)
Using listen (1.2.3)
Using bundler (1.3.5)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using thor (0.18.1)
Using middleman-core (3.1.5)
Using middleman-more (3.1.5)
Using sprockets (2.10.0)
Using sprockets-helpers (1.0.1)
Using sprockets-sass (1.0.1)
Using middleman-sprockets (3.1.4)
Using uglifier (2.1.2)
Using middleman (3.1.5)
Using rack-livereload (0.3.15)
Using middleman-livereload (3.1.0)
Using wdm (0.1.0)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
I then add a configuration to config.rb and try to use the gem without success:
$ middleman deploy
WARN: Unresolved specs during Gem::Specification.reset:
rack (>= 1.0, >= 1.4.5)
thor (< 2.0, >= 0.15.2)
multi_json (~> 1.0)
rb-inotify (>= 0.9)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
There's no 'deploy' command for Middleman. Try 'middleman help' for a list of commands.
Please help me to narrow down the cause of these issues.
I had a similar WARN: Unresolved specs during Gem::Specification.reset: message when I did middleman build I'm on a Mac using rvm with ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0]. I found an issue post on GitHub with a similar WARN and the fix was to run gem regenerate_binstubs. It cleared the WARN for me. I'm not sure exactly what that does but it clears up a few issues with rubygems-bundler.

"Rake/rdoc task is obsolete" message ... and none of the fixes online here are working

I am a Rails & Ruby noob and was going through the Agile Web Development with Rails book. I did a routine rake command and got this familiar message:
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (ava
ilable in RDoc 2.4.2+) instead.
c:/rails_projects/depot/Rakefile:8:in `'
I searched Google thoroughly, tried editing my Gemfile a couple of times as suggested in other threads, updated rdoc gem, and still I get this error. I am running Rails 3.0.5, Ruby 1.9.3p392, rdoc 4.0.2. This is my bundle install:
Using rake (10.0.4)
Using abstract (1.0.0)
Using activesupport (3.0.5)
Using builder (2.1.2)
Using i18n (0.6.4)
Using activemodel (3.0.5)
Using erubis (2.6.6)
Using rack (1.2.8)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.37)
Using actionpack (3.0.5)
Using mime-types (1.22)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.2.19)
Using actionmailer (3.0.5)
Using arel (2.0.10)
Using activerecord (3.0.5)
Using activeresource (3.0.5)
Using json (1.7.7)
Using bundler (1.3.4)
Using thor (0.14.6)
Using railties (3.0.5)
Using rails (3.0.5)
Using rdoc (4.0.1)
Using sqlite3 (1.3.7)
And my Gemfile:
gem 'rails', '3.0.5'
gem 'sqlite3'
gem 'rdoc', ">= 4.0.1"
require 'rdoc/task'
I put that gem rdoc thing in based on one forum I found.
The bad require 'rake/rdoctask' call is happening in Rails itself. The simplest solution is probably to update Rails. You should be able to work through that book just fine using Rails 3.0.20.

uninitialized constant FactoryGirl::Evaluation::Observable

I'm trying to use factory_girl 4.2.0 with rspec 2.13.0. First I add 'factory_girl' to my Gemfile and bundle update:
Using aasm (3.0.16)
Using i18n (0.6.4)
Using multi_json (1.6.1)
Using activesupport (3.2.12)
Using builder (3.0.4)
Using activemodel (3.2.12)
Using arel (3.0.2)
Using tzinfo (0.3.36)
Using activerecord (3.2.12)
Using active_record_inline_schema (0.6.0)
Using tins (0.7.1)
Using amatch (0.2.11)
Using coderay (1.0.9)
Using conversions (1.4.6)
Using fastercsv (1.5.5)
Using fixed_width-multibyte (0.2.3)
Using hash_digest (1.0.0)
Using nokogiri (1.5.6)
Using rubyzip (0.9.9)
Using ruby-ole (1.2.11.6)
Using spreadsheet (0.8.2)
Using roo (1.10.3)
Using unix_utils (0.0.15)
Using remote_table (2.1.0)
Using to_regexp (0.2.0)
Using errata (1.1.1)
Using posix-spawn (0.3.6)
Using upsert (1.1.7)
Using data_miner (2.4.1)
Using diff-lcs (1.2.1)
Using httpclient (2.3.3)
Using method_source (0.8.1)
Using pg (0.14.1)
Using pg-hstore (1.1.7)
Using slop (3.4.3)
Using pry (0.9.12)
Using rspec-core (2.13.0)
Using rspec-expectations (2.13.0)
Using rspec-mocks (2.13.0)
Using rspec (2.13.0)
Using umarket1-package (0.2.0)
Using bundler (1.3.1)
Then in my spec_helper.rb I do:
require 'factory_girl'
but I get this error:
.rvm/gems/ruby-1.9.3-p327/gems/factory_girl-4.2.0/lib/factory_girl/evaluation.rb:5:in `<class:Evaluation>': uninitialized constant FactoryGirl::Evaluation::Observable (NameError)
Do I need to require something else before factory_girl?
probably you have a file that defines a Observer class (or even just a file called observer.rb) in some place.
https://github.com/thoughtbot/factory_girl/blob/af282a178b02ea9cc85b7b0767fce836a76108b4/lib/factory_girl/evaluation.rb#L1
and its loaded after you init your app (example in the lib folder).

Failed to build gem native extension ruby 2.0 upgrade fastthread

I am upgrading my system to ruby 2.0 and I have done everything short of throw my computer on the wall. I find it hard to believe that fastthread is the problem. Has anyone else seen this error when running 'bundle install'. Here is my ruby version
ruby -v
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.0]
when I try to run rails -v I get this
rails -v
Could not find fastthread-1.0.7 in any of the sources
Run bundle install to install missing gems.
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.0.3)
Using i18n (0.6.1)
Using multi_json (1.6.1)
Using activesupport (3.2.9)
Using builder (3.0.4)
Using activemodel (3.2.9)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.5)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.2.2)
Using actionpack (3.2.9)
Using mime-types (1.21)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.4.4)
Using actionmailer (3.2.9)
Using arel (3.0.2)
Using tzinfo (0.3.35)
Using activerecord (3.2.9)
Using activeresource (3.2.9)
Using bundler (1.3.0)
Using highline (1.6.15)
Using net-ssh (2.6.5)
Using net-scp (1.1.0)
Using net-sftp (2.1.1)
Using net-ssh-gateway (1.2.0)
Using capistrano (2.14.2)
Using chunky_png (1.2.7)
Using coffee-script-source (1.5.0)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.3)
Using json (1.7.7)
Using rdoc (3.12.2)
Using thor (0.17.0)
Using railties (3.2.9)
Using coffee-rails (3.2.2)
Using fssm (0.2.10)
Using sass (3.2.6)
Using compass (0.12.2)
Using compass-rails (1.0.3)
Using daemon_controller (1.1.1)
Installing fastthread (1.0.7)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/Users/ben/.rvm/rubies/ruby-2.0.0-p0/bin/ruby extconf.rb
extconf.rb:13:in `block in <main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:13:in `block in <main>': Use RbConfig instead of obsolete and deprecated Config.
make
Makefile:104: *** missing separator. Stop.
Gem files will remain installed in /Users/[me]/.rvm/gems/ruby-2.0.0-p0/gems/fastthread-1.0.7 for inspection.
Results logged to /Users/[me]/.rvm/gems/ruby-2.0.0-p0/gems/fastthread-1.0.7/ext/fastthread/gem_make.out
An error occurred while installing fastthread (1.0.7), and Bundler cannot
continue.
Make sure that `gem install fastthread -v '1.0.7'` succeeds before bundling.
Has anyone else ran into this?
Conents of /Users/[me]/.rvm/gems/ruby-2.0.0-p0/gems/fastthread-1.0.7/ext/fastthread/gem_mak‌​e.out
/Users/[me]/.rvm/rubies/ruby-2.0.0-p0/bin/ruby extconf.rb
extconf.rb:13:in `block in <main>': Use RbConfig instead of obsolete and deprecated Config.
extconf.rb:13:in `block in <main>': Use RbConfig instead of obsolete and deprecated Config.
make
Makefile:104: *** missing separator. Stop.
Phusion Passenger 4 has already solved this by removing the fastthread dependency. The 4.0 betas and RCs install just fine on Ruby 2.0.
If you use Passenger as your webserver you have to have this dependency. See this pull request for the fix: https://github.com/zoltankiss/fastthread/commit/a47a121990cf7d4f31147406c2d379dabc048479
The author of the gem has not yet included this fix. You can require fastthread from https://github.com/zoltankiss/fastthread if you need it. That is who submitted the pull request.

Rake 0.8.7 and ActiveSupport 3.0.1

I am running Ruby 1.9.2. I have rake 0.8.7 installed. However running rake inside a Rails application gives me the following:
(in /usr/home/users/dimitar/Rails/spek)
Could not find activesupport-3.0.1 in any of the sources
Try running `bundle install`.
So I go ahead and run bundle install again and everything looks good:
Fetching source index for http://rubygems.org/
Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.1)
Using builder (2.1.2)
Using i18n (0.4.1)
Using activemodel (3.0.1)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.6)
Using tzinfo (0.3.23)
Using actionpack (3.0.1)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.8)
Using mail (2.2.7)
Using actionmailer (3.0.1)
Using arel (1.0.1)
Using activerecord (3.0.1)
Using activeresource (3.0.1)
Using bundler (1.0.3)
Using thor (0.14.3)
Using railties (3.0.1)
Using rails (3.0.1)
Using sqlite3-ruby (1.3.1)
Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem is installed.
But rake still gives me the same error message. Any suggestions?
Actually the problem seems to come from the config/boot.rb file:
# Set up gems listed in the Gemfile.
gemfile = File.expand_path('../../Gemfile', __FILE__)
begin
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
rescue Bundler::GemNotFound => e
STDERR.puts e.message
STDERR.puts "Try running `bundle install`."
exit!
end if File.exist?(gemfile)
Do you have multiple Ruby interpreters installed (maybe via rvm or some other method)? If so, are you sure that the right one is active?
Things to look at:
which ruby
which rake
ruby -e 'puts $:' # To show the LOAD_PATH for gems
I had a similar problem using ruby-1.9.2 and fixed it by upgrading rubygems
sudo gem update --system
I had the same problem when I was using REE 1.8.7. I switched to 1.9.2 and did bundle install. Then my rake commands worked.
I had this issue when I mistakenly ran passenger with ruby 1.9.3 and the app used 1.8.7 in its .rvmrc. Fixed by using 1.9.3 (now I have encoding problems, but thats a different story).

Resources