Skip to content

Allow to use require_relative from eval and irb environment #139

Closed
wants to merge 4 commits into from

4 participants

@LTe
LTe commented Jul 5, 2012

Before patch

1.9.3p125 :001 > require_relative "file"
LoadError: cannot infer basepath
    from (irb):1:in `require_relative'
    from (irb):1
    from /home/lite/.rvm/rubies/ruby-1.9.3-p125-perf/bin/irb:16:in `<main>'

After patch

1.9.3p125 :001 > require_relative "file"
 => true 
@shyouhei
Ruby Programming Language member
shyouhei commented Jul 5, 2012

Can you also modify necessary files so that make passes?

@LTe
LTe commented Jul 5, 2012

Can you also modify necessary files so that make passes?

For me make runs without problems. What do you mean by 'necessary files'?

@LTe LTe Allow to use require_relative from eval and irb environment
Ruby also can recognize path through current thread control frame
d2b02da
@shyouhei
Ruby Programming Language member
shyouhei commented Jul 5, 2012

For me make runs without problems. What do you mean by 'necessary files'?

I suspect that's because you're using a preexisting build directory. Create another folder elsewhere and start from cloning your repo into it.

@LTe
LTe commented Jul 5, 2012
lite@LTE-RB ~> git clone git@github.com:LTe/ruby.git
Cloning into 'ruby'...
remote: Counting objects: 229291, done.
remote: Compressing objects: 100% (45946/45946), done.
remote: Total 229291 (delta 182177), reused 227095 (delta 181540)
Receiving objects: 100% (229291/229291), 77.43 MiB | 2.90 MiB/s, done.
Resolving deltas: 100% (182177/182177), done.

lite@LTE-RB ~> cd ruby/
(trunk=85bb4) lite@LTE-RB ~/ruby> git checkout require_relative 
Branch require_relative set up to track remote branch require_relative from origin.
Switched to a new branch 'require_relative'
(require_relative=d2b02) lite@LTE-RB ~/ruby> autoconf
(require_relative=d2b02) lite@LTE-RB ~/ruby> ./configure
*** stuff ***
config.status: creating Makefile
config.status: creating ruby-2.0.pc
(require_relative=d2b02) lite@LTE-RB ~/ruby> make -j3
*** stuff ***
done without error
(require_relative=d2b02) lite@LTE-RB ~/ruby> sudo make install
(require_relative=d2b02) lite@LTE-RB ~/ruby> /usr/local/bin/ruby -v
ruby 2.0.0dev (2012-07-05 trunk 36321) [x86_64-linux]
@nobu
Ruby Programming Language member
nobu commented on load.c in d2b02da Jul 5, 2012

no needs to call realpath here

LTe replied Jul 5, 2012

Removed

@shyouhei
Ruby Programming Language member
shyouhei commented Jul 5, 2012

OK so when I checked your repo at first (was LTe@99392d9), it broke the compilation. But now (LTe@f58d7c6) it compiles cleanly.

@nobu nobu and 1 other commented on an outdated diff Jul 6, 2012
@@ -497,7 +497,10 @@ struct loaded_feature_searching {
{
VALUE base = rb_current_realfilepath();
if (NIL_P(base)) {
- rb_loaderror("cannot infer basepath");
+ VALUE path = rb_find_file(FilePathValue(fname));
@nobu
Ruby Programming Language member
nobu added a note Jul 6, 2012

also rb_find_file() is not needed, since rb_require_safe() calls it.

@LTe
LTe added a note Jul 6, 2012

Updated, thanks for feedback :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@nobu nobu and 1 other commented on an outdated diff Jul 6, 2012
@@ -497,7 +497,10 @@ struct loaded_feature_searching {
{
VALUE base = rb_current_realfilepath();
if (NIL_P(base)) {
- rb_loaderror("cannot infer basepath");
+ VALUE path = FilePathValue(fname);
@nobu
Ruby Programming Language member
nobu added a note Jul 6, 2012

sorry to be unclear, ditto for FilePathValue(), and, of course, succeeding if statement.

@LTe
LTe added a note Jul 6, 2012

@nobu so we don't need FilePathValue(fname) to?

if(!NIL_P(fname))
  return rb_require_safe(fname, rb_safe_level());

This is ok?

@nobu
Ruby Programming Language member
nobu added a note Jul 6, 2012

yes, but fname.

@LTe
LTe added a note Jul 6, 2012

Sure, updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@zzak
Ruby Programming Language member
zzak commented Nov 19, 2012

I'm closing this, please refer to Bug #7391 in redmine

@shyouhei Could you please review the ticket in redmine?

Thank you!

@zzak zzak closed this Nov 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.