Missing RedCloth gem but `rake gems:install` does nothing - ruby-on-rails

I tried starting my Rails application but got this error message from Passenger:
Ruby on Rails application could not be started
The application has exited during startup (i.e. during the evaluation of
config/environment.rb)
/home/chuck/chuck.com/vendor/rails/railties/lib/rails/gem_dependency.rb:119:
Warning: Gem::Dependency#version_requirements is deprecated and will be removed
on or after August 2010. Use #requirement
Missing these required gems:
RedCloth
You're running: ruby 1.8.7.72 at /usr/bin/ruby1.8 rubygems 1.3.6 at
/home/chuck/.gem/ruby/1.8, /usr/lib/ruby/gems/1.8
Run `rake gems:install`
to install the missing gems.
I installed a Rakefile in my app and tried running rake gems:install but nothing happens and no error message is printed.
How can I resolve this problem?

If it's rails-2.3.x, in your config/enfironment.rb
config.gem 'RedCloth', :lib => 'redcloth'

I have found that gems:install is spotty because of the things that people put in their environments.rb files. If this app isn't using bundler, you should gem install RedCloth and then try again.

I wrote a little more descriptive solution on how to fix this issue. You need to modify the environments.rd file and add
:lib=> 'redcloth'
Read my blog post here
http://spuder.wordpress.com/2011/08/04/missing-these-required-gems-redcloth/

