Rails: OAuth gem dependency error w/ bundler? - ruby-on-rails

Trying to start the server and I'm getting this:
/Users/Ross/.rvm/gems/ruby-1.9.2-p180#webapp/gems/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require': no such file to load -- addressable/uri (LoadError)
from /Users/Ross/.rvm/gems/ruby-1.9.2-p180#webapp/gems/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `block in require'
from /Users/Ross/.rvm/gems/ruby-1.9.2-p180#webapp/gems/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `block in load_dependency'
from /Users/Ross/.rvm/gems/ruby-1.9.2-p180#webapp/gems/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:640:in `new_constants_in'
from /Users/Ross/.rvm/gems/ruby-1.9.2-p180#webapp/gems/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:223:in `load_dependency'
from /Users/Ross/.rvm/gems/ruby-1.9.2-p180#webapp/gems/ruby/1.9.1/gems/activesupport-3.1.3/lib/active_support/dependencies.rb:240:in `require'
from /Users/Ross/.rvm/gems/ruby-1.9.2-p180#webapp/gems/ruby/1.9.1/gems/faraday-0.7.5/lib/faraday/connection.rb:1:in `<top (required)>'
I've tried a number of versions, deleting the Gemfile.lock, updating the bundler, etc. I've searched a lot of the threads around and it there looks to be a conflict between OmniAuth and devise but not with my error. Version conflict? How do you diagnose?
Here's my Gemfile:
source 'http://rubygems.org'
require 'rubygems'
gem 'rails'
gem 'actionpack'
gem 'jquery-rails'
gem 'haml'
gem "devise", :git => "https://github.com/plataformatec/devise.git"
# gem 'oa-core'
gem 'omniauth'
gem 'omniauth-openid'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'omniauth-github'
gem "settingslogic"
gem 'composite_primary_keys'
gem 'addressable'
# gem 'faraday'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
gem 'squeel'
gem 'sqlite3'
gem 'mysql2', '~> 0.2.6'
gem "bcrypt-ruby", :require => "bcrypt"
group :development, :test do
gem 'rspec-rails'
gem 'ruby-debug19', :require => 'ruby-debug'
gem 'hpricot', :require => false #html2haml
gem 'ruby_parser', :require => false # html2haml
gem 'pickle'
gem 'awesome_print', :require => 'ap'
gem 'factory_girl_rails'
end
group :development do
gem 'heroku', :require => false
gem 'sass'
end
group :test do
gem 'shoulda'
gem 'cucumber-rails'
gem 'spork', '~> 0.9.0.rc3'
gem 'guard-spork'
gem 'database_cleaner'
end

It actually was a ownership issue the dependent gem was installed as root. I updated the ownership all the directories and files in the gems directory and it worked. If you have a problem installing (i.e. generate native code) a gem where you sudo it, remember to go back and change the ownership of files back in the gems directory back to your user account

Related

Rails 4.2 - url helper raises "ArgumentError: wrong number of arguments (3 for 1..2)"

