rails 3 - LoadError (cannot load such file -- zip/zip) - ruby-on-rails-3

I'm using rubyzip to zip a csv file so uses can download it. This works perfectly in development mode. But when I tried zipping the file on the production server (rackspace) I received the error: LoadError (cannot load such file -- zip/zip). Is it a path issue? Anyone know a fix?
The error is being called in my code on this line: require 'zip/zip'
I've tried the solution from here, but it didn't help.

I fixed this problem by specifying gem version 0.9.9 in Gemfile:
gem 'rubyzip', "~> 0.9.9"
Using rubyzip (1.0.0) caused an error.

When upgrading rubyzip to 1.0.0 change require 'zip/zip' to require 'zip'.

I had this problem after adding roo to a Rails project.
Roo needed the new interface, something else (some other gem) was using the old interface - so most of these answers didn't work (couldn't lower the version of rubyzip, rubyzip2 is deprecated, didn't have require zip/zip in my project).
What worked for me was cassio-s-cabral's answer referring to the rubyzip github page.
gem 'rubyzip', '>= 1.0.0' # will load new rubyzip version
gem 'zip-zip' # will load compatibility for old rubyzip API.

I had the same problem: error thrown on "require 'zip/zip'" code, and the solution from this post also did not help.
After a long research I found that the problem was that my "require 'zip/zip'" statement was done in a separate
lib/exporters/package_exporter.rb
file, and for some reason "require" statements are not handled in "lib" folder in production by default.
When I moved "require 'zip/zip'" to the beginning of my
app/controllers/packages_controller.rb
the problem was solved!

I had a similar issue with active_support, just added the 'zip' gem to my Gemfile and it worked fine

I'm use rubyzip2 gem to fix this problem
gem 'rubyzip2'

what work for me was to install 2 gems:
gem install rubyzip
gem install zip
and in the script put
require 'rubygems'
require 'zip/zip'

In their github page explains what to do.
Rubyzip interface changed!!! No need to do require "zip/zip" and Zip
prefix in class names removed.
If you have issues with any third-party gems what required old
version of rubyzip you can use next workaround:
gem 'rubyzip', '>= 1.0.0' # will load new rubyzip version
gem 'zip-zip' # will load compatibility for old rubyzip API.

Related

`java.lang.VerifyError: class org.bouncycastle.asn1.ASN1Primitive` after installing Neo4j-Devise gem on JRuby

