Rails better_errors gem server not starting - ruby-on-rails

Since I isntalled better_errors gem I can't start my server using command rails server. I have tried adding lines into my development.rb like BetterErrors::Middleware.allow_ip! "0.0.0.0/0" or BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP'] but it didn't work.
This is my error message when I try to start server:
/home/jakub/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/better_errors-2.1.1/lib/better_errors/exception_extension.rb:6:in `caller_locations': stack level too deep (SystemStackError)
from /home/jakub/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/better_errors-2.1.1/lib/better_errors/exception_extension.rb:6:in `set_backtrace'
from /home/jakub/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/web-console-2.0.0.beta3/lib/web_console/exception_extension.rb:15:in `call'
from /home/jakub/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/web-console-2.0.0.beta3/lib/web_console/exception_extension.rb:15:in `block in <class:Exception>'
from /home/jakub/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/better_errors-2.1.1/lib/better_errors/exception_extension.rb:10:in `set_backtrace'
from /home/jakub/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/web-console-2.0.0.beta3/lib/web_console/exception_extension.rb:15:in `call'
from /home/jakub/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/web-console-2.0.0.beta3/lib/web_console/exception_extension.rb:15:in `block in <class:Exception>'
from /home/jakub/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/better_errors-2.1.1/lib/better_errors/exception_extension.rb:10:in `set_backtrace'
from /home/jakub/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/web-console-2.0.0.beta3/lib/web_console/exception_extension.rb:15:in `call'
... 5885 levels...
from /home/jakub/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
And my gemfile:
source 'https://rubygems.org'
gem 'rails', '4.2.2'
gem 'bcrypt', '3.1.7'
gem "paperclip",
git: "git://github.com/thoughtbot/paperclip.git"
gem 'faker', '1.4.2'
gem 'will_paginate', '3.0.7'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'sass-rails', '5.0.2'
gem 'uglifier', '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'turbolinks', '2.3.0'
gem 'jbuilder', '2.2.3'
gem 'sdoc', '0.4.0', group: :doc
group :development, :test do
gem 'better_errors', '~> 2.1.1'
gem 'sqlite3', '1.3.9'
gem 'byebug', '3.4.0'
gem 'web-console', '2.0.0.beta3'
gem 'spring', '1.1.3'
end
group :test do
gem 'minitest-reporters', '1.0.5'
gem 'mini_backtrace', '0.1.3'
gem 'guard-minitest', '2.3.1'
end
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
end

This is an active issue on github since 2014. One workaround seems to be to move gem 'better_errors' out of the development and testing groups from your Gemfile.
You can also start to restart spring manually which might resolve your problem:
cd /your/project
spring stop
...
spring start
...
In your Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.2.2'
gem 'bcrypt', '3.1.7'
gem "paperclip",
git: "git://github.com/thoughtbot/paperclip.git"
gem 'better_errors', '~> 2.1.1'
group :development, :test do
# ...
end
Other things you could try:
Remove your Gemfile.lock, keep your Gemfile as is and rerun bundle install. Make sure rails s is not run while doing that.
Remove better_errors version from you Gemfile

Related

when use "heroku run rails test ", I got error "add `gem 'rails-controller-testing'` to your Gemfile" , and it's already added to my gemfile

I'm creating a new rails application, and I'm working on the registration system, based on "rails tutorial" book, but I got a problem, when I run
rails test
on my local machine for my rails app, I got no errors
but when push the app to heroku, and then run
heroku run rails test
I got this error
Error:
UsersSignupTest#test_valid_signup_information:
NoMethodError: assert_template has been extracted to a gem. To continue using it,
add `gem 'rails-controller-testing'` to your Gemfile.
test/integration/users_signup_test.rb:25:in `block in <class:UsersSignupTest>'
this is my gemfile
source 'https://rubygems.org'
ruby "2.5.1"
gem 'rails', '5.1.4'
gem 'bootstrap-sass', '3.3.7'
gem 'bcrypt', '3.1.12'
gem 'puma', '3.9.1'
gem 'sass-rails', '5.0.6'
gem 'uglifier', '3.2.0'
gem 'coffee-rails', '4.2.2'
gem 'jquery-rails', '4.3.1'
gem 'turbolinks', '5.0.1'
gem 'jbuilder', '2.7.0'
gem 'carrierwave', '~> 0.11.2'
group :development, :test do
gem 'sqlite3', '1.3.13'
gem 'byebug', '9.0.6', platform: :mri
end
group :development do
gem 'web-console', '3.5.1'
gem 'listen', '3.1.5'
gem 'spring', '2.0.2'
gem 'spring-watcher-listen', '2.0.1'
end
group :test do
gem 'rails-controller-testing', '1.0.2'
gem 'minitest', '5.10.3'
gem 'minitest-reporters', '1.1.14'
gem 'guard', '2.13.0'
gem 'guard-minitest', '2.4.4'
end
group :production do
gem 'pg', '0.18.4'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
any solutions please, knowing that I'm still newbie :)

Deploying Rails App with webpack to heroku

