Rails 2 - Problems running project - ruby-on-rails

I work with JRuby and Rails 3.2 but now I've found I got to work on a project on Rails 2.
I know some basic things about Rails 2 like the command jruby ./script/server to start the server instead of rails s but when we start talking about gems in Rails 2 things get complicated for me.
Right now I need to run the project and I'm getting the next errors:
First this repetitive message:
NOTE: Gem::SourceIndex#add_spec is deprecated, use Specification.add_spec. It will be removed on or after 2011-11-01.
Gem::SourceIndex#add_spec called from C:/jruby-.6.7.2/lib/ruby/site_ruby/1.8/rubygems/source_index.rb:91.
Also this:
config.gem: Unpacked gem activerecord-jdbc-adapter-0.9 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem activerecord-jdbcmysql-adapter-0.9 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem builder-2.1.2 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem ci_reporter-1.6.0 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem CVS in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem CVS in vendor/gems not in a versioned directory. Giving up.
config.gem: Unpacked gem jdbc-mysql-5.0.4 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem remarkable-3.1.8 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem remarkable_activerecord-3.1.8 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem remarkable_rails-3.1.6 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem ruby-ole-1.2.10.1 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem spreadsheet-0.6.4.1 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
config.gem: Unpacked gem will_paginate-2.2.2 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this.
And finally right when the server it's about to start:
=> Booting Mongrel
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
WARNING: Using default logging
RuntimeError: will_paginate 3.0 is not compatible with Rails 2.3 or older
(root) at C:/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/will_paginate-3.0.4/lib/will_paginate.rb:8
require at org/jruby/RubyKernel.java:1033
require at C:/jruby-1.6.7.2/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:60
require at C:/jruby-1.6.7.2/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:55
require at D:/MyProject/vendor/rails/activesupport/lib/active_support/dependencies.rb:156
new_constants_in at D:/MyProject/vendor/rails/activesupport/lib/active_support/dependencies.rb:521
new_constants_in at D:/MyProject/vendor/rails/activesupport/lib/active_support/dependencies.rb:520
require at D:/MyProject/vendor/rails/activesupport/lib/active_support/dependencies.rb:156
(root) at C:/jruby-1.6.7.2/lib/ruby/gems/1.8/gems/will_paginate-3.0.4/lib/will_paginate.rb:67
require at org/jruby/RubyKernel.java:1033
require at C:/jruby-1.6.7.2/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36
require at D:/MyProject/vendor/rails/activesupport/lib/active_support/dependencies.rb:156
new_constants_in at D:/MyProject/vendor/rails/activesupport/lib/active_support/dependencies.rb:521
new_constants_in at D:/MyProject/vendor/rails/activesupport/lib/active_support/dependencies.rb:520
require at D:/MyProject/vendor/rails/activesupport/lib/active_support/dependencies.rb:156
(root) at D:/MyProject/config/environment.rb:84
require at org/jruby/RubyKernel.java:1033
require at D:/MyProject/vendor/rails/railties/lib/commands/server.rb:36
(root) at ./script/server:3
I would provide any other details to help solving this just let me know. Thnaks!

Related

Cannot load --spec_helper

I am running Rspec 3.0.0 and Ruby 1.9.3.
I was going through the test-first ruby tutorial: https://github.com/alexch/learn_ruby
When i go through the first excercise: 00_hello and run rake, I keep getting the following error:
c:\learn_ruby\00_hello>rake
(in c:/learn_ruby)
C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:
36:in `require': cannot load such file -- spec_helper (LoadError)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custo
m_require.rb:36:in `require'
I tried suggestions such as putting the following in the gemfile:
group :development, :test do gem 'rspec-rails', '~> 3.0.0.beta'
end
bundle install
bundle exec
rails generate rspec:install
that didn't help matters either, I also tried rspec --init, but I still keep getting the same error. I put require spec_helper in the hello_spec file too. Can someone please help me out?
$ bundle install
$ bundle exec
$ rails generate rspec:install
Should be ran from the terminal, not put inside the gemfile.
Run bundle in the terminal then try your rake command again.

Rake db:migrate error - paperclip

