Questions tagged [load-path]

63 questions
156
votes
7 answers

Why does Ruby 1.9.2 remove "." from LOAD_PATH, and what's the alternative?

The latest changesets to Ruby 1.9.2 no longer make the current directory . part of your LOAD_PATH. I have a non-trivial number of Rakefiles that assume that . is part of the LOAD_PATH, so this broke them (they reported "no such file to load" for all…
John Feminella
  • 303,634
  • 46
  • 339
  • 357
102
votes
8 answers

Adding a directory to $LOAD_PATH (Ruby)

I have seen two commonly used techniques for adding the directory of the file currently being executed to the $LOAD_PATH (or $:). I see the advantages of doing this in case you're not working with a gem. One seems more verbose than the other,…
Mark W
  • 2,522
  • 3
  • 18
  • 21
63
votes
5 answers

What does the "$" character mean in Ruby?

Been playing with Ruby on Rails for awhile and decided to take a look through the actual source. Grabbed the repo from GitHub and started looking around. Came across some code that I am not sure what it does or what it references. I saw this code…
19
votes
3 answers

what is "$:" in ruby?

Usually be seen in .gemspec file. eg. i18n.gemspec. $: << File.expand_path('../lib', __FILE__)
lchanmann
  • 357
  • 2
  • 10
19
votes
5 answers

Organization of Locale Files in rails app

I currently have the following 4 files in my config/locales of my root application: -en.yml -de.yml -simple_form.en.yml -simple_form.de.yml In my application.rb which resides in a spec/dummy folder for testing the application gem I have the…
Jay
  • 3,012
  • 14
  • 48
  • 99
13
votes
2 answers

How is the default Ruby LOAD_PATH determined?

Assuming I compile my own fresh Ruby (MRI 1.9.3), what is the default LOAD_PATH, and how is that computed?
Alex Gaynor
  • 14,353
  • 9
  • 63
  • 113
12
votes
3 answers

add-to-list 'load-path doesn't seem to work

Whenever I see some installation instruction for an emacs package it always suggests to use add-to-list 'load-path it never works for me. For some reason and I have to use load-file. For example, this will not work: (add-to-list 'load-path…
rabidmachine9
  • 7,775
  • 11
  • 46
  • 59
11
votes
1 answer

Ruby require "no such file to load" error yet clearly in path

I've been trying to get a ruby file to require another ruby file and I feel like I'm going crazy. My setup is as follows Two files in '/raid1/ruby-code/benchmark/' CommandRunner Benchmarker Benchmarker is the main program at this point and wants…
asm
  • 8,758
  • 3
  • 27
  • 48
10
votes
1 answer

gulp-sass work around for load_path support?

Problem: I'm using gulp-sass and would like to define a load_path so that I don't have to have really long @import rules voor bower dependencies e.g. @import "normalize" instead of @import…
Timidfriendly
  • 3,224
  • 4
  • 27
  • 36
9
votes
2 answers

Adding to Rails autoload_path from Gem

I want to write a gem that adds a app/services directory to a Rails application. Since I want to add it from within the Gem i came up with this solution: class Railtie < ::Rails::Railtie config.after_initialize do |app| ::Rails.logger.info…
phoet
  • 18,688
  • 4
  • 46
  • 74
8
votes
4 answers

Why can't I require a file in the parent directory in ruby?

Note that I am not using Rails. I have a directory structure like: foo/ bar/ base_classes/ base_classes.rb base_classes.rb: Dir.glob(File.expand_path(File.join("base_classes/config/constants", "*.rb"))) { |file| require file} …
Jeremy Smith
  • 14,727
  • 19
  • 67
  • 114
8
votes
0 answers

RVM - Ruby integration was extracted to a separate gem (`remove $LOAD_PATH.unshift`)

I was upgrading to Rails 3.2.6 (ruby 1.9.3-p194) and installing RVM on Debian and using Apache2 server (2.2.19). I used these very nice instructions: http://dalibornasevic.com/posts/21-rvm-and-passenger-setup-for-rails-2-and-rails-3-apps/ The Apache…
8
votes
2 answers

Add $LOAD_PATH externally

I understand that to add a path to $LOAD_PATH just do $LOAD_PATH.unshift(path) But I have to add this line to every program I wrote. Is there anyway to add it to the system level? I tried to search a bit on the startup script for Ruby, but did not…
SwiftMango
  • 15,092
  • 13
  • 71
  • 136
7
votes
2 answers

How to refer a local gem in ruby?

I pack some ruby code into a gem. I want to refer the code in the gem in some other code. So in the Gemfile I specify the gem's name, version, and local path. Like: gem 'gemname','0.x', :path => 'RELATIVE_PATH_TO_GEM_FILE' After bundle install, I…
user810923
  • 71
  • 1
  • 2
6
votes
2 answers

Fast (Rspec) tests with and without Rails

I have two classes: 1.Sale is a subclass of ActiveRecord; its job is to persist sales data to the database. class Sale < ActiveRecord::Base def self.total_for_duration(start_date, end_date) self.count(conditions: {date: start_date..end_date}) …
Mike
  • 9,692
  • 6
  • 44
  • 61
1
2 3 4 5