Rails 3.0 - can't load ruby-oci8 with Bundler - ruby-on-rails

Rails n00b here - need some assistance. I am trying to port a Rails3 app from Linux to Windows. My Gemfile looks as follows:
source 'http://rubygems.org'
gem 'rails', '3.0.0'
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
gem 'ruby-oci8', '1.0.6'
I do not have an Oracle client on this Windows machine, so I will not be able to natively compile a ruby-oci8 gem.
I have commented out the 'ruby-oci8' line in my Gemfile and I installed the gem manually from here: http://rubygems.org/downloads/ruby-oci8-1.0.6-x86-mswin32-60.gem. I have also copied the necessary DLLs into ruby\bin.
I have verified that it works:
ruby -rubygems -e "require 'oci8'; OCI8.new('user','password','pasdev:2700/gen11dvu').exec('select * from ARCS_USER_LO
GON') do |r| puts r.join(','); end"
This returns lots of data from my db, so I know it works.
However, if I try to require 'oci8' from a rails console (or from the running app), I get the following:
LoadError: no such file to load -- oci8
I presume this happens b/c Rails only loads the gems specified in the Gemfile, but I cannot figure out how to specify it! I already have the gem I need installed:
C:\javadev\ashbtw3>gem list
*** LOCAL GEMS ***
activerecord (3.0.0)
bundler (1.0.21, 1.0.0)
rails (3.0.0)
rake (0.8.7)
ruby-oci8 (1.0.6 x86-mswin32-60)
...etc...
Yet if I uncomment this line in the Gemfile:
gem 'ruby-oci8', '1.0.6'
bundler tries to download and compile another 1.0.6, which of course fails. I have also tried all of these variations unsuccessfully:
gem 'ruby-oci8', '1.0.6', :platforms => :mingw
gem 'ruby-oci8', '1.0.6-x86-mswin32-60', :platforms => :mingw32
gem 'ruby-oci8-1.0.6-x86-mswin32-60'
gem 'ruby-oci8', '1.0.6-x86-mswin32-60'
Why is bundler trying to install a gem that I already have? How do I properly specify the version and platform to make Bundler see that this gem is already installed, and just include it in Gemfile.lock? Is there some other solution here that I can use w/o installing an Oracle client?
EDIT 1:
As per Kyle's suggestion, I tried the following:
gem 'ruby-oci8', :path => 'C:/Ruby187/lib/ruby/gems/1.8/gems/ruby-oci8-1.0.6-x86-mswin32-60
This made Bundler run successfully!
Using ruby-oci8 (1.0.6) from source at C:/Ruby187/lib/ruby/gems/1.8/gems/ruby-oci8-1.0.6-x86-mswin32-60
However, trying to require 'oci8' from the Rails console now gives me this:
C:\javadev\ashbtw3>ruby script\rails console
Loading development environment (Rails 3.0.0)
irb(main):001:0> require 'oci8'
LoadError: no such file to load -- oci8lib
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `load_dependency'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:591:in `new_constants_in'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:in `load_dependency'
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
from C:/Ruby187/lib/ruby/gems/1.8/gems/ruby-oci8-1.0.6-x86-mswin32-60/lib/oci8.rb:20
from C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in `require'
The file it's missing is in under ext/oci8 in the installed gem directory, yet it does not see it.
Is there something additional I can do?

Have you tried specifying the :path ?
gem 'ruby-oci8', :path => '/path/to/ruby-oci8-1.0.6-x86-mswin32-60'

Related

Rails doesn't load actionform gem from Gemfile

My Rails 4.2 app fails to load some GitHub hosted gem (installed via bundler v1.8.2). I am using rvm 1.26.10 (master)
In my Gemfile,
gem 'simple_form', '~> 3.1.0'
gem 'actionform', :github => 'rails/actionform'
Bundler install them in different location:
$ bundle show simple_form
/Users/me/.rvm/gems/ruby-2.1.5#my_app/gems/simple_form-3.1.0
$ bundle show actionform
/Users/me/.rvm/gems/ruby-2.1.5#my_app/bundler/gems/actionform-4a858fecf4c2
Rails never load the actionform gem.
After inserting the line //= require action_form to my app/assets/javascript/application.js file, this error comes
Sprockets::FileNotFound at / couldn't find file 'action_form'
However, the action_form.js file exists in the gem file.
Moreover, when i try to reproduce the readme example, i got this error
NameError at /conferences/new uninitialized constant ActionForm
require 'bundler/setup' is in boot.rb
Any advise about this issue?
Thanks!
The problem is a mismatch between the gem name and the file inside the gem. Because the gem is named 'actionform', Bundler will try to require 'actionform', however the file is actually called action_form.
You can tell Bundler the right file name with this syntax:
gem 'actionform', :github => 'rails/actionform', :require => 'action_form'
Note that it is normal for gems from git sources to be installed into a different location than gems installed from gem servers. It has nothing to do with this problem.

heroku - can't activate test-unit (= 1.2.3, runtime), already activated test-unit-2.3.1. Make sure all dependencies are added to Gemfile

I keep getting this error on heroku....here is my gemfile...what do i do
source 'http://rubygems.org'
gem 'rails', '2.3.8'
gem 'will_paginate', '2.3.12'
gem 'googlecharts'
# gem 'faker'
gem 'httparty'
gem 'bandsintown'
gem 'itunes-search-api','0.1.0', :path => 'vendor/gems/itunes-search-api-0.1.0'
gem 'i18n', '0.4.2'
gem "giggly", "~> 0.1.2"
gem "ruby-paypal",'0.0.5', :path => 'vendor/gems/ruby-paypal-0.0.5'
group :production do
gem 'test-unit', "2.3.1"
gem 'pg'
end
group :development, :test do
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
end
I tried taking it gem 'test-unit', "2.3.1" out and even leaving it without a specific version and I got this error...
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2/lib/rake/file_utils.rb:84: warning: already initialized constant LN_SUPPORTED
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
rake aborted
rake/rdoctask is deprecated. Use rdoc/task instead (in RDoc 2.4.2+)
rake aborted!
can't activate test-unit (= 1.2.3, runtime), already activated test-unit-2.3.1. Make sure all dependencies are added to Gemfile.
/usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/shared_helpers.rb:108:in `block in cripple_rubygems'
Now I am getting this error
/app/lib/tasks/rspec.rake:1:in `<top (required)>'
test-unit is not part of the bundle. Add it to Gemfile.
/usr/ruby1.9.2/lib/ruby/gems/1.9.1/gems/bundler-1.0.7/lib/bundler/shared_helpers.rb:102:in `block in cripple_rubygems'
/app/lib/tasks/rspec.rake:1:in `<top (required)>'
I am so confused...on what to do next
To sum up:
no need of test-unit in production
remove the rspec rake task since you don't use rspec
For me, this error:
/app/lib/tasks/rspec.rake:1:in `<top (required)>'
test-unit is not part of the bundle. Add it to Gemfile.
started unexpectedly when I went to do some maintenance work on an old project. This was triggered by this line in the rspec rake task:
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
In returning to this application, the default Ruby version was upgraded to 1.9. Using RVM to set this back to 1.8 (in my case under Jruby) eliminated this message and got me back going as before without the message.
Charles
An error like this can occur if your code loads some gems before Bundler is run and it happens to load a different version than is specified in Gemfile and Gemfile.lock. When Bundler is run later, it will detect that the wrong version of a gem has been loaded and raise this error. The solution is to make sure the Bundler.setup runs before any other gems are loaded. There are instructions on how to do this in Rails 2.3 on the bundler website, which you should follow:
http://gembundler.com/rails23.html

