I recently installed SOLR on my Amazon EC2 machine and when I try to start SOLR using RAILS_ENV=production bundle exec rake sunspot:solr:start --trace, I get the following message:
** Invoke sunspot:solr:run (first_time)
** Invoke sunspot:solr:moved_to_sunspot_solr (first_time)
** Execute sunspot:solr:moved_to_sunspot_solr
Note: This task has been moved to the sunspot_solr gem.
To install, start and stop a local Solr instance, please add sunspot_solr to your Gemfile:
group :development do
gem 'sunspot_solr'
end
However, I've already included sunspot_solr in my Gemfile and my RAILS_ENV is production (I've also tried export RAILS_ENV=production. Any tip as to why SOLR won't start and keeps trying to run in development? I followed this link to install it - http://tanin.nanakorn.com/b/96/tomcat_and_solr_on_ec2
Here is part of my Gemfile:
group :development, :test do
gem 'factory_girl_rails'
gem "rspec-rails"
gem 'faker'
gem 'fuubar'
gem 'pry'
gem 'foreman'
gem 'guard-spork'
gem 'sunspot_solr'
end
I've ran bundle install already and see that the gem is being used:
Using rsolr (1.0.8)
Using sunspot (1.3.0)
Using sunspot_rails (1.3.0)
The sunspot_solr gem is in your Gemfile's :development group, which Rails will ignore when you specify RAILS_ENV=production. The sunspot_solr gem is intended mostly as a convenience for development and testing, and is not particularly tuned for production, which is why the documentation suggests including it in the :development group.
If you have followed the steps described in the blog article that you linked, you actually don't need to use Sunspot's bundled Solr instance. By the end of that article, you should have a Solr server running on your server. (You'd have to double check the Tomcat configs to see which port it is running on.)
If I may be so bold, you might also benefit from considering a cloud hosted Solr search such as my own websolr.com. You should be able to have an index up and running there within a few minutes.
Related
I am trying to deploy my app in a staging environment using Capistrano.
Running cap staging deploy results in error saying:
bundler: failed to load command: whenever (/home/ubuntu/builder/shared/bundle/ruby/2.7.0/bin/whenever)
DEBUG [52d26072] Gem::Exception: can't find executable whenever for gem whenever. whenever is not currently included in the bundle, perhaps you meant to add it to your Gemfile?
I have already included whenever gem in the local Gemfile but still it is not able to find it:
Here's a part of my Gemfile:
gem 'capistrano',
gem 'capistrano-secrets-yml'
gem 'capistrano-rbenv'
gem 'capistrano-bundler'
gem 'capistrano-rails'
gem 'whenever', :require => false
I am not able to find what the problem is. Can you please help me?
I would try bundle exec cap staging deploy to make sure you are executing the command using your bundle. Additionally you may need to remove require => false because it does not include the library when you load your bundle.
I saw this question Setup sunspot solr with rails in production environment.
But I see my output:
bundle exec sunspot-solr start
...sunspot_solr is not part of the bundle. Add it to Gemfile.
I have sunspot_solr under development group, and I suppose I should not change that.
Bundler output
Using rsolr (1.0.8)
...
Using sunspot (1.3.3)
Using sunspot_rails (1.3.3)
Rake output
rake sunspot:solr:start RAILS_ENV=production
Note: This task has been moved to the sunspot_solr gem. To install, start and
stop a local Solr instance, please add sunspot_solr to your Gemfile:
group :development do
gem 'sunspot_solr'
end
Any advice, thanks.
Can you try putting the gems outside the development group?
I have the following gems outside the development group:
gem 'sunspot_rails'
gem 'sunspot_solr'
Edit: I'm a new ruby on rails student.
Following my Git Push Heroku Master, I am running into issues with Heroku. Here is the latest and greatest, aborting the rake assets:precompile.
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Tasks: TOP => environment
(See full trace by running task with --trace)
Precompiling assets failed, enabling runtime asset compilation
Injecting rails31_enable_runtime_asset_compilation
Please see this article for troubleshooting help:
http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting
Included below are the contents of my Gemfile:
gem 'rails', '3.2.8'
gem 'bootstrap-sass', '2.1'
gem 'pg'
group :development, :test do
gem 'rspec-rails'
gem 'guard-rspec'
gem 'guard-spork'
gem 'spork'
gem 'annotate'
gem 'database_cleaner'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
end
platforms :jruby do
gem 'trinidad'
gem 'jruby-openssl'
end
gem 'jquery-rails'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug'
# Bundle the extra gems:
gem 'RedCloth', '~> 4.2.9', :require => 'redcloth'
gem 'ruby-openid', :require => 'openid'
gem 'rack-openid', :require => 'rack/openid'
gem 'aaronh-chronic', :require => 'chronic' # Fixes for 1.9.2
gem 'coderay'
gem 'lesstile'
gem 'formtastic'
gem 'will_paginate', '~> 3.0.2'
gem 'exception_notification', '~> 2.5.2'
gem 'open_id_authentication'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :test do
gem 'database_cleaner'
gem 'cucumber-rails', :require => false
gem 'cucumber-websteps', :require => false
gem 'factory_girl'
gem 'rspec'
gem 'nokogiri', '~> 1.5.0'
gem 'webrat'
end
What might be the issue?
Update: I ran the rake command with --trace, and it had alerted me with a failure because the production database did not exist. I created the database, and ran --trace again, and this is what I'm currently being thrown:
Command failed with status (1): [/usr/local/Cellar/ruby/1.9.3-p286/bin/ruby...]
See the Rails 3.1+ Asset Pipeline on Heroku Cedar article. This exact scenario is covered in the Troubleshooting section.
In short, your Heroku application has a strong separation between building (including asset compilation) and running (where your application becomes available). This is consistent with the 12-factor app principles, but it means that your application cannot access any configured resources during the build phase -- including the database -- meaning ActiveRecord is unavailable during asset precompilation.
You can tell Rails not to bootstrap your application during asset compilation in config/application.rb:
config.assets.initialize_on_precompile = false
The troubleshooting section also recommends:
If rake assets:precompile is still not working, you can debug this locally by configuring a nonexistent database in your local config/database.yml and attempting to run rake assets:precompile. Ideally you should be able to run this command without connecting to the database.
I struggled with exactly the same problem, for hours tonight. After adding
config.assets.initialize_on_precompile = false
to application.rb, remember to do a
git commit
right afterwards. I forgot to do this, and Heroku had no idea I'd changed application.rb. They don't have this extra line on their troubleshooting page.
For Rails 4
Enable Heroku Labs feature to fix this problem
heroku labs:enable user-env-compile
I had this issue with Rails 4 and none of the other suggestions helped. I finally figured it out and it was due to the Rollify gem trying to connect to the database. That has been fixed in the Rollify gem, however, you may need to grab the latest source code to get the fix. I just change my gem import for Rollify to:
gem 'rolify', :git => 'git://github.com/EppO/rolify.git'
That seemed to fix the problem and I haven't had to do any of the other suggestions.
Don't forget to bundle install and commit the change to git.
Also, if that doesn't fix your problem either, you might want to start looking closely at the gems you're using and make sure none of them attempt to connect to the database.
i am using ruby 1.9.2 and rails 3.1.0
please help, cause i very need it to work for studying. It's my university project(
i have installed this gems
gem 'thin'
gem 'pg'
but when i use heroku rake db:migrate is tells me to instal postgreadapter. But i have it.
I did all that i read about this problem, also did
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
in rubymine it writes gem "pg" is not available in SDK 'ruby-1.9.2-p290'
same with thin and heroku gems
It seems you have not installed those gems in rubymine (locally). run "bundle install" or if you need to do something specific in rubymine to install gems.
I am trying to learn rails from http://ruby.railstutorial.org/
Exercise 3 explains to install rspec, rspec-rails, and webrat using this gemfile
source 'http://rubygems.org'
gem 'rails', '3.0.6'
gem 'sqlite3', '1.3.3', :require => 'sqlite3'
group :development do
gem "rspec-rails", ">= 2.0.1"
end
group :test do
gem "rspec-rails", ">= 2.0.1"
gem 'rpsec'
gem 'webrat'
end
i have tried to install rspec-rails and webrat and they seem to have installed correctly.
C:\RubyProject\sample_app>gem install rspec-rails -v=2.0.1
**************************************************
Thank you for installing rspec-rails-2.0.1!
This version of rspec-rails only works with versions of rails >= 3.0.0
To configure your app to use rspec-rails, add a declaration to your Gemfile.
If you are using Bundler's grouping feature in your Gemfile, be sure to include
rspec-rails in the :development group as well as the :test group so that you
can access its generators and rake tasks.
group :development, :test do
gem "rspec-rails", ">= 2.0.1"
end
Be sure to run the following command in each of your Rails apps if you're
upgrading:
script/rails generate rspec:install
Even if you've run it before, this ensures that you have the latest updates
to spec/spec_helper.rb and any other support files.
Beta versions of rspec-rails-2 installed files that are no longer being used,
so please remove these files if you have them:
lib/tasks/rspec.rake
config/initializers/rspec_generator.rb
Lastly, be sure to look at Upgrade.markdown to see what might have changed
since the last release.
**************************************************
Successfully installed rspec-rails-2.0.1
1 gem installed
Installing ri documentation for rspec-rails-2.0.1...
Installing RDoc documentation for rspec-rails-2.0.1...
But when i run bundle install
I get the following error message
Could not find gem 'rpec-rails (= 2.0.1)' in any of the gem sources listed in your Gemfile.
So me being a total newbie to RoR has no idea why this is occurring. I have tried following this link
http://railsforum.com/viewtopic.php?id=41464
which seems to be a dead end. I'm hoping that someone here can point me in the right direction. Any help would be appreciated.
If your output is correct:
Could not find gem 'rpec-rails (= 2.0.1)' in any of the gem sources listed in your Gemfile.
Then it looks like you've got a typo in your gem file. You've installed the gem, but it won't bundle with the app since you didn't spell rspec-rails correctly. Check your declarations in the gem file.
It is an annoying word to spell.
I noticed your :test group contains a typo: rpsec instead of rspec.