I'm pretty new to programming and have been trying to follow the Team Treehouse tutorials. However, whilst working on my own project, I've been building an app with JRuby and Neo4j. I've managed to make my way through a few differences so far, but seem to be stuck now. I've just installed the Neo4j-Devise gem and everything has been working ok, but now I seem to be getting this error whenever I try to start the server... or do anything useful really:
LoadError: load error: jopenssl/load -- java.lang.VerifyError: class org.bouncycastle.asn1.ASN1Primitive overrides final method equals.(Ljava/lang/Object;)Z
require at org/jruby/RubyKernel.java:1083
(root) at C:/jruby-1.7.9/lib/ruby/gems/shared/gems/jruby-openssl-0.9.4/lib/jruby-openssl.rb:5
require at org/jruby/RubyKernel.java:1083
(root) at C:/jruby-1.7.9/lib/ruby/gems/shared/gems/bundler-1.3.5/lib/bundler/runtime.rb:1
each at org/jruby/RubyArray.java:1613
require at C:/jruby-1.7.9/lib/ruby/gems/shared/gems/bundler-1.3.5/lib/bundler/runtime.rb:72
each at org/jruby/RubyArray.java:1613
require at C:/jruby-1.7.9/lib/ruby/gems/shared/gems/bundler-1.3.5/lib/bundler/runtime.rb:70
require at C:/jruby-1.7.9/lib/ruby/gems/shared/gems/bundler-1.3.5/lib/bundler/runtime.rb:59
require at C:/jruby-1.7.9/lib/ruby/gems/shared/gems/bundler-1.3.5/lib/bundler.rb:132
require at org/jruby/RubyKernel.java:1083
(root) at C:/Sites/Knock4/config/application.rb:14
tap at org/jruby/RubyKernel.java:1891
(root) at C:/jruby-1.7.9/lib/ruby/gems/shared/gems/railties-3.2.16/lib/rails/commands.rb:1
require at org/jruby/RubyKernel.java:1083
(root) at script/rails:6
I have read a few other pages on here suggesting that similar errors can be caused by differences in Bouncycastle versions, but I've tried changing them (at least I think I have, perhaps I've been doing that wrong!) and I keep getting the same error.
Any assistance would be greatly appreciated!
The gem file is as follows:
source 'https://rubygems.org'
gem 'rails', '3.2.16'
gem 'jruby-openssl'
gem 'devise', '2.2.7'
gem 'devise-neo4j', :git => 'git://github.com/cfitz/devise-neo4j.git', :branch => 'devise2'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'therubyrhino'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :development, :test do
gem "rspec-rails"
end
gem "neo4j", ">= 2.2.0"
gem 'neo4j-admin'
It appears that the neo4j-admin-0.2.0-java gem includes lib/neo4j-admin/jars/bcprov-jdk16-140.jar. Unpacking that JAR shows that there are bouncycastle classes included.
Looking at the docs for ASN1Primitive, we can see that it inherits from ASN1Object. Running javap on the ASN1Object included in the above JAR, we can see what equals is defined as (extra lines removed):
$ javap ASN1Object.class | grep equals
public final boolean equals(java.lang.Object);
This data correlates with this related question. Looking at the MANIFEST.MF file at the root of the JAR, it says
Implementation-Version: 1.40.0
So JRuby is likely including a newer version of bouncycastle and you have a gem providing an older version; welcome to DLL Hell :-). I'm not sure of the best solution here. You could delete the bcprov JAR as a quick hack, but who knows what that might do. You should check to see if there is a newer version of the neo4j gems that might work around this. If not, you should probably file a bug with them so that they are aware (if there isn't one already).
EDIT
Here is the bug report. It doesn't look to have been worked on in quite a while.
EDIT 2
Of course, if you don't need the neo4j-admin gem, you can probably remove it from your Gemfile and keep on trucking.

