I was getting an error with my application, so I looked on stack and found an answer undefined method `require_relative' for main:Object (NoMethodError) it said that I should run gem install rails which I did, after I ran that, when I tried to run rails generate controller StaticPages home help --no-test-framework
I got an error:
(in /usr/local/rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/rails-0.9.5)
rake aborted!
ERROR: 'rake/rdoctask' is obsolete and no longer supported. Use 'rdoc/task' (available in RDoc 2.4.2+) instead.
/usr/local/rvm/gems/ruby-2.0.0-p247#railstutorial_rails_4_0/gems/rails-0.9.5/Rakefile:3:in `<top (required)>'
It says that I am running rails .95 and even when I ran gem update rails nothing happend
Here is my gemfile
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.2'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
Try deleting your Gemfile.lock (or perhaps moving it). This worked for me.
Related
Need help.
When I try to make
user#X220:~/rails_projects/sample_app$ heroku run rake db:migrate
There is a mistake:
Running rake db:migrate on limitless-fjord-69900.... up, run.2816
rake aborted!
Gem::LoadError: Specified 'postgresql' for database adapter, but the gem is not loaded.
Add gem 'pg' to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:177:in rescue in spec'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_adapters/connection_specification.rb:174:inspec'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/connection_handling.rb:50:in establish_connection'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/railtie.rb:120:inblock (2 levels) in '
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:38:in instance_eval'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:38:inexecute_hook'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:45:in block in run_load_hooks'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:44:ineach'
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-4.2.6/lib/active_support/lazy_load_hooks.rb:44:in run_load_hooks'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/base.rb:315:in'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/base.rb:26:in <top (required)>'
/app/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.6/lib/active_record/tasks/mysql_database_tasks.rb:8:in'
.
.
.
Tasks: TOP => db:migrate => db:load_config
(See full trace by running task with --trace)
My Gemfile is:
'source 'https://rubygems.org'
ruby '2.2.0'
gem 'activerecord', '~> 4.2', '>= 4.2.6'
gem 'rails', '4.2.6'
group :development, :test do
gem 'byebug'
gem 'sqlite3', '~> 1.3', '>= 1.3.11'
gem 'rspec-rails', '~> 2.8'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'therubyracer', platforms: :ruby
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
group :doc do
gem 'sdoc', '~> 0.4.0', require: false
end
gem 'unicorn'
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
group :production do
gem 'rails_12factor'
gem 'pg'
end
What's wrong?
Remove or comment gem 'sqlite3' from your Gemfile even if it in development group.
I don't know why but Heroku doesn't run your application when it contains sqlite gem outside production.
If you are use SQLite in development, you have to comment gem 'sqlite' every time when deploying to Heroku and uncomment after deploying.Better way will be use Postgres in development.
As suggested before, this could have to do with your sqlite gem.
If you still want to use sqlite you can set to ignore that group. From Heroku docs:
To specify groups of gems to not to be installed, you can use the BUNDLE_WITHOUT config var.
$ heroku config:set BUNDLE_WITHOUT="development:test"
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?
I cant install rspec.
command:
rails generate rspec:install
↓
result:
Could not find generator rspec:install.
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.5'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.2'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
This is my Gemfile.
And, this tutorial is this one.
http://www.railstutorial.org/
I replicated your gemfile and ran the command. It works for me just so long as the bundle installation finished correctly.
To make sure yours is installing correctly, you might try adding this line to your gemfile so that it can pull all the correct versions.
source 'https://rubygems.org'
Also, you may need to run your bundle install as the following if the postgres implementation gems give you trouble as they sometimes do. The tutorial you're working on uploads to heroku and doesn't require those gems on your development environment:
bundle install --without production
After everything has installed successfully, "rails generate rspec:install" should work.
I am going through the railstutorial.org book.
I am receiving this error:
$ bundle exec guard init rspec
c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/guard-2.0.3/lib/guard/interactor.rb:1:in
require': cannot load such file -- pry (LoadError)
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/guard-2.0.3/lib/guard/inter
actor.rb:1:in'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/guard-2.0.3/lib/guard/dsl.r
b:2:in require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/guard-2.0.3/lib/guard/dsl.r
b:2:in'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/guard-2.0.3/lib/guard.rb:6:
in require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/guard-2.0.3/lib/guard.rb:6:
in'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/guard-2.0.3/bin/guard:3:in
require'
from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/guard-2.0.3/bin/guard:3:in
'
from c:/Ruby200-x64/bin/guard:23:in load'
from c:/Ruby200-x64/bin/guard:23:in'
My gem file is:
1. source 'https://rubygems.org'
ruby '2.0.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
group :development, :test do
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
gem 'rspec-rails', '2.13.1'
gem 'guard-rspec', '2.0.0'
gem 'guard', '2.0.3'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
gem 'rb-notifu', '0.0.4'
gem 'win32console', '1.3.2'
gem 'wdm', '0.1.0'
end
# Use SCSS for stylesheets
gem 'sass-rails', '4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '2.1.1'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks', '1.1.1'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '1.0.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
Am I missing something? Thanks for any help!
Looks like guard requires pry be installed.
gem install pry
Explicitly add pry or similar to your Gemfile. I use pry-nav which will automatically bundle pry when bundle install is run.
# Gemfile
gem 'pry-nav', group: [:development, :test]
Cite:
http://pryrepl.org/
https://github.com/nixme/pry-nav
https://github.com/nixme/pry-debugger
https://github.com/rweng/pry-rails
I am using the RMeetup gem to pull data from meetup.com. In development mode, I can feature this code in my controller, model or helper with no issues:
RMeetup::Client.api_key = "matt's key"
RMeetup::Client.fetch(:groups, :lat => #user.latitude, :lon => #user.longitude")
But when I try to deploy, Heroku tells me:
app[web.1]: NameError (uninitialized constant RMeetup::Client):
I'm a novice on Rails, and I don't know how to fix this problem. I've tried creating a new RMeetup model to maybe better house this information and fix the issue, but Rails tells me:
The name 'RMeetup' is either already used in your application or reserved by Ruby on Rails. Please choose an alternative and run this generator again.
The RMeetup gem is not located exclusively in the dev section of my gemfile. Complicating the matter, I don't actually save any of the data I receive from Meetup.com until a user fills out a form. So I don't have a natural place to build a model off the results from RMeetup fetch operations. I currently do it in a helper or controller.
So why does my local dev have no problem with "RMeetup::Client" but Heroku does, and how can I fix it?
As requested, here is also the Gemfile:
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.0'
gem 'bcrypt-ruby', '3.0.1'
gem 'pg', '0.15.1'
gem 'geocoder'
gem 'rmagick'
gem 'carrierwave'
gem 'rMeetup'
group :development, :test do
gem 'rspec-rails', '2.13.1'
gem 'puma'
end
group :test do
gem 'selenium-webdriver', '2.0.0'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.0'
gem 'uglifier'
gem 'coffee-rails', '4.0.0'
gem 'jquery-rails', '2.2.1'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'rails_12factor', '0.0.2'
end
Try
gem 'rMeetup', require: 'rmeetup'
in your Gemfile