We are upgrading our Rails app from 4.1 to 4.2.
While this code works great in 4.0 and 4.1:
admin_root_url(:subdomain => 'www')
When I try it on 4.2.3 I get this error:
ArgumentError: wrong number of arguments (3 for 1..2)
I checked it several time in console, running this code:
include Rails.application.routes.url_helpers
default_url_options[:host] = "localhost"
root_url
Our Gemfile looks like this:
source 'https://rubygems.org'
ruby "2.1.2"
gem 'rails', '4.2.4'
gem 'rake', "~> 10.2.2"
group :development do
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Generates model and controller UML diagrams
gem 'railroady'
gem 'bullet'
gem 'web-console', '~> 2.0'
end
group :staging, :production do
gem 'pg'
gem 'rails_12factor'
gem 'newrelic_rpm'
end
gem 'sass-rails', '~> 4.0.0'
gem 'less-rails-bootstrap'
gem 'uglifier', '>= 1.3.0'
gem 'yui-compressor'
gem 'coffee-rails', '~> 4.0.0'
gem 'therubyracer', platforms: :ruby
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
gem 'simple_form', '~> 3.1.0'
gem "paperclip", "~> 4.2"
gem 'aws-sdk'
gem 'devise', '~> 3.5.2'
gem "cancan"
gem 'friendly_id', '~> 5.0.2'
gem 'pusher', '~> 0.14.5'
gem "configurable_engine", :path => "vendor/gems/configurable_engine"
gem 'backbone-rails'
gem 'marionette-rails'
gem "breadcrumbs_on_rails"
gem 'subdomain-fu', :git => "git://github.com/mbleigh/subdomain-fu.git"
gem 'bitly'
gem 'social-share-button', '~> 0.1.8'
gem 'momentjs-rails', '~> 2.5.0'
gem 'bootstrap3-datetimepicker-rails', '~> 3.0.0'
gem 'rails_autolink'
gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
gem "twitter"
gem 'unicorn'
gem 'i18n-js', '>= 3.0.0.rc11'
gem 'sitemap_generator'
gem 'will_paginate-bootstrap'
group :test, :development, :staging do
gem 'populator'
gem 'faker'
end
gem "jquery-fileupload-rails"
gem 'rails-timeago', '~> 2.0'
gem 'font-awesome-rails'
gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'jquery-minicolors-rails'
gem 'htmlentities', '~> 4.3.2'
gem 'sanitize'
gem 'nokogiri'
gem 'dalli'
gem 'kgio', '~> 2.9.3'
gem 'useragent'
gem "fog", "~>1.20"#, require: "fog/aws/storage"
gem 'asset_sync'
gem 'responders', '~> 2.0'
gem 'rails-deprecated_sanitizer'
================ edit ===============
Stack-trace in console:
ArgumentError: wrong number of arguments (3 for 1..2)
from /home/guy/.rvm/gems/ruby-2.1.2/bundler/gems/subdomain-fu-3752799a02c0/lib/subdomain_fu/url_rewriter.rb:6:in `url_for_with_subdomains'
from /home/guy/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb:282:in `call'
from /home/guy/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb:225:in `call'
from /home/guy/.rvm/gems/ruby-2.1.2/gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb:347:in `block (2 levels) in define_url_helper'
from (irb):3
from /home/guy/.rvm/gems/ruby-2.1.2/gems/railties-4.2.4/lib/rails/commands/console.rb:110:in `start'
from /home/guy/.rvm/gems/ruby-2.1.2/gems/railties-4.2.4/lib/rails/commands/console.rb:9:in `start'
from /home/guy/.rvm/gems/ruby-2.1.2/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:68:in `console'
from /home/guy/.rvm/gems/ruby-2.1.2/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/guy/.rvm/gems/ruby-2.1.2/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
================ edit (2) ===============
I dived into the code and saw that the line in /gems/actionpack-4.2.4/lib/action_dispatch/routing/route_set.rb (282) that raises the error is that:
t._routes.url_for(hash, route_name, url_strategy)
While the url_for function signature in url_rewriter is:
def url_for_with_subdomains(options, path_segments=nil)
Looks like I need to update something, but I don't know what.
================ edit (3) ===============
Just to be sure that it has nothing to do with my routes.rb file, I cleaned it and left it like that:
MyApp::Application.routes.draw do
root 'pages#index', :constraints => {:subdomain => /www|$^/}
end
As expected, still have the same error.
Had the same problem, the solution was instead of using:
include Rails.application.routes.url_helpers
I din't included and added url_helpers to a variable, like this:
url_helpers = Rails.application.routes.url_helpers
url_helpers.root_url
I had exactly same problem and at the end in my case
t._routes.url_for(hash, route_name, url_strategy)
called url_for_with_secure_option from bartt-ssl_requirement gem.
Since we don't need bartt-ssl_requirement gem anymore in our case solution was to simply remove bartt-ssl_requirement gem.
Try to remove subdomain-fu and use Rails4 request.subdomain when needed.
In case you get that error in the console, because you use a helper that uses URL helpers:
class << helper; include Rails.application.routes.url_helpers; end
helper.my_method # \o/

Clearance stops rails server from running

I installed clearance and followed the last steps which were "rails generate clearance:install". However rails server does not start up for me when I try to open in terminal.
/Users/lexi87/areyoutaken/config/initializers/clearance.rb:4:in `block in <top (required)>': uninitialized constant Clearance::PasswordStrategies::BCrypt (NameError)
from /Users/lexi87/.rvm/gems/ruby-1.9.3-p374/gems/clearance-0.16.3/lib/clearance/configuration.rb:36:in `configure'
from /Users/lexi87/areyoutaken/config/initializers/clearance.rb:1:in `<top (required)>'
from /Users/lexi87/.rvm/gems/ruby-1.9.3-p374/gems/railties-3.2.12/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
Here's my Gemfile and I have bcrypt gem inside.
source 'https://rubygems.org'
gem 'rails', '3.2.12'
gem 'bootstrap-sass', '2.1'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'jquery-rails', '2.0.2'
gem 'annotate', '2.5.0'
gem 'clearance'
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.11.0'
gem 'guard-rspec', '1.2.1'
gem 'guard-spork', '1.4.2'
gem 'spork', '0.9.2'
gem 'rb-fsevent', '~> 0.9.1'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '4.1.0'
gem 'cucumber-rails', '1.2.1', :require => false
gem 'database_cleaner', '0.7.0'
# gem 'launchy', '2.1.0'
# gem 'rb-fsevent', '0.9.1', :require => false
gem 'growl', '1.0.3'
end
group :production do
gem 'pg', '0.12.2'
end
Any help would be greatly appreciated.
You appear to be running gem version 0.16.3 of clearance, which doesn't support the Clearance::PasswordStrategies::BCrypt password strategy. If you upgrade to v1.0.0.rc1 or higher than that should work.
The only supported password strategies in 0.16.3 are Clearance::PasswordStrategies::Blowfish and Clearance::PasswordStrategies::SHA1.
If you want to try a version that supports BCrypt, you can update your Gemfile to say:
gem 'clearance', :git => "git://github.com/thoughtbot/clearance.git", :tag => "v1.0.0.rc4"
That will pull a specific tag of that repository. You can leave off the :tag to grab the latest version from GitHub. Keep in mind, that it may not be as stable as 0.16.3.

