PDA

View Full Version : Ruby Gems Problem



saxsologuy
11-23-2008, 02:04 PM
I am having a problem with my installed Ruby Gems not being linked correctly from the scripts inside my Rails directory. I am a little bit of a n00b at Ruby, but I know it's probably just a few flags I'm missing. I've looked around at a lot of sites, but haven't found anything that works.

This is the error I'm receiving:

/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- scrubyt (LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from test.rb:5

Can I get any help?

Attached is the first few lines in my script file, my environment.db, my .htaccess file, and my .bachrc file.


Script File:


$:.push("/home/nolanher/ruby/gems")
$:.unshift File.join(File.dirname(__FILE__), '../../..//lib')

require 'rubygems'
require 'scrubyt'

#Start Scrubyt


Environment.db


# Be sure to restart your server when you modify this file

ENV['GEM_PATH'] = '/home/nolanher/ruby/.gems:/usr/lib/ruby/gems/1.8'

# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
ENV['RAILS_ENV'] ||= 'production'

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.1.2' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# See Rails::Configuration for more options.

# Skip frameworks you're not going to use. To use Rails without a database
# you must remove the Active Record framework.
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]

# Specify gems that this application depends on.
# They can then be installed with "rake gems:install" on new installations.
# config.gem "bj"
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "aws-s3", :lib => "aws/s3"

# Only load the plugins named here, in the order given. By default, all plugins
# in vendor/plugins are loaded in alphabetical order.
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]

# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{RAILS_ROOT}/extras )

# Force all environments to use the same logger level
# (by default production uses :info, the others :debug)
# config.log_level = :debug

# Make Time.zone default to the specified zone, and make Active Record store time values
# in the database in UTC, and return them converted to the specified local zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Comment line to use default local time.
config.time_zone = 'UTC'

# Your secret key for verifying cookie session data integrity.
# If you change this key, all old sessions will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
config.action_controller.session = {
:session_key => '_first_session',
:secret => '19531dd3aaae05a8ea5587d4cc98e6fd7db98712edcce58c2 ab76f4eafd137bba3ded7d4bbd6d221f59470f4c9d21ce6d6e c025a6f6001272af564f96060a446'
}

# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rake db:sessions:create")
# config.action_controller.session_store = :active_record_store

# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql

# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector

end


.htaccess


#START Ruby on Rails
# General Apache options
AddHandler fastcgi-script .fcgi
AddHandler fcgid-script .fcgi
AddHandler cgi-script .cgi
Options +FollowSymLinks +ExecCGI

# If you don't want Rails to look in certain directories,
# use the following rewrite rules so that Apache won't rewrite certain requests
#
# Example:
# RewriteCond %{REQUEST_URI} ^/notrails.*
# RewriteRule .* - [L]

# Redirect all requests not available on the filesystem to Rails
# By default the cgi dispatcher is used which is very slow
#
# For better performance replace the dispatcher with the fastcgi one
#
# Example:
# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
RewriteEngine On

# If your Rails application is accessed via an Alias directive,
# then you MUST also set the RewriteBase in this htaccess file.
#
# Example:
# Alias /myrailsapp /path/to/myrailsapp/public
# RewriteBase /myrailsapp

SetEnv RAILS_ENV production

RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]

# In case Rails experiences terminal errors
# Instead of displaying this message you can supply a file here which will be rendered instead
#
# Example:
# ErrorDocument 500 /500.html

ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
#END Ruby on Rails



And, lastly my .bashrc file:


# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

export PATH="$PATH:$HOME/ruby/gems/bin"
export GEM_HOME="$HOME/ruby/gems"
export GEM_PATH="$GEM_HOME:/usr/lib/ruby/gems/1.8"
export GEM_CACHE="$GEM_HOME/cache"




Thanks for the help!

cade
11-23-2008, 11:07 PM
It looks like there is a bit of an inconsistency between the push inside your script and your environment.rb file. Is the gem in "gems" or ".gems"? It shouldn't make a lot of difference either way (it should use the push, if I recall Rails' precedence correctly), but it may cause a conflict. How are you installing the the gems? Via CPanel or from the command line? Can you load the gem successfully via IRB?

saxsologuy
11-25-2008, 01:06 AM
Okay, the command seems to be working now. I don't quite remember what changed, but there were a few other things I fixed as well.

nadalbg
11-25-2008, 11:32 AM
I get this when trying to load my ruby gem

-bash-3.00$ ruby axml.rb
axml.rb:3:in `require': no such file to load -- xmlparser (LoadError)
from axml.rb:3

Any ideas,

nadalbg
11-25-2008, 11:44 AM
Just saw that when I load SSH I get this error -bash: /home2/morethb8/.bashrc: line 9: syntax error: unexpected end of file

but I did exactly like is written at the help article http://helpdesk.bluehost.com/kb/index.php?x=&mod_id=2&id=418

nadalbg
11-25-2008, 11:52 AM
My bashrc is

# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

export GEM_HOME=$HOME/ruby/gems
export GEM_PATH=$GEM_HOME:/usr/lib/ruby/gems/1.8
export GEM_CACHE=$GEM_HOME/cache

export PATH=$PATH:$HOME/ruby/gems/bin

and the start of the script

require 'xmlparser'

class AXML

def self.parse_file(file)
root = nil
File.open(file) do |fh|
root = parse(fh)
end
root
end

# Returns the root node (as Element) or nodes (as Array)
def self.parse(stream)
parser = AXML::XMLParser.new
parser.parse(stream)
parser.root


Sorry for the 3 posts in a row

nadalbg
11-30-2008, 04:50 AM
I maanged to fix the bashrc file and the other things, the only thing left is the ruby gem script.
I get this error. If anyone can help me I will be very glad. Thanks

axml.rb:2:in `require': no such file to load -- xmlparser (LoadError)
from axml.rb:2
Its in ruby/gems/gems/axml-0.0.2

thegodmachine
12-09-2008, 06:16 AM
Just saw that when I load SSH I get this error -bash: /home2/morethb8/.bashrc: line 9: syntax error: unexpected end of file

but I did exactly like is written at the help article http://helpdesk.bluehost.com/kb/index.php?x=&mod_id=2&id=418

I found that the GEM_PATH provided in that artical was incorrect. For my environment.rb I used the following instead:

ENV["GEM_PATH"]= "/home1/webdoubt/ruby/gems:/usr/lib/ruby/gems/1.8"

Note also "home1" NOT "home". Use the shell command "pwd" to check what path you should use. ie.

$ cd ~/
$ pwd
... shows path to your home directory.