Fixed: StartupMacros not loading on Linux system

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Fixed: StartupMacros not loading on Linux system

axm2
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
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Fixed: StartupMacros not loading on Linux system

dscho
Hi,

On Thu, 24 Jul 2008, Koala wrote:

> 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...

Who is "AM"?

Besides, I have the impression that you _break_ existing setups with your
"fix".

Sure, plugins.dir is a misnomer, but that makes it no better if you break
_my_ running system.

>             // 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");
>             }

Why?  It is _perfectly_ legal for pluginsDir to end in a slash.

>             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

And this is where things can break.

I'd rather have you fix _your_ invocation, especially since JBuilder
already had it right, than to change ImageJ for that.

Ciao,
Dscho