bugGNU Octave - Bugs: bug #48221, prefdir should not be a private...


bug #48221: prefdir should not be a private function

Submitted by:  Guillaume <gyom>
Submitted on:  Tue 14 Jun 2016 09:22:16 AM UTC  
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Guillaume Open/Closed:  Closed
Release:  dev Operating System:  Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Wed 15 Jun 2016 04:07:48 PM UTC, comment #6:

I fixed this on the default branch with the following simpler change:


You can now call prefdir, and passing any argument to it will create the directory if it doesn't exist (tested with a bogus HOME variable).

This in no way guarantees that all preferences or settings related to Octave are actually stored in said directory, or that it can be safely removed to clean up all Octave preferences. That would be a separate, much larger undertaking.

Mike Miller <mtmiller>
Project Administrator
Wed 15 Jun 2016 09:37:54 AM UTC, comment #5:

Sorry, there was a typo - new version below:

Guillaume <gyom>
Wed 15 Jun 2016 09:25:13 AM UTC, comment #4:

Thanks for the feedbacks. It would be great to move prefdir.m from octave/scripts/prefs/private/ to octave/scripts/prefs/.

I still think it would also be an improvement to let the preference directory have its own folder (eg ~/.octave/ instead of ~/) in case, as Mike mentions, we end up storing more than a single file (Matlab seems to store many files there).

It is also possible that, on Windows, a file or folder starting with '.' is not allowed or recommended. I made a change to my proposed code - I'm just not sure what get_home_directory () returns on this platform.

Guillaume <gyom>
Tue 14 Jun 2016 04:29:20 PM UTC, comment #3:

Yes, I am completely ignoring what the preferences directory or file actually are, and just thinking about supporting the syntax to create the directory. Granted in most cases the user's home directory will already exist, so it's a no-op, but maybe not all cases.

And maybe some day we will have a configuration directory that combines all settings for Octave, including installed packages, startup commands, prefs, and what are currently GUI preferences (using QSettings). There are other open bug reports about these things though.

Mike Miller <mtmiller>
Project Administrator
Tue 14 Jun 2016 04:08:12 PM UTC, comment #2:

At some point Matlab may have moved this around. It is certainly dead simple to move it up from the private directory into the 'prefs' directory where it will be visible.

I don't know that we need to bother to support prefdir(1) syntax. Octave automatically creates the file '.octave_prefs' as necessary. Of course, we could always just document that you can call it that way.

Also, Octave supports preferences, but we support them in a UNIX way which is to have an rc file in the user's home directory. We don't use a separate folder, ~/.octave/, to hold that rc file.

Rik <rik5>
Project Administrator
Tue 14 Jun 2016 03:56:11 PM UTC, comment #1:

The linked page says "prefdir(1)" should create the directory. Does "prefdir(0)" also create it? Or "prefdir([])"?

Mike Miller <mtmiller>
Project Administrator
Tue 14 Jun 2016 09:22:16 AM UTC, original submission:

At the moment, prefdir is implemented in scripts/prefs/private/prefdir.m and is therefore not accessible from the command line while it should be for Matlab compatibility, see:


Before I noticed this file in Octave, I also implemented my own version that might provide a better compatibility with Matlab:

Guillaume <gyom>


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

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by gyom (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-06-15 mtmiller StatusNeed Info => Fixed
        Open/ClosedOpen => Closed
    2016-06-14 mtmiller StatusNone => Need Info

    Back to the top

    Powered by Savane 3.4