I have installed Paperclip but I have error when I try to run
rake db:migrate
after
rails generate paperclip asset photo
I get
cannot load such file -- paperclip/tasks/attachments
What is wrong? This folder exists with that file.
Try using:
bundle exec rake db:migrate
When I tried downloading it as a plugin (rails plugin install ... ), I saw the same problem. I deleted the plugins from vendor/plugins directory and then added the paperclip gem to gemfile (gem "paperclip", "~> 3.0") and everything now works. You may want to give it a try.
To make sure paperclip is loaded and the version which supports attachments, do
bundle show paperclip
Open the gem in text editor and check if paperclip/tasks/attachments.rb is present. If no, then the version of the gem needs to be upgraded or uninstall all paperclip gem versions and do a fresh install. paperclip-3.5.0 works.
If the version is correct and if it still throws error, include
require 'paperclip'
in your boot.rb.
This forces rails to include the gem at boot time.

Rails - rake:gems:install - not installing gems

If i define a few gems in my config/environments/test.rb file like this:
config.gem "rspec"
config.gem "rspec-rails"
config.gem "mocha"
and then run 'rake gems:install RAILS_ENV=test'
I get the following error:
Missing these required gems:
mocha
Run `rake gems:install` to install the missing gems.
however if I run rake gems:install like it says it will continue to recurse like this forever.
How do I actually get the gems to install using rake (not gem install)?
thanks!
I wonder, is there a reference to something from the mocha gem in your rake file or environment.rb file? I've seen issues like this before and it presents as this type of problem.
Try installing mocha 'manually' with...
gem install mocha
Then see if you can run rake gems:install.
I ran into this problem as well, and followed the directions here to resolve it. Specifically, deleting and regenerating lib/tasks/rspec.rake is pretty crucial. Also, adding
:lib => false
to
config.gem "rspec", :lib => false, :version => ">= 1.2.0"
helped.
I found this was a GEM_PATH issue. Basically, rails can't find the gems you've installed and even though they're there, they're completely invisible. A bit weird, but hey.
On dreamhost I had to configure the line:
ENV['GEM_PATH'] = '/home/<my_account>/.gems:/usr/lib/ruby/gems/1.8/gems'
in config/environment.rb
but on my dev box this doesn't work for me and has to be removed entirely.
YMMV but I'd suggest that's a good place to start looking.
Which platform are you using? If it it window then
Execute Below command and its works
gem install mocha --platform=mswin32

Unpacked gem in vendor/gems not in a versioned directory

I unpacked a gem into my vendor/gems directory and tried to run my Rails app.
I got this message:
Unpacked gem in vendor/gems not in a versioned directory
I don't understand this error and judging by the Google search results for this error there are not many people who have experienced this problem.
Could this mean I also need to vendor Rails to use vendor/gems?
The much easier and more robust way is to use gem dependencies.
Then if you want to unpack your gems into vendor/gems its as easy as typing:
rake gems:unpack
You do not need to vendor rails in order to vendor gems, the error appears to be a user error you are decompressing the gem into the wrong location and missing some version info.
You don't need to vendor Rails to use vendor gems.
Normally gems unpack to a directory called something like vendor/gems/some_gem-1.2.3. Check that all your vendored gem directories follow this pattern (i.e. GEM_NAME-VERSION).
Did you do this manually or using rake? Since a gem in the vendor/gems directory has this format - gem-name-VERSION.
For example the ruby-openid gem will be unpacked to vendor/plugins/ruby-openid-2.1.7/.
Try using rake gems:unpack to unpack the gems.

What could prevent the creation of a gem specification file?

I tried to update the specs on a gem that didn't have a .specification file.
1. cd {application_home_directory}
2. rake gems:refresh_specs
When I did, I received the recursive warning:
config.gem: Unpacked gem in vendor/gems has no specification file.
Run 'rake gems:refresh_specs' to fix this.
I've also tried this, which also fails to create a specification without any error/warning:
1. cd vendor/gems/gemname
2. gem specification gemname > .specification
What could prevent the creation of a gem specification file in these cases?
Do you have config.gem statements for your gems in your environment.rb file? In my experience, you need to have the gems set up in your configuration in order for rake gems:refresh_specs to know about them.

Resources