From: James Byrne Date: 2010-09-03T23:08:36+09:00 Subject: Re: 1.9 require problem James Byrne wrote: > > > I understand the intent of the change. And I take it that > require_relative was provided to maintain the old behaviour. However, > this situation does seem to require a little more in the way of an > explicit explanation of the probable cause of the errors which > inevitably result from using 1.8 code with 1.9. OK. This is not good. If I try to use require_relative I discover that backtracks in the directory tree are ignored. For instance, given this code: #!/usr/bin/env ruby lib_path = File.dirname(__FILE__) + '/../lib/forex/hll_forex_ca_feed' puts lib_path puts("Library file found? " + (File.file?(lib_path + '.rb')).to_s) require_relative lib_path HLLForexCAFeed::Main.new(ARGV).execute I would expect that the file ./bin/../lib/forex/hll_forex_ca_feed.rb would be found. Instead, when I run this program I see this: $ bin/forex bin/../lib/forex/hll_forex_ca_feed Library file found? true bin/forex:9: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:9:in `
Note that the path determined by require_relative: home/byrnejb/Software/Development/Projects/proforma.git/bin/lib/forex/hll_forex_ca_feed) does not accommodate the /../ portion of the relative path provided. It simply discards it. In my opinion, the path should read: home/byrnejb/Software/Development/Projects/proforma.git/lib/forex/hll_forex_ca_feed or home/byrnejb/Software/Development/Projects/proforma.git/bin/../lib/forex/hll_forex_ca_feed Is this intended behaviour? -- Posted via http://www.ruby-forum.com/.