bundle install circular dependencies

The following console logs should describe the issue
bundle install
Could not find multi_json-1.1.0 in any of the sources
Run `bundle install` to install missing gems.
bundle install asks me to bundle install.
Have tried: https://github.com/mpapis/rubygems-bundler/issues/4
Looked at: https://github.com/carlhuda/bundler/issues/865
Not sure where to go next.
Also of interest, if we comment all the gems from inside vendor/gems the bundle works fine.
source 'http://rubygems.org'
gem 'rails', '~> 3.2.2'
gem 'mysql2'
gem 'thin'
# Asset template engines
gem 'coffee-script'
gem 'uglifier'
gem 'sprockets'
gem 'less-js'
gem 'execjs'
gem 'nokogiri'
gem 'lucy'
gem 'babilu'
gem 'simple_form'
gem 'mechanize'
gem 'geoip'
gem 'less'
gem 'bb-ruby'
gem 'client_side_validations', "~> 3.2.0.beta.2"
gem 'client_side_validations-simple_form'
gem 'require_all'
#for avatars
gem 'paperclip'
gem 'rmagick'
gem "multipart-post"
gem 'gibberish'
# Memcached client
gem 'dalli'
#to support tables without auto-incrementing primary keys
gem 'composite_primary_keys', "~> 5.0.1"
gem 'calendar_helper', :require => 'calendar_helper'
gem 'jquery-rails'
gem 'capistrano'
gem 'capistrano-ext'
gem 'simple_form'
gem 'htmlentities'
gem 'will_paginate'
gem 'airbrake', :path => "vendor/gems/airbrake"
gem "uservoice", :path => "vendor/gems/uservoice"
# For spambots
gem "honeypot-captcha"
# Internationalization GUI
gem "tolk", :git => "http://github.com/miloops/tolk.git", :branch => "rails31"
gem "will-paginate-i18n"
gem "omniauth"
gem "omniauth-facebook"
gem "omniauth-justintv", :git => 'http://github.com/themindoverall/omniauth-justintv.git'
gem 'oauth'
gem 'rails-i18n'
# For rate limiting
gem "rack-throttle", :path => "vendor/gems/rack-throttle"
gem "xfire-api", :path => "vendor/gems/xfire-api"
gem "anametrix", :path => "vendor/gems/anametrix"
#To make ruby debug work see: http://stackoverflow.com/questions/6438116/rails-with-ruby-debugger-throw-symbol-not-found-ruby-current-thread-loaderro
group :development, :test do
#gem 'ruby-debug-base19', '0.11.26', :path => "~/.rvm/gems/ruby-1.9.3-p#{RUBY_PATCHLEVEL}/gems/ruby-debug-base19-0.11.26/"
#gem 'linecache19', '0.5.13', :path => "~/.rvm/gems/ruby-1.9.3-p#{RUBY_PATCHLEVEL}/gems/linecache19-0.5.13/"
#gem 'ruby-debug19', :require => 'ruby-debug'
gem 'ruby_parser'
end
group :test do
gem 'ruby-prof'
gem 'test-unit' # For performance testing
gem 'turn', :require => false
gem 'factory_girl_rails', "~> 1.0.1"
gem 'capybara', "~> 1.0.0"
gem 'database_cleaner', '~> 0.6.7'
gem 'rspec-rails', "~> 2.6.1"
gem 'cucumber-rails', "~> 1.0.0"
gem 'webrat', "~> 0.7.3"
gem 'autotest'
gem 'simplecov'
gem 'autotest-rails-pure'
gem 'simplecov', :require => false, :group => :test
gem 'spork'
end
group :production do
gem 'rack-google_analytics', :require => "rack/google_analytics"
end
Have you declared that gem in your Gemfile? Sometimes it helps to specify a specific version as you've done for some:
gem 'multi-json', '1.1.0'
If anyone turns out to be stuck on this what turned out to be the answer is one of our homegrown gems:
gem "xfire-api", :path => "vendor/gems/xfire-api"
had a require in it provided by a gem that was not specified in the gemspec. If you're stuck on this and have homegrown gems take a look through all your requires and makes sure all the files are provided by gems you specify in the Gemspec.

