How to load packages in Octave permanently?

TonyParker picture TonyParker · Jun 23, 2016 · Viewed 27.9k times · Source

I am using Octave on Window vista. I am using 4 package in my code. But every time I restart octave, I have to load manually from command line, 'pkg load ...' Is there a way to load them permanently so that whenever Octave is started it finds them in its path.

Answer

carandraug picture carandraug · Jun 23, 2016

When Octave starts, it runs ~/.octaverc. If you want Octave to automatically load a package, simply add a pkg load pkg-name command to it. If the files does not exist, create it.

If you do this, remember that other people may not have Octave configured to load packages at startup. Therefore, if you write code for others, remember that your programs still need to load the packages they require.

Do not use pkg install -auto ... or pkg rebuild -auto .. because that will stop working on the next Octave release.