Login  Register

Fixed: StartupMacros not loading on Linux system

Posted by axm2 on Jul 24, 2008; 3:16am
URL: http://imagej.273.s1.nabble.com/Fixed-StartupMacros-not-loading-on-Linux-system-tp3695531.html

Dear Johannes, Dear Rasband,

please note that I run ImageJ * always * as a normal user, but just for
argument's sake ran it once with superuser permissions to rule out the
possibility that some weird permissions problem could be the cause. However,
it makes bugger all difference whether I run it as user or su. I shortened
the screen output to show only one output.

Thanks for noting the /plugins/plugins bit Johannes - that got me on the
right track. It is actually a bug in Menus.java and below is the bugfix.
Interesting though it does not go wrong from within JBuilder on Linux...

Cheers,
Tux

            String pluginsDir = property;
            if (pluginsDir==null)
                pluginsDir = homeDir;
            else if (pluginsDir.equals("user.home")) {
                pluginsDir = System.getProperty("user.home");
                if (!(new
File(pluginsDir+Prefs.separator+"plugins")).isDirectory())
                    pluginsDir = pluginsDir + Prefs.separator + "ImageJ";
                property = null;
                // needed to run plugins when ImageJ launched using Java
WebStart
                if (applet==null) System.setSecurityManager(null);
                jnlp = true;
            }

            // bugfix added 20080724 by AM: on Linux systems 'property' is
not null
            // and returns a path for pluginsDir that already ends in
'/plugins' which
            // leads to pluginsPath ending in ../plugins/plugins/ and
macrosPath in
            // ../plugins/macros
            // the variable name of pluginsDir is not well chosen as it
really is the
            // directory to where the ij executable is running from - hence
ijHomeDir
            //  would be a better name for pluginsDir.
            if((pluginsDir.endsWith(Prefs.separator))){
              pluginsDir = pluginsDir.substring(0,pluginsDir.length() - 1);
              if (IJ.debugMode)
                System.out.println("pluginsDir ends with directory
separator");
            }
            if((pluginsDir.endsWith(Prefs.separator+"plugins"))){
              pluginsDir = pluginsDir.substring(0,pluginsDir.length() - 8);
              if (IJ.debugMode)
                System.out.println("pluginsDir already ended in '/plugins' -
chopped off");
            }// end of bugfix

            // proceed as normal
            pluginsPath =
pluginsDir+Prefs.separator+"plugins"+Prefs.separator;
            if (property!=null&&!(new File(pluginsPath)).isDirectory())
                pluginsPath = pluginsDir + Prefs.separator;
            macrosPath =
pluginsDir+Prefs.separator+"macros"+Prefs.separator;

PS for Rasband: Perhaps we could get this into the mainstream code or make
some equivalent change?


2008/7/24 Johannes Schindelin <[hidden email]>:

> Hi Tux,
>
> On Tue, 22 Jul 2008, Tux Hacker wrote:
>
>
> > ////////// failed to load from shell ////////////////////////
> > 11:48 tux:../ij/ij-139s-am129 > su
> > Password:
>
> What the... ? Running ImageJ as _root_?
>
> > pluginsPath (b)=null
> > pluginsPath (d)=/home/arndt/j/ij/ij-139s-am129/plugins/plugins/
>
> This tells me that your script to run ImageJ from the command line sets
> plugins.dir to .../plugins/!  Compare that to theoutput from JBuilder:
>
> > ///////////// same log when run from JBuilder - good behaviour ///////
> >
> > [...]
> > userHome (a)=/home/arndt
>
> Saner.
>
> > pluginsPath (b)=null
> > pluginsPath (d)=/home/arndt/j/ij/ij-139s-am129/plugins/
>
> It obviously sets plugins.dir _not_ to .../plugins/.
>
> Hth,
> Dscho
>
>