error while deploying rails app to ec2 using rubber gem `response_call': Expected(200) <=> Actual(400 Bad Request) (Excon::Errors::BadRequest)

when I do cap rubber:create_staging, I am getting the following error when rubber tries to create ec2 instance. Am I missing any configuration setting?
** Creating instance ami-eafa5883/t1.micro/elearn_production_default,elearn_production_web,elearn_production_web_tools,elearn_production_production,elearn_production_apache,elearn_production_app,elearn_production_passenger,elearn_production_collectd,elearn_production_common,elearn_production_monit,elearn_production_db,elearn_production_mysql,elearn_production_mysql_master,elearn_production_elasticsearch,elearn_production_examples,elearn_production_graphite_server,elearn_production_graphite_web,elearn_production_graylog_elasticsearch,elearn_production_graylog_mongodb,elearn_production_mongodb,elearn_production_graylog_server,elearn_production_graylog_web,elearn_production_haproxy/us-east-1b
/Users/svisamsetty/.rvm/gems/ruby-1.9.3-p429/gems/excon-0.22.1/lib/excon/middlewares/expects.rb:10:in response_call':
Expected(200) <=> Actual(400 Bad Request) (Excon::Errors::BadRequest)
from /Users/svisamsetty/.rvm/gems/ruby-1.9.3-p429/gems/excon-0.22.1/lib/excon/connection.rb:355:inresponse'
I'm having the same problem. It looks like it is covered as Issue #362 on the Rubber github page:
https://github.com/rubber/rubber/issues/362
I downgraded my excon version from 0.22.01 to 0.21.0
Adding this in the gem file and then bundle, fixed the problem.
gem 'excon', '~> 0.21.0'
I am not aware of the root cause though.
I solved this by updating the fog gem by running:
bundle update fog
Aparently I was very outdated running fog 1.9.0. Now im running 1.23.0 and got to successfully deploy to EC2 by following Rubber's Railscasts (http://railscasts.com/episodes/347-rubber-and-amazon-ec2)
This also updated the following gems to these versions:
fog-core 1.23.0
net-scp 1.2.1
fog-json 1.0.0
List item
inflecto 0.0.2
fog-brightbox 0.1.1
fog-softlayer 0.3.11
ipaddress 0.8.0
mini_portile 0.6.0
Nokogiri depends on libxml2-2.9.0 library so be sure to have that installed
Hope it helps!!

no such file to load -- google_chart using gem gchartrb

I am trying to use the gem gchartrb to create some graphs/charts in my RoR application.
I have looked into several tutorial and all say the same thing, that I have to add
require 'google_chart'
But I am getting the message:
no such file to load -- google_chart
I have the require inside my controller, I have confirmed that the gem is installed.
I am using Rails 3.
Also, I have tried adding config.gem 'gchartrb', :lib => 'google_chart' in my environment.rb as suggested here but nothing changed
Thanks for your help
EDIT:
I have also tried with the gem googlecharts, what I have in my Gemfile is:
gem "googlecharts", :require => "gchart"
but I get no such file to load -- gchart when I try to load the view.
I am not sure, it is required now or not. But it worked for me in Rails 3 as well. I am using Rails 3.0.10. I added below 2 lines and it worked for me.
1) gem 'gchartrb' in Gemfile
2) require 'google_chart' in config/boot.rb
Hope it helps!
config.gem is for rails 2.3.X.
For rails 3, you will need to add the gem to your Gemfile and run gem bundle
You may also need to check that the google_charts gem actually supports Rails 3...
Given that the latest code update seems to have been in 2008 - that might not actually be likely. :(
You can try it anyway and see...

Heroku app crashes, logs say "No such file to load -- nokogiri (LoadError)"

I had a working app, added Nokogiri, to parse some xml, runs fine locally.
My Gemfile includes: gem 'nokogiri'
I ran bundle install and verified my Gemfile.lock includes DEPENDENCIES ... nokogiri
In my controller class I added (didnt thinkI had to but got an error locally if I didnt):
class MydealController < ApplicationController
require 'rubygems'
require 'open-uri'
require 'nokogiri'
when I use my browser to get the url in MydealController that uses nokogiri doc = Nokogiri::XML(getresult) Heroku crashes.
heroku logs shows this error No such file to load -- nokogiri (LoadError)
Looking at what happens when I git push heroku I do not see nokogiri on the list of many many gems that get installed. Heroku says the push was fine, but nokogiri is not listed and I get the aforementioned error...
It seems that when using Windows Gemfile.lock will contain version of nokogiri gem specific for windows, solution is to remove Gemfile.lock and push to heroku.
More info on this subject here
Your mission should you choose to accept it.
Ensure:
nokogiri is in Gemfile.lock
Gemfile.lock is committed to git
you push the commit that has nokogiri in Gemfile.lock to Heroku
Good luck! This message will self destruct in 10 seconds...
Just had the same problem -- you have to run bundle install to get it added to the Gemfile.lock which heroku looks at to find uninstalled dependencies.
This might help to understand the reason:
http://devcenter.heroku.com/articles/ps
Indeed removing Gemfile.lock might help. All other compiled gem will cause isseu. Best way is to ask Heroku's support.
Only found this article:
http://ganeshprasadsr.blogspot.com/2010/10/installing-nokogiri-for-rails-3-app-on.html
Try to remove require 'nokogiri' from controller.
It works for me.

Rails 3 Initializers: No such file to load

I am trying to use the Sunlight API gem with a Rails project. I have installed the gem and can successfully use it from irb.
However, when I put the require statement (require 'sunlight') in sunlight.rb in config/initializers, I get the following error:
/opt/local/lib/ruby/gems/1.8/gems/activesupport-3.0.0.beta3/lib/active_support/dependencies.rb:209:in `require': no such file to load -- sunlight (LoadError)
I checked the permissions on the gems directory, and it is world readable/executable.
Here is the code from sunlight.rb:
require 'rubygems'
require 'sunlight'
Sunlight::Base.api_key = 'bb7b775755054c54aa9715d202f6785c'
Can anyone tell me how to fix this? TIA!
Is sunlight listed in your Gemfile? Rails3 uses Bundler to manage Gem installations.