Can't run Rails tests

I've reviewed the questions that seem to be relevant to my problem, and I can't find a solution. When I try to run the tests in a Rails 3.0.3 App, I get this error:
willmac:signalkit wbarrett$ rake test
(in /Users/wbarrett/Sites/signalkit)
LOADING CONFIG/ENVIRONMENT.RB
./test/unit/authentication_test.rb:3: uninitialized constant ActiveSupport (NameError)
from /Users/wbarrett/.rvm/gems/ree-1.8.7-2011.03#global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
from /Users/wbarrett/.rvm/gems/ree-1.8.7-2011.03#global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
from /Users/wbarrett/.rvm/gems/ree-1.8.7-2011.03#global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
from /Users/wbarrett/.rvm/gems/ree-1.8.7-2011.03#global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
./test/functional/authentications_controller_test.rb:3: uninitialized constant ActionController (NameError)
from /Users/wbarrett/.rvm/gems/ree-1.8.7-2011.03#global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `load'
from /Users/wbarrett/.rvm/gems/ree-1.8.7-2011.03#global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
from /Users/wbarrett/.rvm/gems/ree-1.8.7-2011.03#global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5:in `each'
from /Users/wbarrett/.rvm/gems/ree-1.8.7-2011.03#global/gems/rake-0.8.7/lib/rake/rake_test_loader.rb:5
Errors running test:units, test:functionals!
As you can see, the tests are requiring test_helper and requiring environment.rb (I added the LOADING.. output to the top of the environment.rb config file)
Here's my Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.0.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'devise'
gem 'unicorn'
gem 'omniauth', :git => 'git://github.com/signalkit/omniauth.git', :branch => 'signalkit'
gem 'mongrel'
# gem 'tinder'
gem 'oauth2', :git => 'git://github.com/signalkit/oauth2.git', :branch => 'signalkit' #0.1.1 with modification for Basecamp
gem 'crack'
gem 'delayed_job'
gem "builder", "2.1.2"
gem "haml", "3.0.12"
gem "maruku", "0.6.0"
gem "RedCloth", "4.2.2"
gem "sinatra", "1.1.0", :require => "sinatra/base"
gem "monkeywrench"
gem "httparty"
gem "hoptoad_notifier"
group :test do
gem "shoulda", "~> 2.11.3"
gem "mocha", "~> 0.9.12"
gem "webmock", "= 0.7.3"
gem "test-unit"
end
What's wrong with this picture? Thanks all!
UPDATE: 6/30/2011 4:05PM CST
For whatever reason, changing the require at the top of all the test files from
require 'test_helper'
to
require File.dirname(__FILE__) + '/../test_helper'
solved my problem. +25 to whoever can tell me why this is, since the helper was being loaded fine the other way as well.