I created my rails with this template that included webpack. But i still wrote my javascript code in app/assets/javascript. Now I am trying to deploy my app to heroku and it keeps failing. I get this error
remote: /tmp/build_6f0656280cbbda40c5832ccb79fc1783/vendor/bundle/ruby/2.3.0/gems/bundler-1.15.2/lib/bundler/rubygems_integration.rb:432:in `block in replace_bin_path': can't find executable webpack for gem webpacker (Gem::Exception)
The main error seems to be "cant find executable webpack for gem webpacker". I have no idea how to solve it. This is my gemfile
source 'https://rubygems.org'
ruby '2.3.5'
gem 'figaro'
gem 'jbuilder', '~> 2.0'
gem 'puma'
gem 'rails', '5.1.4'
gem 'redis'
gem 'cloudinary'
gem 'carrierwave', '~> 1.2'
gem 'rails_admin', '~> 1.2'
group :production do
gem 'pg', '~> 0.20'
end
gem 'autoprefixer-rails'
gem 'bootstrap-sass'
gem 'jquery-rails'
gem 'font-awesome-sass'
gem 'sass-rails'
gem 'simple_form'
gem 'turbolinks', '~> 5.0.0'
gem 'coffee-rails'
gem 'uglifier'
gem 'webpacker'
gem 'devise'
gem 'ransack'
gem 'trix'
gem "letter_opener", group: :development
group :development do
gem 'web-console', '>= 3.3.0'
gem 'sqlite3'
end
group :development, :test do
# gem 'binding_of_caller'
# gem 'better_errors'
gem 'pry-byebug'
gem 'pry-rails'
gem 'listen', '~> 3.0.5'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
Breaking changes in 3.3.0
https://github.com/rails/webpacker/blob/master/CHANGELOG.md#330---2018-03-03
bundle exec rails webpacker:binstubs

uninitialized constant Sprockets::Rails::VERSION (NameError)

In updating dependencies, I have come across updating sprockets. However there doe not appear to be a proper dependency for my set of gems. After returning to: 2.11.3, the erorr apepars:
/Users/..../rvm/gems/ruby-2.3.0/gems/bootstrap-sass-3.3.6/lib/bootstrap-sass/engine.rb:11:in `block in <class:Engine>': uninitialized constant Sprockets::Rails::VERSION (NameError)
Gemfile:
source 'http://rubygems.org'
ruby '2.3.0' # '1.9.3'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.2.6'
#gem 'pg', '0.15.1'
gem 'mysql2', '0.4.4'
gem 'bootstrap-sass', '3.3.6'
gem 'bcrypt', '3.1.11'
gem 'faker', '1.1.2'
gem 'will_paginate', '3.1.0'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'geocoder', '1.3.7'
gem 'nested_form', '0.3.2'
gem 'utf8-cleaner', '0.2.4'
gem 'sprockets', '3.6.0' #2.11.3
gem 'json', '1.8.3'
gem 'ffi'
gem 'iconv', '1.0.4'
gem 'chosen-rails', '1.5.2'
gem 'compass-rails', github: 'Compass/compass-rails'
# For image uploads
gem 'carrierwave', '0.11.2'
# For uploading CSV
gem 'roo', '2.4.0'
# DataTables
gem 'jquery-datatables-rails', '3.4.0' # git: 'git://github.com/rweng/jquery-datatables-rails.git'
gem 'jquery-ui-rails', '5.0.5'
# Editing in line:
gem 'best_in_place', '3.1.0'
# Passing data from controller to coffeescript
gem 'gon', '6.0.1'
#gem 'jquery-turbolinks' '2.1.0'
# For searching and webservice queries-NO LONGER USED
#gem 'sunspot_rails', '2.1.0'
#gem 'sunspot_solr', '2.1.0'
gem 'progress_bar', '1.0.5'
gem 'responders', '2.2.0'
# Calendar Date and Validation
gem 'bootstrap-datepicker-rails'
# For Google Maps overlays
gem 'gmaps4rails', '~> 2.1.2'
gem 'underscore-rails', '~> 1.8.3'
group :development, :test do
gem 'rspec-rails', '3.4.2'
gem 'guard-rspec', '4.7.2'
gem 'spork-rails', '4.0.0'
gem 'childprocess', '0.5.9'
gem 'guard-spork', '2.1.0'
end
group :test do
gem 'selenium-webdriver', '2.53.3'
gem 'capybara', '2.7.1'
gem 'factory_girl_rails', '4.7.0'
end
gem 'sass-rails', '4.0.1'
gem 'uglifier', '3.0.0'
gem 'coffee-rails', '4.1.1'
gem 'jquery-rails', '4.1.1'
gem 'turbolinks', '2.5.3'
gem 'jbuilder', '2.5.0'
group :doc do
gem 'sdoc', '0.4.1', require: false
end
gem 'rails_12factor', '0.0.3'
How can I make this work?
You can fix this problem following steps:
First, you run gem update to update your gems.
And sprockets-rails should be at version 3.0.4
Second, open your Gemfile.lock in your rails project, modify the following line to update sprocket version
sprockets-rails (3.0.4)
Finally, you run bundle install
Above one is the answer,
You can fix this problem following steps:
First, you run gem update to update your gems.
And sprockets-rails should be at version 3.0.4
Second, open your Gemfile.lock in your rails project, modify the following line to update sprocket version
sprockets-rails (3.0.4)
Finally, you run bundle install