I'm also getting errors sometimes when I'm using Rails. I might wonder its something to do with super user command, like:
sudo gem install <gem name>
Because for me also rake gems:install does nothing and I have to manually install the gem as sudo (I'm talking about Linux box here).

Related

rails server bin/rails:6: warning: already initialized constant APP_PATH error

I've tried a number of things like uninstalling/reinstalling rails and gems but to no avail.
When I go into my new project and run rails s or bundle exec rails server I'm getting this error:
bin/rails:6: warning: already initialized constant APP_PATH
/Users/toabui/Sites/cms/bin/rails:6: warning: previous definition of APP_PATH was here Usage: rails COMMAND [ARGS]
Inside my bin/rails I see this code:
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
Does anyone know why I keep getting that error when I run rails s?
I've googled and it seems like there is an error with the spring gem but I can‛t seem to get it to work.
I couldn't find the an_initilizer.rb in my directory and I tried uninstalling/installing the spring gem but it didn't work.
However I did managed to finally get it working.
Apparently there is some conflict with spring and rails 4+.
I needed to run:
rake rails:update:bin
But I ran across another error:
Library not loaded: libmysqlclient.18.dylib
I ran the following command which I found on another stackoverflow post:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
Then ran the original command:
rake rails:update:bin
Then run the server command:
rails s
And now my WebBrick Server is running.
rake rails:update:bin to the rescue.
If you are on El Capitan (OS X 10.11), Security Integrity Protection (SIP) will prevent linking into /usr/lib to fix mysql. Link it into /usr/local/lib instead:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
This is work for me.
gem uninstall mysql2
bundle install or gem install mysql2
I was getting the same error. Removed spring from Gemfile and re-bundled. Not really a solution though.
I found the code that created this error in config/initializers/an_initializer.rb
require "lib/a_file_i_need"
I changed it for
require "#{ Rails.root }/lib/a_file_i_need"
I got this error by trying to update rails 4 and imagemagick and rmagick.
So I just ran
gem uninstall rmagick
Select the All Versions option. Then try again
EDIT: This happaned again with me just now because I tried to use a gem without installing the required base gem. In my case the solution was to install 'omniauth-google' before trying to use 'omniauth-google-oauth2', but because I didn't install I got the same error again
I got the same error. I had ruby 2.1.3 and rails 4.1.6 running on Mavericks and then I migrated to Yosemite and installed the 4.2.0 rails version an ruby 2.1.5 and my apps I made in the previous version didn't work with the new one, so I made some gem sets with RVM and installed the 2.1.3 version.
Now when I wanted to run the server I got these error:
bin/rails:6: warning: already initialized constant APP_PATH
/Users/Lexynux/_WebProjects/RoR_Apps/SAIIP2/bin/rails:6: warning: previous definition of APP_PATH was here
Usage: rails COMMAND [ARGS]
And as tobu mentioned I ran:
rake rails:update:bin
I got this:
LoadError: dlopen(/Users/Lexynux/.rvm/gems/ruby-2.1.3#SAIIP2/extensions/x86_64-darwin-14/2.1.0-static/mysql2-0.3.16/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.18.dylib
Then I ran this:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
And finally I repeated the first command it the terminal asked me for this:
Overwrite /Users/Lexynux/_WebProjects/RoR_Apps/SAIIP2/bin/rails? (enter "h" for help) [Ynaqdh]
I just typed 'Y' and hit return.
After all this I started working and going well.
Thanks.
I received this error after upgrading postgresql.
$ gem uninstall pg
$ gem install pg
resolved this issue for me.
This happened to me after doing a brew upgrade. My guess is that this broke some gems with native extensions, even though there was no error message pointing to that.
What I ended up doing was completely removing my installed gems (In my case I completely uninstalled and reinstalled the ruby version using rbenv).
Running bundle install recompiled the native extensions, and everything was running again.
I'll post what worked for me.
Comment out
gem 'spring'
Add gem 'net-shh'
and run bundle install
And restart your sever
I got the same error, it happend to be related to gem dotenv.
Instructions were to add the following to Gemfile:
gem 'dotenv', :require => 'dotenv/rails-now'
But as it turned out, dotenv/rails-now caused the error. If you use dotenv don't require rails-now
Are you using pg and mysql in different branches ? If yes, please confirm db config file.
I received this error after upgrading rails. Disabling spring give me a hint that the issue was with:
gem 'google-api-client', require: 'google/api_client'
Changed to:
gem 'google-api-client', '0.9'
Resolved the issue.
I had the same error message output when trying to start an application within a Vagrant environment. It cropped up out of nowhere after zero changes to the application code (and other weird behaviour followed, such as development.rb being deleted upon attempting to run the app).
In the end I simply halted the VM & restarted it, everything was then fine so I'm assuming it was an issue with file syncing / shared folders perhaps? (default Vagrant shared folder being used).
Run these in console:
rake tmp:clear
rake secret
IF rake rails:update:bin gives additional errors:
I had recently been doing some server maintenance and had subsequently updated OpenSSL.
When I tried running the rake rails:update:bin command, I was presented with an error relating to openSSL.
Having rebuilt my version of Ruby (`rvm reinstall ruby-x.x.x' with RVM), both errors went away.
This is always worth a try I guess.
My problem was I was using an outdated version of ruby 1.9.3 with rails 4.2. I upgraded to 2.1.2 , removed the broken project, ran rails new blog to recreate my project, navigated into my newly created app and ran rails server and it worked.
I just had this problem and found that it was being caused by the fact that I had removed a gem from the gemfile without deleting the other require references. In my case, I just had to remove it from config/application.rb.
Had this error recently, it is caused by spring, because of its suggested code in executables:
begin
load File.expand_path('../spring', __FILE__)
rescue LoadError
end
It originally expects a LoadError for spring itself in production, but by this code all other load error will be ignored too.
Thus if you have any other LoadError in rails loading process (for example in routes/init) spring worker startup fails and then there goes branch that tries to load everything again like there was no spring.
For me this issue presented as a result of bundle upgrading rvm-capistrano amongst other things.
Adding this require:false fixed things in the end as per this previous post
gem 'rvm-capistrano', require: false
Although could possibly be an additional issue - as running rake rails:update:bin may have helped clear the initial issue.

'rails s' throwing error

I am configuring a Rails APP. I did bundle install properly. Also using ruby 1.8.7 using RVM. Now after bundle install, it is throwing the below given error while doing rails s.
/usr/local/lib/site_ruby/1.8/rubygems.rb:335:in `bin_path': can't find
executable rails for rails-3.2.9 (Gem::Exception)
Can anyone help me to sort out this?
Using ruby: 1.8.7
Rails Version: 3.0.3
After running bundle install, your Gemfile.lock has a list of all the gems and their versions that are needed.
However, you need to run bundle exec in order for bundler to make those gem versions available to you.
The rails script is an exception, as it invokes bundler for you, but it sounds like something isn't working in your environment.
Try executing the rails script using bundle exec like so:
bundle exec rails s
And see if that helps. Also, from the man who wrote bundler: http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/
You have two rails gem versions in same gemset so it is picking latest version. So you need to specify rails version for rails commands.
Try this:
$ rails _3.0.3_ server

Rails 3.2.1 - Could not find rake-0.9.2.2 in any of the sources

I'm brand new to rails and am trying to dive in to my first project on my Mac, but am running in to an issue when I run Rake -T inside my project's root dir:
Could not find rake-0.9.2.2 in any of the sources
Run 'bundle install' to install missing gems.
After I run 'bundle install' I get:
Your bundle is complete! It was installed into ./rake
But I still get the same error when I call Rake again. My gemfile lists rake as:
gem 'rake', '0.9.2.2'
If I run 'bundle list' I can see:
* rake (0.9.2.2)
I've looked at other posts on stackoverflow and google, but none of the solutions have worked for me. I'd also really appreciate any background on what's going on here, for instance, should rake be installed in to the project directory like this?
I'm not sure what else I should include to help troubleshoot?
Thank you!
Go to https://rvm.io
instal rvm, rvm install 1.9.3, rvm use 1.9.3 --default
then you can manage your gems through rvm
It is the best solution to manage your gems.
please check if rvm is configured correctly - read about .rvmrc and setup_and_load_paths.rb http://blog.ninjahideout.com/posts/the-path-to-better-rvm-and-passenger-integration, also check lines at your nginx(i suppose you use it, cause, i just had exactly same problem) configs passenger_root and passenger_ruby (this one should include smth like output of which ruby + #your_gem_set)
good luck
Have you tried Gem install rake ?
Bundle will not install anything to your path I do not think but you may also get it working by bundle exec rake. If that doesn't work, try bundle exec rake -v0.9.2.2.2
I don't fully understand how bundle works either as running Rails commands on my computer runs Rails 3.2.2 while the bundle runs Rails 3.1.1

running rake fails with Gem::GemNotFoundException ERR

Backstory:
New to rails and attempting to install Passenger on a Mediatemple DV server. I am following and somewhat modifying this CentOS guide here since MT currently does not have any recommended 'how tos' regarding setting up a Rails production environment http://www.freshblurbs.com/installing-ruby-rails-3-centos-nginx.
I have fresh-ly installed gem and then ran gem install rake as root. Now, anytime I try to run
rake some_task
I get the following error
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:370:in `bin_path':
can't find gem rake ([">= 0"]) with executable rake (Gem::GemNotFoundException)
from /usr/local/bin/rake:19:in `<main>'
rake is installed here /usr/local/bin/rake
$PATH is /usr/kerberos/sbin:/usr/kerberos/bin://sbin://bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/bin:/usr/local/bin:/root/bin:/usr/bin:/usr/local/lib
output of gem which rake is /usr/local/lib/ruby/1.9.1/rake.rb
... and unfortunately that's about all I got up my sleeves. What am I missing that's causing this to bomb?
Thanks in advance!
I have the similar problem with rake, but in ruby 1.9.2.
http://betterlogic.com/roger/2010/11/ruby-1-9-2-rake-woe/
Maybe in your case it will be helpful too.
Not sure this'll help maybe it will.. maybe not..
But run a gem list first and make sure both rake and also the passenger gem show up. I think I remember seeing a similar error that was misleading trying to setup a production server recently when running:
passenger-install-apache2-module
face palmed when I realised i hadn't installed the passenger gem yet

How do I fix this error? config.gem: Unpacked gem authlogic-2.1.3 in vendor/gems has no specification file

I get this error when launching my Mongrel server...
$ script/server --debugger
=> Booting Mongrel
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
config.gem: Unpacked gem authlogic-2.1.3 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
=> Debugger enabled
=> Call with -d to detach
=> Ctrl-C to shutdown server
When I run rake gems:refresh_specs like it suggests I get another error though:
rake aborted!
undefined method `installed_source_index' for #<Gem::SourceIndex:0x100551a58>
Any thoughts on how to fix this?
I am not sure why it is broken in Authlogic, but I had to generate it myself.
Try this in your Rails project:
$prompt> cd vendor/gems/authlogic-2.1.3
$prompt> gem specification authlogic > .specification
I'm just going to chime in here, because I experience the same thing today, except with a different gem.
I was updating hoptoad to use the notifier as a gem instead of a plugin, and one of the instructions from the Github page is to unpack the gem into vendor/gems.
I'm on Mac OS X, and I unpacked the gem as so:
$> rake gems:unpack GEM=hoptoad_notifier
After I did this, I got the error specified, and the gem didn't actually unpack (it created the directory in vendor/gems, but didn't actually unpack the gem).
I deleted the directory from vendor/gems, and tried again as:
$> sudo rake gems:unpack GEM=hoptoad_notifier
Worked this time, unpacked properly, and no error.
I believe this is the reason:
http://github.com/binarylogic/authlogic/commit/05e452472616bd60bb81affc75a1cb3d95cf7857
The owner purposely added the gitignore on the .specification file.
I'm guessing u freeze this particular gem and submit it in your code branch under vendor/gems/..and as expected, git ignore this particular file per request
I had to pop into vendor/gems/authlogic and remove '.specification' from the .gitignore
Once you've done that you can run rake gems:refresh_specs
Only problem is that the next time you upgrade this gem the bad .gitignore comes back
I had the same "unknown GEM" problems. After much faffing about I found the following recipe :
First, I installed the gem using the standard "gem install authlogic", which placed the gem in /Library/Ruby/Gems/1.8.
Within RadRails, I used the rake task "gems:unpack" which seems to gather all the gems relevant to your app and place them in /vendor/gems as desired.
I then uninstalled the system wide gem to check it has really worked with : gem uninstall authlogic --install-dir=/Library/Ruby/Gems/1.8
Seems to work well.
Build and install the gem before generating the .specification file
$prompt> cd vendor/gems/authlogic-2.1.3
$prompt> gem build authlogic.gemspec
$prompt> gem install authlogic.gemspec
$prompt> gem specification authlogic > .specification

Resources