I want to run a ruby script on heroku server. The problem is that when I run the script on Heroku it seems to see no gems! Here is a sample test situation I have just created.
I have a simple script in Ruby in test.rb file:
require 'rubygems'
require 'mechanize'
puts "Success!"
I also have a Gemfile:
source :rubygems
ruby '1.8.7'
gem 'mechanize'
Everything works on my local machine
~/Ruby/test % ruby test.rb
Success!
When I push it to heroku it looks fine
~/Ruby/test % git push heroku master
Enter passphrase for key '/home/sadie/.ssh/id_rsa':
Counting objects: 9, done.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (9/9), 1.02 KiB, done.
Total 9 (delta 1), reused 0 (delta 0)
-----> Heroku receiving push
-----> Ruby app detected
-----> Using Ruby version: ruby-1.8.7
-----> Installing dependencies using Bundler version 1.2.0
Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
Fetching gem metadata from http://rubygems.org/.......
Installing unf_ext (0.0.5) with native extensions
Installing unf (0.0.5)
Installing domain_name (0.5.3)
Installing mime-types (1.19)
Installing net-http-digest_auth (1.2.1)
Installing net-http-persistent (2.7)
Installing nokogiri (1.5.5) with native extensions
Installing ntlm-http (0.1.1)
Installing webrobots (0.0.13)
Installing mechanize (2.5.1)
Using bundler (1.2.0)
Your bundle is complete! It was installed into ./vendor/bundle
Cleaning up the bundler cache.
-----> Discovering process types
Procfile declares types -> (none)
Default types for Ruby -> console, rake
-----> Compiled slug size is 7.3MB
-----> Launching... done, v3
http://nameless-river-3415.herokuapp.com deployed to Heroku
To [email protected]:nameless-river-3415.git
* [new branch] master -> master
But running the script fails:
~/Ruby/test % heroku run 'ruby test.rb'
Running `ruby test.rb` attached to terminal... up, run.1
/app/vendor/ruby-1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- mechanize (LoadError)
from /app/vendor/ruby-1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from test.rb:2
Thanks in advance!