rspec-core is not part of the bundle. Add it to Gemfile

When I run rspec spec I get this error:
bundle exec rspec spec/models/spree_user_spec.rb
/Users/martins/.rvm/gems/ruby-2.2.3#solidus/gems/bundler-1.11.2/lib/bundler/rubygems_integration.rb:304:in `block in replace_gem': rspec-core is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
from /Users/martins/.rvm/gems/ruby-2.2.3#solidus/bin/rspec:22:in `<main>'
from /Users/martins/.rvm/gems/ruby-2.2.3#solidus/bin/ruby_executable_hooks:15:in `eval'
from /Users/martins/.rvm/gems/ruby-2.2.3#solidus/bin/ruby_executable_hooks:15:in `<main>'
Any idea why? Here you got my Gemfile:
Gemfile
source 'https://rubygems.org'
ruby '2.2.3'
gem 'solidus'
gem 'quiet_assets', group: :development
gem 'dotenv-rails', groups: [:development, :test]
gem 'puma'
gem 'cancancan', '~> 1.10'
group :test do
gem 'factory_girl_rails', '~> 4.5.0'
gem 'capybara', '~> 2.4'
gem 'capybara-screenshot'
gem 'database_cleaner', '~> 1.3'
gem 'email_spec'
gem 'launchy'
gem 'rspec-activemodel-mocks', '~>1.0.2'
gem 'rspec-collection_matchers'
gem 'rspec-its'
gem 'rspec-core'
gem 'rspec-rails', '~> 3.3.0'
gem 'simplecov'
gem 'webmock', '1.8.11'
gem 'poltergeist'
gem 'timecop'
gem 'with_model'
gem 'rspec_junit_formatter'
end
gem 'rails', '4.2.5'
gem 'pg', '~> 0.15'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
group :development, :test do
gem 'rubocop'
gem 'spring-commands-rspec'
gem 'guard-rspec', require: false
end
group :darwin, :test do
gem 'rb-fsevent'
end
group :production do
gem 'exception_notification'
gem 'rails_12factor'
end
A similar problem led me here, except in addition to rspec-core, none of the gems in my test group were installed, because apparently bundler remembers your initial switches.
Updating .bundle/config to not include BUNDLE_WITHOUT: "test" let bundle install add the correct gems.
rspec-core is a runtime dependency for rspec-rails and so you should not need to explicitly add it to your Gemfile. Did you add it as a result of trying to debug this? See the docs here.
When you run bundle install, bundler will go out and retrieve necessary dependencies and include those in your Gemfile.lock, with the specific versions required to support your Gemfile gems.
I recommend you start by removing rspec-core from your Gemfile and running bundle install. Then take a look at your Gemfile.lock. Is rspec-core in there? It should be. If not, it would help if you paste the snippet of your lock file that contains rspec-rails and its dependencies?

Rake generate_session_store error with Gemfile

I am trying to make a site live through hostgator, and I am following their instructions
When I get to step 5.6, where I enter rake generate_session_store in SSH I get the error
There was an error in your Gemfile, and Bundler cannot continue.
I can not figure out what I am doing wrong. If anyone can help me it would be greatly appreciated.
My current gemfile:
source 'https://rubygems.org'
gem "rake", "0.8.7"
gem "rack", "1.1.0"
gem "i18n", "0.4.2"
gem "rubytree", "0.5.2", :require => "tree"
gem "RedCloth", "~>4.2.3", :require => "redcloth" # for CodeRay
gem "mysql"
gem "coderay", "~>0.9.7"
gem "rdoc", "~>2.4.2"
gem 'rails', '4.2.0'
gem 'bcrypt', '3.1.7'
gem 'bootstrap-sass', '3.2.0.0'
gem 'sass-rails', '5.0.2'
gem 'uglifier', '2.5.3'
gem 'coffee-rails', '4.1.0'
gem 'jquery-rails', '4.0.3'
gem 'turbolinks', '2.3.0'
gem 'jbuilder', '2.2.3'
gem 'sdoc', '0.4.0', group: :doc
#gem 'acts_as_shopping_cart', '~> 0.2.1'
gem 'selenium-webdriver', '~> 2.46.2'
gem 'activerecord', '~> 4.2.0'
gemspec
gem 'activemerchant'
group :development, :test do
gem 'sqlite3', '1.3.9'
gem 'byebug', '3.4.0'
gem 'web-console', '2.0.0.beta3'
gem 'spring', '1.1.3'
end
group :test do
gem 'minitest-reporters', '1.0.5'
gem 'mini_backtrace', '0.1.3'
gem 'guard-minitest', '2.3.1'
gem 'cucumber-rails', :require => false
# database_cleaner is not required, but highly recommended
#gem 'database_cleaner'
end
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
gem 'puma', '2.11.1'
end

Resources