Rails 3 annotate doesn't work

When I run annotate at the command-line, I get the following error:
$ annotate
/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks': undefined method `task' for #<MyApp::Application:0x00000102e03b90> (NoMethodError)
from /.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.7/lib/rails/application.rb:139:in `load_tasks'
from /.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
from Rakefile:8:in `<top (required)>'
from /.rvm/gems/ruby-1.9.2-p0/gems/annotate-2.4.0/lib/annotate.rb:17:in `load'
from /.rvm/gems/ruby-1.9.2-p0/gems/annotate-2.4.0/lib/annotate.rb:17:in `load_tasks'
from /.rvm/gems/ruby-1.9.2-p0/gems/annotate-2.4.0/bin/annotate:66:in `<top (required)>'
from /.rvm/gems/ruby-1.9.2-p0/bin/annotate:19:in `load'
from /.rvm/gems/ruby-1.9.2-p0/bin/annotate:19:in `<main>'
This is what my Gemfile looks like:
source 'http://rubygems.org'
gem 'rails'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'will_paginate', '3.0.pre2'
gem 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git'
gem 'mime-types', :require => 'mime/types'
gem 'rails3-generators'
gem 'devise', '~> 1.1.3'
gem 'devise_invitable', '~> 0.3.4'
gem 'declarative_authorization', :git => 'git://github.com/stffn/declarative_authorization.git'
gem 'aasm'
gem 'braintree'
#For voting
gem 'thumbs_up'
# For In-Place-Editing
gem 'best_in_place'
#For slugs for the plans
gem "friendly_id", "~> 3.2"
gem 'aws-s3'
group :development do
# Server
gem 'thin'
gem 'annotate-models', '1.0.4'
#gem 'rails-erd'
gem 'annotate'
gem 'faker', '0.3.1'
gem 'ruby_parser'
end
This is all on my localhost btw.
Marcamillion, it probably broke because at one stage you had rake 0.9.0 installed, which broke a lot of things for a lot of people without deprecating methods or warning people. When you ran bundle update, it would have installed rake 0.9.2 which fixed this. Hope this helps someone else.
I've solved this problem using gem 'annotate', ">=2.5.0".
I'm using ruby 1.9.2p320 and Rails 3.2.13.

Resources