[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #57403] pkg.m loads packages before their depe
From: |
Philip Nienhuis |
Subject: |
[Octave-bug-tracker] [bug #57403] pkg.m loads packages before their dependencies |
Date: |
Fri, 13 Dec 2019 06:05:17 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0 |
URL:
<https://savannah.gnu.org/bugs/?57403>
Summary: pkg.m loads packages before their dependencies
Project: GNU Octave
Submitted by: philipnienhuis
Submitted on: Fri 13 Dec 2019 12:05:15 PM CET
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: Philip Nienhuis
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 5.1.0
Operating System: Any
_______________________________________________________
Details:
With reference to this thread,
https://octave.1599824.n4.nabble.com/pkg-m-Load-order-of-dependencies-tt4694833.html
I looked a little in the behavior of addpath() (called during loading of OF
packages).
Like its Matlab sibling, when addpath() is given a list of directories to add
to the path, it processes that list in reverse order. So 'addpath ("a", "b")'
results in a path where directory "a" is searched before directory "b". This
behavior, while Matlab-compatible, isn't documented AFAICS (TMW doesn't
document it either).
Now, pkg.m's private function load_packages_and_dependencies.m calls addpath
like this (L.48) :
addpath (dirs{:})
where "dirs" is a cell array of packages and its dependencies that is
carefully sorted in reverse order, apparently with the intention to load
dependencies before the package depending on them is loaded.
However, because of addpath's behavior, the resulting behavior of pkg.m is
that packages are added to the path before their dependencies have been
loaded. The consequences are that a package cannot rely on its dependencies
during its initialization and cannot shadow functions in its dependencies.
E.g., in the case mentioned in the thread, where matgeom is a dependency of
geometry, dirs is:
dirs =
{
[1,1] =
C:\Programs\Octave\Octave-6.0.0_20191126D\mingw64\share\octave\packages\matgeom-1.2.2
[1,2] =
C:\Programs\Octave\Octave-6.0.0_20191126D\mingw64\share\octave\packages\geometry-4.0.0
[1,3] =
C:\Programs\Octave\Octave-6.0.0_20191126D\mingw64\lib\octave\packages\geometry-4.0.0\x86
_64-w64-mingw32-api-v53+
}
What should be done here is first load matgeom, and once that is loaded and
initialized, load geometry. But because addpath() loads in reverse order,
these packages are also loaded in reverse (wrong) order.
Similar holds for e.g., signal and control.
To fix this I propose to simply replace 'addpath (dirs{:}))' by 'addpath
(fliplr (dirs{:}))'.
I'll upload a patch for pkg.m once I have a bug number.
If confirmed this is a very very old bug that remained concealed because
apparently (1) no OF package needs its dependencies to initialize itself and
(2) all OF packages only need dependencies for supplying functionality at run
time. So I think it would be safe and advisable to apply the fix to stable as
well then.
Also I'll upload a patch for addpath (or rather, load-path.cc) to document the
behavior of addpath() when given a list of directories.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?57403>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #57403] pkg.m loads packages before their dependencies,
Philip Nienhuis <=
- [Octave-bug-tracker] [bug #57403] pkg.m loads packages before their dependencies, Philip Nienhuis, 2019/12/13
- [Octave-bug-tracker] [bug #57403] pkg.m loads packages before their dependencies, Markus Mützel, 2019/12/13
- [Octave-bug-tracker] [bug #57403] pkg.m loads packages before their dependencies, Philip Nienhuis, 2019/12/13
- [Octave-bug-tracker] [bug #57403] pkg.m loads packages before their dependencies, Markus Mützel, 2019/12/14
- [Octave-bug-tracker] [bug #57403] pkg.m loads packages before their dependencies, Philip Nienhuis, 2019/12/14
- [Octave-bug-tracker] [bug #57403] pkg.m loads packages before their dependencies, Markus Mützel, 2019/12/14
- [Octave-bug-tracker] [bug #57403] pkg.m loads packages before their dependencies, Philip Nienhuis, 2019/12/14
- [Octave-bug-tracker] [bug #57403] pkg.m loads packages before their dependencies, Markus Mützel, 2019/12/14
- [Octave-bug-tracker] [bug #57403] pkg.m loads packages before their dependencies, Philip Nienhuis, 2019/12/14
- [Octave-bug-tracker] [bug #57403] pkg.m loads packages before their dependencies, Philip Nienhuis, 2019/12/14