bugGNU Octave - Bugs: bug #44548, pkg install defaults to global in...


bug #44548: pkg install defaults to global in Microsoft Windows

Submitter:  Oliver Heimlich <oheim>
Submitted:  Mon 16 Mar 2015 06:36:45 AM UTC
Category:  Octave Function Severity:  1 - Wish
Priority:  5 - Normal Item Group:  Feature Request
Status:  Fixed Assigned to:  None
Originator Name:  Oliver Heimlich Open/Closed:  * Closed
Release:  * dev Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Jump to the original submission

Sun 15 Mar 2020 04:42:48 PM UTC, comment #16: 

No reports about problems on Windows or other platforms related to this change so far.
Closing as fixed.

Markus Mützel <mmuetzel>
Group administrator
Sat 22 Feb 2020 05:40:15 PM UTC, comment #15: 

I pushed a change here that makes "pkg install" default to "-global" if Octave is running with elevated privileges on Windows and to "-local" otherwise:

I think this is the closest we can get to the behavior on Linux.
With that change, I see the following:

>> pkg install -forge geometry
clipper.cpp: In function 'void ClipperLib::InitEdge(ClipperLib::TEdge*, ClipperLib::TEdge*, ClipperLib::TEdge*, const ClipperLib::IntPoint&)':
clipper.cpp:750:34: warning: 'void* memset(void*, int, size_t)' clearing an object of non-trivial type 'struct ClipperLib::TEdge'; use assignment or
 value-initialization instead [-Wclass-memaccess]
  750 |   std::memset(e, 0, sizeof(TEdge));
      |                                  ^
