Is $LOAD_PATH used for 'require "some_file"?'

Currently working on Winderz trying to figure out why

   require "some_file"

Fails but

   require "./some_file"

works. The $LOAD_PATH includes the directory the files being run and loaded
are in. Hit this issue on Linux as well, not sure if it's operator error or
what.

Why does require need the "./" to find a file in the $LOAD_PATH?

Thanks!

Leam

···

--
Mind on a Mission <http://leamhall.blogspot.com/>

Are you sure you set the load path correctly?
It should work, and works for me (on Linux).

But: why not use require_relative? That's exactly the use case.

Unless you are creating a gem, then the gem's lib directory
should already be in the load path when installed properly.
Then you can (should?) use require with paths relative to `lib',
but without the leading ".": i. e. the file `gem-dir/lib/mygem.rb'
can use `require "mygem/helper"', which should load
`gem-dir/lib/mygem/helper.rb'.

Regards,
Marcus

···

Am 06.02.2017 um 13:58 schrieb leam hall:

Currently working on Winderz trying to figure out why

   require "some_file"

Fails but

   require "./some_file"

works. The $LOAD_PATH includes the directory the files being run and
loaded are in. Hit this issue on Linux as well, not sure if it's
operator error or what.

Why does require need the "./" to find a file in the $LOAD_PATH?

--
GitHub: https://github.com/stomar/
PGP: 0x6B3A101A

I recall you were using 1.8.7 on CentOS; are you also using that version on
Windows?

···

On Mon, Feb 6, 2017 at 6:58 AM, leam hall <leamhall@gmail.com> wrote:

Currently working on Winderz trying to figure out why

   require "some_file"

Fails but

   require "./some_file"

works. The $LOAD_PATH includes the directory the files being run and
loaded are in. Hit this issue on Linux as well, not sure if it's operator
error or what.

Why does require need the "./" to find a file in the $LOAD_PATH?

Thanks!

Leam

--
        Eric Christopherson

I am still working on this. The simple case works on Linux but the actual code fails. My guess is I am just not seeing something and need to spend some time mapping out the code.

Leam

···

On 02/06/17 15:47, sto.mar@web.de wrote:

Am 06.02.2017 um 13:58 schrieb leam hall:

Currently working on Winderz trying to figure out why

   require "some_file"

Fails but

   require "./some_file"

works. The $LOAD_PATH includes the directory the files being run and
loaded are in. Hit this issue on Linux as well, not sure if it's
operator error or what.

Why does require need the "./" to find a file in the $LOAD_PATH?

Are you sure you set the load path correctly?
It should work, and works for me (on Linux).

But: why not use require_relative? That's exactly the use case.

Unless you are creating a gem, then the gem's lib directory
should already be in the load path when installed properly.
Then you can (should?) use require with paths relative to `lib',
but without the leading ".": i. e. the file `gem-dir/lib/mygem.rb'
can use `require "mygem/helper"', which should load
`gem-dir/lib/mygem/helper.rb'.

Regards,
Marcus

Hey Eric, I was using 2.2 and then down to 2.1.9 from RubyInstaller because
of issues. Haven't seen 2.4.0 for Windows yet. and even then I may or may
not be able to install it at work.

···

On Thu, Feb 9, 2017 at 10:43 AM, Eric Christopherson < echristopherson@gmail.com> wrote:

I recall you were using 1.8.7 on CentOS; are you also using that version

on Windows?

--
        Eric Christopherson

--
Mind on a Mission <http://leamhall.blogspot.com/>

Ah, just to clarify, the issue was DevKit install as I was trying to use
Nokogiri. Now using REXML and just installed Ruby 2.3.3 on Winderz.

···

On Thu, Feb 9, 2017 at 10:48 AM, leam hall <leamhall@gmail.com> wrote:

On Thu, Feb 9, 2017 at 10:43 AM, Eric Christopherson < > echristopherson@gmail.com> wrote:

I recall you were using 1.8.7 on CentOS; are you also using that version

on Windows?

--
        Eric Christopherson

Hey Eric, I was using 2.2 and then down to 2.1.9 from RubyInstaller
because of issues. Haven't seen 2.4.0 for Windows yet. and even then I may
or may not be able to install it at work.

--
Mind on a Mission <http://leamhall.blogspot.com/>

FWIW, modern Nokogiri compiles natively on Windows with DevKit. Here's a
recent test run from Nokogiri's pipeline:

https://ci.nokogiri.org/teams/nokogiri-core/pipelines/nokogiri/jobs/ruby-2.3-devkit/builds/3

···

On Thu, Feb 9, 2017 at 11:22 AM, leam hall <leamhall@gmail.com> wrote:

Ah, just to clarify, the issue was DevKit install as I was trying to use
Nokogiri. Now using REXML and just installed Ruby 2.3.3 on Winderz.

I was using current Nokogiri. Unfortunately, installing DevKit requires admin on the box.

···

On 02/10/17 03:11, Mike Dalessio wrote:

On Thu, Feb 9, 2017 at 11:22 AM, leam hall <leamhall@gmail.com > <mailto:leamhall@gmail.com>> wrote:

    Ah, just to clarify, the issue was DevKit install as I was trying to
    use Nokogiri. Now using REXML and just installed Ruby 2.3.3 on Winderz.

FWIW, modern Nokogiri compiles natively on Windows with DevKit. Here's a
recent test run from Nokogiri's pipeline:

    https://ci.nokogiri.org/teams/nokogiri-core/pipelines/nokogiri/jobs/ruby-2.3-devkit/builds/3