Heroku deployment using Mongo

Can someone tell me what I am doing wrong? I am trying to push a simple rails app to Heroku that uses MongoDB. My Gemfile contains the following line:
gem "mongo"
When pushing the app to Heroku it error's out with: no such file to load -- mongo
-----> Heroku receiving push
-----> Rails app detected
-----> Detected Rails is not set to serve static_assets
Installing rails3_serve_static_assets... done
-----> Gemfile detected, running Bundler version 1.0.3
Unresolved dependencies detected; Installing...
/usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- mongo (LoadError)
Here is my whole gemfile:
require 'rubygems'
require 'mongo'
source 'http://gemcutter.org'
gem "rails", "3.0.0"
#gem 'rails', :git => 'http://github.com/rails/rails.git'
gem "mongo_mapper"
gem 'mongoid', '2.0.0.beta.20'
gem 'devise', :git => 'git://github.com/plataformatec/devise.git'
gem 'heroku', '1.13.7'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
You dont need either of these lines in your Gemfile:
require 'rubygems'
require 'mongo'
Neither of those are required for bundler to update or install your gems.
Also, is there a reason why you're installing both mongoid and mongo_mapper?
Perhaps another approach that you can use, is to use something like https://mongolab.com, connect you application with the database on the cloud, and then make the deployment (only the rails application).I've been using MongoLabs for a while, and works pretty good, you can check your collections directly from there (you don't need to use the JS shell). This is just a suggestion, to make the deployment easier :)

Can't start Rails 3 app

I have just configured dependencies for a simple Rails application using Gemfile, but I'm not able to start it anymore.
Here is the error message I get:
/Library/Ruby/Site/1.8/rubygems.rb:274:in `activate': can't activate rails (= 2.3.5, runtime) for [], already activated rails-3.0.4 for [] (Gem::LoadError)
from /Library/Ruby/Site/1.8/rubygems.rb:216:in `try_activate'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
...
The Gemfile is configured as follows
source :rubygems
gem 'rails', '3.0.4'
#gem 'rails', '2.3.5'
gem 'fastercsv', '1.5.4'
gem 'comma', '0.4.1'
and my environment.rb contains the following line
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '3.0.4' unless defined? RAILS_GEM_VERSION
Note that if I change that variable to 2.3.5, the server starts.
Any idea about what is causing the issue?
If you want to change an existing gemfile run: bundle update. Bundle install is only used for the initial setup. And by the way we are at 3.0.5 now. I am also wondering was this a rails 2 application? Did you simply swap out the gem version number and expect it to then become a rails 3 app? The environment.rb file in a rails 3 application does not show the rails gem version.

Rails Bundler on windows refuses to install hpricot (even on manual gem install get Error: no such file to load -- hpricot)

Upgraded to rails 3, and using Bundler for gems, in a mixed platform development group. I am on Windows. When I run Bundle Install it completes succesfully but will not install hpricot. The hpricot line is:
gem "hpricot", "0.8.3", :platform => :mswin
also tried
gem "hpricot", :platform => :mswin
Both complete fine but when I try to do a "bundle show hpricot" I get:
Could not find gem 'hpricot' in the current bundle.
If I do a run a rails console and try "require 'hpricot'" I get:
LoadError: no such file to load -- hpricot
I have manually installed hpricot as well, and still get the above error. This worked fine before moving to rails 3.
Try this in console and then do bundle install, it will work:
gem install hpricot --platform=mswin32
It may be that you are using a version of ruby that was built with MinGW in which case your platform will be 'mingw' rather than 'mswin'. Try changing your Gemfile line to the following:
gem "hpricot", "0.8.3", :platform => :mingw
And if you have other developers that are using the current setup and don't wan to break it for them, change it to this:
gem "hpricot", "0.8.3", :platforms => [:mswin, :mingw]

Resources