bugGNU Octave - Bugs: bug #52598, addpath adds a relative path when...

 
 

bug #52598: addpath adds a relative path when given a relative path

Submitter:  Motius <motius>
Submitted:  Wed 06 Dec 2017 12:51:42 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  In Progress Assigned to:  None
Originator Name:  Motius Open/Closed:  * Open
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 10 Jan 2018 04:36:12 PM UTC, comment #11: 

@jwe: Yes, adding "+directory" to the patch is more equivalent to import.  I suppose this bug report will have to be fixed independently of bug #52585.

Rik <rik5>
Group administrator
Wed 10 Jan 2018 01:17:53 PM UTC, comment #10: 

Wouldn't it cause trouble to add +namespace directories to the path?  Those functions should only be visible if used as namespace.function or if there is an import statement present.  Adding the +namespace directory to the path would make all the functions visible without "namespace." prefix.

John W. Eaton <jwe>
Group administrator
Thu 07 Dec 2017 07:02:51 PM UTC, comment #9: 

As long as work is being done on the the loadpath in Octave, also see bug #52585.  In that case, functions in +namespace directories are note being recognized.  One of the easiest solutions would be to add the +namespace directories to Octave's internal loadpath, but not to display these directories when path() is called since they are for Octave's internal benefit.

Rik <rik5>
Group administrator
Wed 06 Dec 2017 09:26:07 PM UTC, comment #8: 

I just pulled the reverted changeset and that does not change the path:


sebald@ ~/octave/bug_52599 $ /usr/local/src/octave/octave/build1/run-octave --no-gui
[snip]
octave:1> p1 = path;
octave:2> path(path);
octave:3> p2 = path;
octave:4> strsplit(p2,p1)
ans =
{
  [1,1] =
  [1,2] =
}


Dan Sebald <sebald>
Wed 06 Dec 2017 09:03:21 PM UTC, comment #7: 

That raises an interesting question as to whether path() should show something different than what it interprets.  That is, what happens with path(path)?  Should the path change?  Currently Octave adds the '.' as an expanded string:


sebald@ ~/octave/bug_52599 $ /usr/local/src/octave/octave/build1/run-octave --no-gui
GNU Octave, version 4.3.0+
[snip]
For information about changes from previous versions, type 'news'.

octave:1> p1 = path;
octave:2> path(path);
octave:3> p2 = path;
octave:4> strsplit(p2,p1)
ans =
{
  [1,1] = /home/sebald/matlab/bug_52599:
  [1,2] =
}


Dan Sebald <sebald>
Wed 06 Dec 2017 07:36:39 PM UTC, comment #6: 

Yes, "." is always first in Matlab's path but not displayed.  I thought it best to display that info, but internally maybe it should be handled differently.

John W. Eaton <jwe>
Group administrator
Wed 06 Dec 2017 07:11:22 PM UTC, comment #5: 


> We probably want to avoid turning "." into an absolute name, especially if we are going to display it in the output of "path".


For what is worth, matlab's path function does not return '.' in the path. I am guessing it's simply always implicit.

Carnë Draug <carandraug>
Group Member
Wed 06 Dec 2017 07:02:55 PM UTC, comment #4: 

I backed out the load-path changeset.  The fix is not as simple as I initially thought.  We probably want to avoid turning "." into an absolute name, especially if we are going to display it in the output of "path".

One simple fix would be to leave the load_path class alone and just fix addpath, rmpath, path (and others?) to expand the path, but I'd rather fix it in one place, inside the load_path class so that relative directory names can't appear in the load_path.

For the other problems, are you building with the JIT compiler enabled?  I also see the the decic problem unless I disable it.  I think it started happening after my most recent change to the symbol_scope object but I haven't investigated further.

John W. Eaton <jwe>
Group administrator
Wed 06 Dec 2017 06:29:08 PM UTC, comment #3: 

After commenting out the functional tests is decic.m I get a little farther, but the test suite aborts when it enters the fixed tests.


Fixed test scripts:

  bug-35448.tst ...............................................element number 3 undefined in return list



Rik <rik5>
Group administrator
Wed 06 Dec 2017 06:11:14 PM UTC, comment #2: 

Patch works, but I'm having problems running the 'make check'.

There is 1 test failure in run.m that seems related to this change.

The other problem is the test suite is hanging in scripts/ode/decic.m.  That probably isn't related to this change but I can't complete 'make check' to see if there are any other errors.

Rik <rik5>
Group administrator
Wed 06 Dec 2017 04:47:28 PM UTC, comment #1: 
John W. Eaton <jwe>
Group administrator
Wed 06 Dec 2017 12:51:42 PM UTC, original submission:  

SUMMARY


Octave treats relative paths added with addpath as relative to the current directory. This used to be MatLab's behavior until it was changed around 2016, see:

https://www.mathworks.com/help/matlab/release-notes.html?rntext=&startrelease=R2016b&endrelease=R2016b&category=Language+and+Programming&groupby=release&sortby=descending&searchHighlight=

EXAMPLE


The scripts below illustrate the changing behavior between MatLab versions:

$ mkdir -p x/foo y/foo
$ printf "function bar\ndisp('x')\n" > x/foo/bar.m
$ printf "function bar\ndisp('y')\n" > y/foo/bar.m
$ /usr/local/MATLAB/R2010b/bin/matlab -nodisplay -nosplash

                                                                                              < M A T L A B (R) >
                                                                                    Copyright 1984-2010 The MathWorks, Inc.
                                                                                 Version 7.11.0.584 (R2010b) 64-bit (glnxa64)
                                                                                                August 16, 2010


  To get started, type one of these: helpwin, helpdesk, or demo.
  For product information, visit www.mathworks.com.

>> cd x
>> addpath('foo')
>> bar
x
>> cd ../y
>> bar
y
>> exit

$ /usr/local/MATLAB/R2017b/bin/matlab -nodisplay -nosplash

                                                                                              < M A T L A B (R) >
                                                                                    Copyright 1984-2017 The MathWorks, Inc.
                                                                                    R2017b (9.3.0.713579) 64-bit (glnxa64)
                                                                                              September 14, 2017


To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.

>> cd x
>> addpath('foo')
>> bar
x
>> cd ../y
>> bar
x


thanks to carandraug for the paste and the MatLab link

OCTAVE


Octave has the same behavior as earlier versions of MatLab.

Motius <motius>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by sebald (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by motius (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-03-16 mtmiller Dependencies- bugs #57983 is dependent
    2017-12-06 jwe StatusReady For Test In Progress
    2017-12-06 jwe StatusNone Ready For Test
        Release4.2.1 dev

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code