clipper.cpp:95:8: note: 'struct ClipperLib::TEdge' declared here
   95 | struct TEdge {
      |        ^~~~~
warning: doc_cache_create: unusable help text found in file 'clipper'
warning: called from
    doc_cache_create>handle_function at line 98 column 5
    doc_cache_create>create_cache at line 118 column 36
    gen_doc_cache_in_dir>@<anonymous> at line 150 column 18
    doc_cache_create>gen_doc_cache_in_dir at line 151 column 9
    doc_cache_create at line 62 column 12
    install>generate_lookfor_cache at line 820 column 5
    install at line 235 column 7
    pkg at line 517 column 9

For information about changes from previous versions of the geometry package, run 'news geometry'.

After this, the "geometry" package is installed in %USERPROFILE%\octave\geometry-4.0.0.

Previously, the installation failed due to missing write permissions for the global packages store.

Marking as ready for test.

Markus Mützel <mmuetzel>
Group administrator
Sat 22 Feb 2020 02:36:21 PM UTC, comment #14: 

With regards to comment #8: As of early 2020, we are still targeting Windows XP. (Although I believe that the Octave bundle we provide via MXE Octave won't run on XP since some dependencies dropped support.)
PowerShell was added in Windows 7 / Windows Server 2008 R2.
But maybe it is about time we officially dropped support for good ol' Windows XP.

Markus Mützel <mmuetzel>
Group administrator
Thu 17 Jan 2019 09:07:52 AM UTC, comment #13: 

Thanks for the pointer; I hadn't found that in my search before posting here. Heading over there...

Andrew Janke <apjanke>
Thu 17 Jan 2019 08:50:00 AM UTC, comment #12: 

(Release => dev)

Philip Nienhuis <philipnienhuis>
Group Member
Thu 17 Jan 2019 08:49:11 AM UTC, comment #11: 

Andrew, for your comment #10 remarks there's already a fairly old bug report (bug #40444).

Philip Nienhuis <philipnienhuis>
Group Member
Thu 17 Jan 2019 06:33:06 AM UTC, comment #10: 

For that matter, it looks like on Windows, Octave is storing its configuration and user state data under the root directory of the user profile (%USERPROFILE%) at ~/.config/octave and ~/.octave_hist. I think it would be more appropriate to store these in the user's roaming profile appdata (AppData/Roaming, accessible via %APPDATA%).

Andrew Janke <apjanke>
Wed 16 Jan 2019 07:30:48 PM UTC, comment #9: 

I'd like to suggest calling out to PowerShell to check the permissions, instead of probing with a file write: https://stackoverflow.com/questions/34859477/check-if-user-has-read-write-permissions. PowerShell is available in all recent versions of Windows.

I'd also like to suggest that the correct default location for local (user) installations of Octave pkg packages is under the user LocalAppData shell folder, which you can locate with `getenv('LOCALAPPDATA')`. That's the Windows equivalent of `$XDG_DATA_HOME` (~/.local/share).

Andrew Janke <apjanke>
Fri 23 Dec 2016 09:58:19 PM UTC, comment #8: 

This issue is probably still present in Octave 4.2.0.

There has been a PATCH proposed in comment #6.

Hartmut <hardy>
Tue 02 Jun 2015 04:33:45 PM UTC, comment #7: 

Retagging release from 4.0.0-rc1 to 4.0.0.

John W. Eaton <jwe>
Group administrator
Tue 17 Mar 2015 01:00:48 PM UTC, comment #6: 

Please consider the revised patch, which also works with a fresh installation of GNU Octave that has not created package directories yet.

(file #33376)

Oliver Heimlich <oheim>
Tue 17 Mar 2015 08:13:29 AM UTC, comment #5: 

I have developed and tested the attached patch (I created a new private dirwritable as a replacement for your iswritable). On Microsoft Windows it checks for required permissions and defaults to “-global” iff that is possible. Effectively you get the following behaviour (unless you completely mess with your file system permissions of course).

Run as administrator: Defaults to -global
GNU Octave was installed in the user's folder (or any other writable place): Defaults to -global
GNU Octave was installed in %ProgramFiles%: Defaults to -local

During testing I stumbled upon bug #43557 a lot, but that is a different topic.

(file #33374)

Oliver Heimlich <oheim>
Mon 16 Mar 2015 09:54:20 PM UTC, comment #4: 

I haven't used or have access to windows in ages. Would be nice if you could provide a patch that does and test it. For now, it might be better to go for the simpler option. If the logic changes too much, then it might not be a good candidate for 4.0.

Carnë Draug <carandraug>
Group Member
Mon 16 Mar 2015 07:22:23 PM UTC, comment #3: 

Checking “properly” for permissions is a hard thing to do, because you would have to implement the required system calls and consider different file systems and possibly network shares. The creation of a temporary file is a reliable method for testing permissions.

If the user does not provide -global or -local, the default should depend on the file permissions (in Microsoft Windows only!).

Then, the user may install GNU Octave into a public location (e. g. %ProgramFiles%), where pkg install would default to -local (unless run as administrator). And when installed in a writable place (e. g. %USERPROFILE%) it would default to -global and packages would be installed into the program folder.

Another solution would be to use -local as default in Microsoft Windows, because this would be simple and work in either case.

Oliver Heimlich <oheim>
Mon 16 Mar 2015 04:27:43 PM UTC, comment #2: 

Defaulting to global on windows seems to be design


although it may be so because of not knowing how to check properly for permissions on that system.

I had a a fix for this some years ago which involved checking permissions by actually trying to create an empty file. I committed it to a development work for pkg https://bitbucket.org/carandraug/octave/commits/a240810c24d1 but I can't graft it now since it has a lot of other changes that are not really ready to be merged. The iswritable function used there seems to be missing as well :(

Carnë Draug <carandraug>
Group Member
Mon 16 Mar 2015 02:16:30 PM UTC, comment #1: 

Thanks for your bug report. Yes, the default is to do a global install on Windows, or on unixy systems if you are the superuser. There is a FIXME comment in pkg.m about whether this could be done in a different way on Windows. And as you saw, the "-local" option is always available to override the default.

Btw, I think there has been some discussion to eliminate the distinction between global and local package installation in the larger plans for the pkg command, but I can't remember exactly.

Mike Miller <mtmiller>
Group Member
Mon 16 Mar 2015 06:36:45 AM UTC, original submission:  

I have tested the 4.0.0-rc1 on Microsoft Windows 7 and ran into a problem installing packages (from Octave Forge). I have used “pkg install -forge packagename” and GNU Octave tried to install the package globally. However, the application has been run without administrator privileges and failed to write into the program folder. “pkg install -local” works perfectly.

I suggest to change the bevaiour of pkg as follows (in Microsoft Windows): If the application is run with administrator privileges (or better check for write permission on the program folder?!), pkg uses -global. Otherwise it uses -local.

This would be consistent with the behaviour on GNU/Linux, where GNU Octave installs packages globally with root privileges only.

Oliver Heimlich <oheim>


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

Attach Files:

Attached Files
file #33376:  bug-44548.diff added by oheim (4KiB - text/x-patch)
file #33374:  bug-44548.diff added by oheim (4KiB - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by apjanke (Posted a comment)
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by oheim (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 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-03-15 mmuetzel StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2020-02-22 mtmiller Carbon-CopyRemoved 80942 -
    2020-02-22 mmuetzel StatusConfirmed Ready For Test
    2019-01-17 philipnienhuis Release4.0.0 dev
    2015-06-02 jwe Release4.0.0-rc1 4.0.0
    2015-03-17 oheim Attached File- Added bug-44548.diff, #33376
    2015-03-17 oheim Attached File- Added bug-44548.diff, #33374
    2015-03-16 mtmiller StatusNone Confirmed
    2015-03-16 mtmiller Severity3 - Normal 1 - Wish
        Item GroupInstallation Failure Feature Request
        Summarypkg install fails in Microsoft Windows (file permission) pkg install defaults to global in Microsoft Windows

    Back to the top

    Powered by Savane 3.13-3cd0.
    Corresponding source code