help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inadequate/inconsisten 'help pkg' message; problems with downloading


From: Sergei Steshenko
Subject: Re: inadequate/inconsisten 'help pkg' message; problems with downloading
Date: Sun, 7 Aug 2011 04:36:50 -0700 (PDT)

--- On Tue, 8/2/11, Sergei Steshenko <address@hidden> wrote:

> From: Sergei Steshenko <address@hidden>
> Subject: Re: inadequate/inconsisten 'help pkg' message; problems with 
> downloading
> To: address@hidden
> Date: Tuesday, August 2, 2011, 5:35 AM
> It looks like package removing does
> not work.
> 
> 
> This is what I read in 'help pkg':
> 
> "
>     `uninstall'
>           Uninstall named
> packages.  For example,
> 
>            
>    pkg uninstall image
> 
>           removes the `image'
> package from the system.  If another
>           installed package
> depends on the `image' package an error
>           will be issued. 
> The package can be uninstalled anyway by
>           using the `-nodeps'
> option.
> 
> ".
> 
> This is what I observe in reality:
> 
> "
> octave:3> pkg uninstall -nodeps -verbose java
> warning: some of the packages you want to uninstall are not
> installed
> octave:4> quit
> 
> error: feval: function `java_exit' not found
> address@hidden:~/whatever/junk/dir> (export GNUTERM=wxt;
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/binsh/octave)
> GNU Octave, version 3.4.2
> Copyright (C) 2011 John W. Eaton and others.
> This is free software; see the source code for copying
> conditions.
> There is ABSOLUTELY NO WARRANTY; not even for
> MERCHANTABILITY or
> FITNESS FOR A PARTICULAR PURPOSE.  For details, type
> `warranty'.
> 
> Octave was configured for "i686-pc-linux-gnu".
> 
> Additional information about Octave is available at http://www.octave.org.
> 
> Please contribute if you find this software useful.
> For more information, visit http://www.octave.org/help-wanted.html
> 
> Read http://www.octave.org/bugs.html to learn
> how to submit bug reports.
> 
> For information about changes from previous versions, type
> `news'.
> 
> warning: function
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/share/octave/packages/statistics-1.0.10/fstat.m
> shadows a core library function
> warning: function
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/share/octave/packages/statistics-1.0.10/prctile.m
> shadows a core library function
> warning: dispatch is obsolete and will be removed from a
> future version of Octave; please use classes instead
> warning:
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/share/octave/packages/integration-1.0.7/PKG_ADD:
> possible Matlab-style short-circuit operator at line 9,
> column 32
> warning: function
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/lib/octave/packages/linear-algebra-2.0.0/i686-pc-linux-gnu-api-v45+/mgorth.oct
> shadows a core library function
> warning: function
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/share/octave/packages/multicore-0.2.15/gethostname.m
> shadows a built-in function
> warning: addpath:
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/lib/octave/packages/ocs-0.1.1/i686-pc-linux-gnu-api-v45+/../utl:
> No such file or directory
> warning: addpath:
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/lib/octave/packages/ocs-0.1.1/i686-pc-linux-gnu-api-v45+/../asm:
> No such file or directory
> warning: addpath:
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/lib/octave/packages/ocs-0.1.1/i686-pc-linux-gnu-api-v45+/../tst:
> No such file or directory
> warning: addpath:
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/lib/octave/packages/ocs-0.1.1/i686-pc-linux-gnu-api-v45+/../nls:
> No such file or directory
> warning: addpath:
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/lib/octave/packages/ocs-0.1.1/i686-pc-linux-gnu-api-v45+/../prs:
> No such file or directory
> warning: addpath:
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/lib/octave/packages/ocs-0.1.1/i686-pc-linux-gnu-api-v45+/../sbn:
> No such file or directory
> warning: function
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/share/octave/packages/oct2mat-1.0.7/arg.m
> shadows a built-in function
> warning: function
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/share/octave/packages/oct2mat-1.0.7/fflush.m
> shadows a built-in function
> warning: function
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/share/octave/packages/oct2mat-1.0.7/file_in_loadpath.m
> shadows a built-in function
> warning: function
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/share/octave/packages/oct2mat-1.0.7/file_in_path.m
> shadows a built-in function
> warning: function
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/share/octave/packages/oct2mat-1.0.7/rindex.m
> shadows a core library function
> warning: function
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/share/octave/packages/oct2mat-1.0.7/substr.m
> shadows a core library function
> warning: function
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/share/octave/packages/oct2mat-1.0.7/toascii.m
> shadows a built-in function
> warning: function
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/share/octave/packages/oct2mat-1.0.7/tolower.m
> shadows a built-in function
> warning: function
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/share/octave/packages/oct2mat-1.0.7/toupper.m
> shadows a built-in function
> warning: function
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/share/octave/packages/plot-1.0.8/colstyle.m
> shadows a core library function
> warning: gmsh does not seem to be present some
> functionalities will be disabled
> warning: dx does not seem to be present some
> functionalities will be disabled
> warning: function
> /mnt/sdb8/sergei/AFSWD_debug/20110601/octave-3.4.2/share/octave/packages/strings-1.0.7/strtrim.m
> shadows a core library function
> octave:1> pkg describe java
> ---
> Package name:
>         java
> Version:
>         1.2.8
> Short description:
>         Provides Java interface with
> OO-like Java objects manipulation
> Status:
>         Loaded
> octave:2>  
> ".
> 
> Why do I see the
> 
> "
> warning: some of the packages you want to uninstall are not
> installed
> "
> 
> message ? According to my understanding of the excerpt from
> 'help pkg'
> the -nodeps option means unconditional removal of the
> package in
> question.
> 
> Why do I see after 'uninstall'
> 
> "
> Status:
>         Loaded
> " ?
> 
> Can a non-existent package be loaded ?
> 
> I have sufficient file system privileges to manipulate
> files - my user ID
> is the files owner user ID.
> 
> Thanks,
>   Sergei.


I have concluded investigation of package removal issues.

First of all, regarding the

"
warning: some of the packages you want to uninstall are not installed
"

message.

Uninstall is performed by 'uninstall' function which is described on
lines ##914 .. 1036 of 'octave-3.4.2/share/octave/3.4.2/m/pkg/pkg.m' file.

One can see in the file:

    948       if (length (delete_idx) != length (pkgnames))
    949         ## FIXME: We should have a better error message.
    950         warning ("some of the packages you want to uninstall are not 
installed");
    951       endif
    952     else
    953       ## FIXME: We should have a better error message.
    954       warning ("some of the packages you want to uninstall are not 
installed");
    955     endif
    956   endif
.

I.e. the non-informative message I see is a self-confirmed bug - because
of the "FIXME: ...".

Now regarding the problem proper - in the described above case the
package is indeed _not_ uninstalled. In order to understand why one has
to read an excerpt from 'help pkg' screen output - see below between
'Excerpt from 'help pkg' BEGIN', 'Excerpt from 'help pkg' BEGIN'.

Attention should be paid the fact that on lines ##52 .. 60 (those lines
describe 'uninstall') '-global' is _not_ mentioned. The importance of
'-global' will be soon shown.

The top level function is, of course, 'pkg'; it is described on
lines ##243 .. 498 of 'octave-3.4.2/share/octave/3.4.2/m/pkg/pkg.m' file.

One can see 'pkg' function source below between "'pkg' source BEGIN",
"'pkg' source END" markers.

In 'pkg' function one can see lines related to setting 'global_install'
flag:

    253   global_install = issuperuser ();
...
    293       case "-local"
    294         global_install = false;
    295         if (! user_prefix)
    296           prefix = tilde_expand (fullfile ("~", "octave"));
    297           archprefix = prefix;
    298         endif
    299       case "-global"
    300         global_install = true;
    301         if (! user_prefix)
    302           prefix = fullfile (OCTAVE_HOME (), "share", "octave", 
"packages");
    303           archprefix = fullfile (octave_config_info ("libdir"),
    304                                  "octave", "packages");
    305         endif
.

Though I installed packages globally, I was not a superuser. So, the

    253   global_install = issuperuser ();

sets 'global_install' flag to _false_.

In 'uninstall' function one can see:

    914 function uninstall (pkgnames, handle_deps, verbose, local_list,
    915                     global_list, global_install)
    916   ## Get the list of installed packages.
    917   [local_packages, global_packages] = installed_packages(local_list,
    918                                                          global_list);
    919   if (global_install)
    920     installed_pkgs_lst = {local_packages{:}, global_packages{:}};
    921   else
    922     installed_pkgs_lst = local_packages;
    923   endif
,

i.e. if global_install is false (which it was in my case),

    922     installed_pkgs_lst = local_packages;

line is executed. Because _no_ packages were installed locally, there
was no actual uninstallation, and the non-informative message was produced
as a consequence.

In order to actually remove packages in my case of non-superuser global
install I need to specify '-global' to 'pkg', e.g.:

pkg uninstall -nodeps -verbose -global ocs

, but, as pointed out above, 'help pkg' does _not_ mention '-global' WRT
'uninstall' command, so the only way for me to realize the necessity
of '-global' was through looking into the code and tracing its execution.

In order to avoid the non-informative message which sparked this whole
investigation I modified the following piece of 'uninstall' function:

    924
    925   num_packages = length (installed_pkgs_lst);
    926   delete_idx = [];
    927   for i = 1:num_packages
    928     cur_name = installed_pkgs_lst{i}.name;
    929     if (any (strcmp (cur_name, pkgnames)))
    930       delete_idx(end+1) = i;
    931     endif
    932   endfor

- now the piece looks this way:

"
  num_packages = length (installed_pkgs_lst);  # fprintf(stderr, "uninstall: 
num_packages=%u\n", num_packages);
  if(num_packages == 0)
    warning("uninstall: number of installed packages appears to be 0, so no 
package can be uninstalled");
    warning("uninstall: if in reality there are installed packages, make sure 
you have correctly specified '-global' or '-local' to 'pkg'");
    return;
  endif

  delete_idx = [];
  for i = 1:num_packages
    cur_name = installed_pkgs_lst{i}.name; fprintf(stderr, "uninstall: 1 
cur_name=%s\n", cur_name);
    if (any (strcmp (cur_name, pkgnames)))
      delete_idx(end+1) = i;
    endif
  endfor
".

With the modification I'm now getting this:

"
octave:15> pkg uninstall -nodeps -verbose ocs
warning: uninstall: number of installed packages appears to be 0, so no package 
can be uninstalled
warning: uninstall: if in reality there are installed packages, make sure you 
have correctly specified '-global' or '-local' to 'pkg'
octave:16>   
"

- I hope this is more user-friendly.

The code producing the original non-informative messages is still there
- in my case the code is simply not reached because of the 'return'
statement.

As I wrote in my earlier Emails, I'm going to release the whole 'pkg.m'
including the above change.

I will also try to improve 'uninstall' description - regarding the
'-global' flag.

Regards,
  Sergei.


Excerpt from 'help pkg' BEGIN

      1 `pkg' is a command-line function
      2
      3  -- Command:  pkg COMMAND PKG_NAME
      4  -- Command:  pkg COMMAND OPTION PKG_NAME
      5      This command interacts with the package manager.  Different
      6      actions will be taken depending on the value of COMMAND.
      7
      8     `install'
      9           Install named packages.  For example,
     10
     11                pkg install image-1.0.0.tar.gz
     12
     13           installs the package found in the file `image-1.0.0.tar.gz'.
     14
     15           The OPTION variable can contain options that affect the manner
     16           in which a package is installed.  These options can be one or
     17           more of
     18
     19          `-nodeps'
     20                The package manager will disable the dependency
     21                checking.  That way it is possible to install a package
     22                even if it depends on another package that's not
     23                installed on the system.  *Use this option with care.*
     24
     25          `-noauto'
     26                The package manager will not automatically load the
     27                installed package when starting Octave, even if the
     28                package requests that it is.
     29
     30          `-auto'
     31                The package manager will automatically load the
     32                installed package when starting Octave, even if the
     33                package requests that it isn't.
     34
     35          `-local'
     36                A local installation is forced, even if the user has
     37                system privileges.
     38
     39          `-global'
     40                A global installation is forced, even if the user
     41                doesn't normally have system privileges
     42
     43          `-forge'
     44                Install a package directly from the Octave-Forge
     45                repository.  This requires an internet connection and
     46                the cURL library.
     47
     48          `-verbose'
     49                The package manager will print the output of all of the
     50                commands that are performed.
     51
     52     `uninstall'
     53           Uninstall named packages.  For example,
     54
     55                pkg uninstall image
     56
     57           removes the `image' package from the system.  If another
     58           installed package depends on the `image' package an error
     59           will be issued.  The package can be uninstalled anyway by
     60           using the `-nodeps' option.
     61
     62     `load'

Excerpt from 'help pkg' END

'pkg' source BEGIN

    243 function [local_packages, global_packages] = pkg (varargin)
    244   ## Installation prefix (FIXME: what should these be on windows?)
    245   persistent user_prefix = false;
    246   persistent prefix = -1;
    247   persistent archprefix = -1;
    248   persistent local_list = tilde_expand (fullfile ("~", 
".octave_packages"));
    249   persistent global_list = fullfile (OCTAVE_HOME (), "share", "octave",
    250                                      "octave_packages");
    251   mlock ();
    252
    253   global_install = issuperuser ();
    254
    255   if (prefix == -1)
    256     if (global_install)
    257       prefix = fullfile (OCTAVE_HOME (), "share", "octave", "packages");
    258       archprefix = fullfile (octave_config_info ("libdir"),
    259                              "octave", "packages");
    260     else
    261       prefix = fullfile ("~", "octave");
    262       archprefix = prefix;
    263     endif
    264     prefix = tilde_expand (prefix);
    265     archprefix = tilde_expand (archprefix);
    266   endif
    267
    268   available_actions = {"list", "install", "uninstall", "load", ...
    269                        "unload", "prefix", "local_list", ...
    270                        "global_list", "rebuild", "build","describe"};
    271   ## Handle input
    272   if (length (varargin) == 0 || ! iscellstr (varargin))
    273     print_usage ();
    274   endif
    275   files = {};
    276   deps = true;
    277   auto = 0;
    278   action = "none";
    279   verbose = false;
    280   octave_forge = false;
    281   for i = 1:length (varargin)
    282     switch (varargin{i})
    283       case "-nodeps"
    284         deps = false;
    285       case "-noauto"
    286         auto = -1;
    287       case "-auto"
    288         auto = 1;
    289       case "-verbose"
    290         verbose = true;
    291       case "-forge"
    292         octave_forge = true;
    293       case "-local"
    294         global_install = false;
    295         if (! user_prefix)
    296           prefix = tilde_expand (fullfile ("~", "octave"));
    297           archprefix = prefix;
    298         endif
    299       case "-global"
    300         global_install = true;
    301         if (! user_prefix)
    302           prefix = fullfile (OCTAVE_HOME (), "share", "octave", 
"packages");
    303           archprefix = fullfile (octave_config_info ("libdir"),
    304                                  "octave", "packages");
    305         endif
    306       case available_actions
    307         if (strcmp (action, "none"))
    308           action = varargin{i};
    309         else
    310           error ("more than one action specified");
    311         endif
    312       otherwise
    313         files{end+1} = varargin{i};
    314     endswitch
    315   endfor
    316
    317   if (octave_forge && ! any (strcmp (action, {"install", "list"})))
    318     error ("-forge can only be used with install or list");
    319   endif
    320
    321   ## Take action
    322   switch (action)
    323     case "list"
    324       if (octave_forge)
    325         if (nargout > 0)
    326           local_packages = list_forge_packages ();
    327         else
    328           list_forge_packages ();
    329         endif
    330       else
    331         if (nargout == 0)
    332           installed_packages (local_list, global_list);
    333         elseif (nargout == 1)
    334           local_packages = installed_packages (local_list, global_list);
    335         elseif (nargout == 2)
    336           [local_packages, global_packages] = installed_packages 
(local_list,
    337                                                                   
global_list);
    338         else
    339           error ("too many output arguments requested");
    340         endif
    341       endif
    342
    343     case "install"
    344       if (length (files) == 0)
    345         error ("you must specify at least one filename when calling 
'pkg install'");
    346       endif
    347
    348       local_files = {};
    349       unwind_protect
    350
    351         if (octave_forge)
    352           [urls, local_files] = cellfun (@get_forge_download, files, 
"uniformoutput", false);
    353           [files, succ] = cellfun (@urlwrite, urls, local_files, 
"uniformoutput", false);
    354           succ = [succ{:}];
    355           if (! all (succ))
    356             i = find (! succ, 1);
    357             error ("could not download file %s from url %s", 
local_files{i}, urls{i});
    358           endif
    359         endif
    360
    361         install (files, deps, auto, prefix, archprefix, verbose, 
local_list,
    362                  global_list, global_install);
    363
    364       unwind_protect_cleanup
    365         cellfun (@unlink, local_files);
    366       end_unwind_protect
    367
    368     case "uninstall"
    369       if (length (files) == 0)
    370         error ("you must specify at least one package when calling 'pkg 
uninstall'");
    371       endif
    372       uninstall (files, deps, verbose, local_list,
    373                  global_list, global_install);
    374
    375     case "load"
    376       if (length (files) == 0)
    377         error ("you must specify at least one package, 'all' or 'auto' 
when calling 'pkg load'");
    378       endif
    379       load_packages (files, deps, local_list, global_list);
    380
    381     case "unload"
    382       if (length (files) == 0)
    383         error ("you must specify at least one package or 'all' when 
calling 'pkg unload'");
    384       endif
    385       unload_packages (files, deps, local_list, global_list);
    386
    387     case "prefix"
    388       if (length (files) == 0 && nargout == 0)
    389         printf ("Installation prefix:             %s\n", prefix);
    390         printf ("Architecture dependent prefix:   %s\n", archprefix);
    391       elseif (length (files) == 0 && nargout >= 1)
    392         local_packages = prefix;
    393         global_packages = archprefix;
    394       elseif (length (files) >= 1 && nargout <= 2 && ischar (files{1}))
    395         prefix = files{1};
    396         prefix = absolute_pathname (prefix);
    397         local_packages = prefix;
    398         user_prefix = true;
    399         if (length (files) >= 2 && ischar (files{2}))
    400           archprefix = files{2};
    401           try
    402             archprefix = absolute_pathname (archprefix);
    403           catch
    404             mkdir (archprefix);
    405             warning ("creating the directory %s\n", archprefix);
    406             archprefix = absolute_pathname (archprefix);
    407           end_try_catch
    408           global_packages = archprefix;
    409         endif
    410       else
    411         error ("you must specify a prefix directory, or request an 
output argument");
    412       endif
    413
    414     case "local_list"
    415       if (length (files) == 0 && nargout == 0)
    416         disp (local_list);
    417       elseif (length (files) == 0 && nargout == 1)
    418         local_packages = local_list;
    419       elseif (length (files) == 1 && nargout == 0 && ischar (files{1}))
    420         try
    421           local_list = absolute_pathname (files{1});
    422         catch
    423           ## Force file to be created
    424           fclose (fopen (files{1}, "wt"));
    425           local_list = absolute_pathname (files{1});
    426         end_try_catch
    427       else
    428         error ("you must specify a local_list file, or request an 
output argument");
    429       endif
    430
    431     case "global_list"
    432       if (length (files) == 0 && nargout == 0)
    433         disp(global_list);
    434       elseif (length (files) == 0 && nargout == 1)
    435         local_packages = global_list;
    436       elseif (length (files) == 1 && nargout == 0 && ischar (files{1}))
    437         try
    438           global_list = absolute_pathname (files{1});
    439         catch
    440           ## Force file to be created
    441           fclose (fopen (files{1}, "wt"));
    442           global_list = absolute_pathname (files{1});
    443         end_try_catch
    444       else
    445         error ("you must specify a global_list file, or request an 
output argument");
    446       endif
    447
    448     case "rebuild"
    449       if (global_install)
    450         global_packages = rebuild (prefix, archprefix, global_list, 
files,
    451                                    auto, verbose);
    452         global_packages = save_order (global_packages);
    453         save (global_list, "global_packages");
    454         if (nargout > 0)
    455           local_packages = global_packages;
    456         endif
    457       else
    458         local_packages = rebuild (prefix, archprefix, local_list, 
files, auto,
    459                                   verbose);
    460         local_packages = save_order (local_packages);
    461         save (local_list, "local_packages");
    462         if (nargout == 0)
    463           clear ("local_packages");
    464         endif
    465       endif
    466
    467     case "build"
    468       if (length (files) < 2)
    469         error ("you must specify at least the build directory and one 
filename\nwhen calling 'pkg build'");
    470       endif
    471       build (files, deps, auto, verbose);
    472
    473     case "describe"
    474       if (length (files) == 0)
    475         error ("you must specify at least one package or 'all' when 
calling 'pkg describe'");
    476       endif
    477       ## FIXME: the name of the output variables is inconsistent
    478       ##            with their content
    479       switch (nargout)
    480         case 0
    481           describe (files, verbose, local_list, global_list);
    482         case 1
    483           pkg_desc_list = describe (files, verbose, local_list, ...
    484                                     global_list);
    485           local_packages = pkg_desc_list;
    486         case 2
    487           [pkg_desc_list, flag] = describe (files, verbose, local_list, 
...
    488                                             global_list);
    489           local_packages  = pkg_desc_list;
    490           global_packages = flag;
    491         otherwise
    492           error ("you can request at most two outputs when calling 'pkg 
describe'");
    493       endswitch
    494
    495     otherwise
    496       error ("you must specify a valid action for 'pkg'. See 'help pkg' 
for details");
    497   endswitch
    498 endfunction

'pkg' source END






reply via email to

[Prev in Thread] Current Thread [Next in Thread]