Actions
Bug #3799
closedUnexpected behaviour of require_relative
Description
=begin
I have this code written to handle ruby 1.8 and 1.9.2:
#!/usr/bin/env ruby
library = '/../lib/forex/hll_forex_ca_feed' if RUBY_VERSION < '1.9.2' require File.dirname(__FILE__) + library else require_relative File.dirname(__FILE__) + '/..' + library end HLLForexCAFeed::Main.new(ARGV).execute
This code works with 1.8.6+ and 1.9.2. However, please note the insertion of an additional directory reverse traversal. If I do not provide this to Ruby-1.9.2 then the require fails with this error:
$ bin/forex bin/forex:8:in `require_relative': no such file to load -- /home/byrnejb/Software/Development/Projects/proforma.git/bin/lib/forex/hll_forex_ca_feed (LoadError) from bin/forex:8:in `
My question is: Why does Ruby-1.9.2-p0 require the additional backtrack?
=end
Updated by nobu (Nobuyoshi Nakada) about 14 years ago
=begin
Hi,
At Wed, 8 Sep 2010 01:59:01 +0900,
James Byrne wrote in [ruby-core:32108]:
$ bin/forex bin/forex:8:in `require_relative': no such file to load -- /home/byrnejb/Software/Development/Projects/proforma.git/bin/lib/forex/hll_forex_ca_feed (LoadError) from bin/forex:8:in `My question is: Why does Ruby-1.9.2-p0 require the additional backtrack?
Is this the real code?
library = '../lib/forex/hll_forex_ca_feed'
require_relative library
I can't reproduce the error with the above.
--
Nobu Nakada
=end
Updated by nobu (Nobuyoshi Nakada) about 14 years ago
- Category set to core
- Status changed from Open to Feedback
- ruby -v set to 1.9.2-p0
=begin
=end
Updated by naruse (Yui NARUSE) almost 14 years ago
- Status changed from Feedback to Rejected
=begin
No feedback.
=end
Actions
Like0
Like0Like0Like0