Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@koic
Copy link
Contributor

@koic koic commented Dec 22, 2025

Based on the example, it appears that foo.rb and main.rb are expected to be in the same directory. Since Ruby 1.9, the current directory is not included in $LOAD_PATH by default. As a result, running box.require('foo') as shown in the sample code raises a LoadError:

main.rb:2:in `Ruby::Box#require': cannot load such file -- foo (LoadError)
        from main.rb:2:in `<main>'

To avoid this, it seems simplest to show either box.require('./foo') or box.require_relative('foo'). In this PR, box.require('foo') is replaced with box.require_relative('foo') to make the intention of using a relative path explicit.

This should reduce the chance that users trying Ruby Box will run into an unexpected error.

Based on the example, it appears that `foo.rb` and `main.rb` are expected to be in the same directory.
Since Ruby 1.9, the current directory is not included in `$LOAD_PATH` by default.
As a result, running `box.require('foo')` as shown in the sample code raises a `LoadError`:

```console
main.rb:2:in `Ruby::Box#require': cannot load such file -- foo (LoadError)
        from main.rb:2:in `<main>'
```

To avoid this, it seems simplest to show either `box.require('./foo')` or `box.require_relative('foo')`.
In this PR, `box.require('foo')` is replaced with `box.require_relative('foo')` to make the intention of
using a relative path explicit.

This should reduce the chance that users trying Ruby Box will run into an unexpected error.
@github-actions github-actions bot added the Documentation Improvements to documentation. label Dec 22, 2025
@nobu nobu requested a review from tagomoris December 22, 2025 05:30
@nobu
Copy link
Member

nobu commented Dec 22, 2025

It looks reasonable to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Improvements to documentation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants