latexmk under MSYS

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

latexmk under MSYS

Vincent Belaïche
Hello,

I have been using latexmk perl script under MSYS with the msys perl
5.8.8 (BTW thank for providing this more recent perl!).

latexmk does not work properly MSYS because it uses the USER
environement variable. It needs it because at some point of time it uses
the ps command to find running processes, and it uses it this way:

ps -f -u $USER

This is for some special use case where you need to detect some viewer
pid. When latexmk detects that the OS is MSWindow or Cygwin, this use ps
is sort of disabled.

My question is the following:

Can there be any handling of the MSYS case so that ps command can be
used for that latexmk purpose ?

I would say that:

1) The objective of MSYS as far as I understand is only to be able to
   use autotools under MSW, not to be some alternative *nixy-like MSW
   shell, so this kind of interactive use of latexmk might be out of
   scope of MSYS

2) I think that

     ps -f -u "$USERNAME"

   does the job... but that maybe not sufficient.

3) And then the next question is how to detect that we are in the MSYS
   case and that we can do this, in the cygwin case this viewer pid
   detection function is disabled with the following perl code of
   latexmk:

-----------------------------------------------------------------------
    # When the OS is detected as cygwin, there are two possibilities:
    #    a.  Latexmk was run from an NT prompt, but cygwin is in the
    #        path. Then the cygwin ps command will not see commands
    #        started from latexmk.  So we cannot use it.
    #    b.  Latexmk was started within a cygwin environment.  Then
    #        the ps command works as we need.
    # Only the user, not latemk knows which, so we default to not
    # using the ps command.  The user can override this in a
    # configuration file.
    $pscmd =
        'NONE $pscmd variable is not configured to detect running processes';
    $pid_position = -1;     # offset of PID in output of pscmd.  
                            # Negative means I cannot use ps
-----------------------------------------------------------------------

    I think that in the case of MSYS one should check:
    - that $OSTYPE == msys,
    - that perl is a one built for MSYS, and

   that would suffice to discard the case that latexmk is started from
   an NT prompt with NT form of /usr/bin being in the NT path (so with
   ps also in the NT path), because in this case OSTYPE is not supposed
   to be defined. Checking that perl is a one built for MSYS is
   certainly safer, that is why I think that if $OSTYPE == msys but perl
   is not an MSYS perl, latexmk should make some warning.

Comments and feedback are welcome.

   Vincent.





------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: latexmk under MSYS

Vincent Belaïche
Resending --- it seems that the original email has got stuck somewhere...
 
  Vincent.

----------------------------------------

> From: [hidden email]
> To: [hidden email]
> CC: [hidden email]; [hidden email]
> Subject: latexmk under MSYS
> Date: Mon, 21 Jul 2014 17:47:19 +0200
>
> Hello,
>
> I have been using latexmk perl script under MSYS with the msys perl
> 5.8.8 (BTW thank for providing this more recent perl!).
>
> latexmk does not work properly MSYS because it uses the USER
> environement variable. It needs it because at some point of time it uses
> the ps command to find running processes, and it uses it this way:
>
> ps -f -u $USER
>
> This is for some special use case where you need to detect some viewer
> pid. When latexmk detects that the OS is MSWindow or Cygwin, this use ps
> is sort of disabled.
>
> My question is the following:
>
> Can there be any handling of the MSYS case so that ps command can be
> used for that latexmk purpose ?
>
> I would say that:
>
> 1) The objective of MSYS as far as I understand is only to be able to
> use autotools under MSW, not to be some alternative *nixy-like MSW
> shell, so this kind of interactive use of latexmk might be out of
> scope of MSYS
>
> 2) I think that
>
> ps -f -u "$USERNAME"
>
> does the job... but that maybe not sufficient.
>
> 3) And then the next question is how to detect that we are in the MSYS
> case and that we can do this, in the cygwin case this viewer pid
> detection function is disabled with the following perl code of
> latexmk:
>
> -----------------------------------------------------------------------
> # When the OS is detected as cygwin, there are two possibilities:
> # a. Latexmk was run from an NT prompt, but cygwin is in the
> # path. Then the cygwin ps command will not see commands
> # started from latexmk. So we cannot use it.
> # b. Latexmk was started within a cygwin environment. Then
> # the ps command works as we need.
> # Only the user, not latemk knows which, so we default to not
> # using the ps command. The user can override this in a
> # configuration file.
> $pscmd =
> 'NONE $pscmd variable is not configured to detect running processes';
> $pid_position = -1; # offset of PID in output of pscmd.
> # Negative means I cannot use ps
> -----------------------------------------------------------------------
>
> I think that in the case of MSYS one should check:
> - that $OSTYPE == msys,
> - that perl is a one built for MSYS, and
>
> that would suffice to discard the case that latexmk is started from
> an NT prompt with NT form of /usr/bin being in the NT path (so with
> ps also in the NT path), because in this case OSTYPE is not supposed
> to be defined. Checking that perl is a one built for MSYS is
> certainly safer, that is why I think that if $OSTYPE == msys but perl
> is not an MSYS perl, latexmk should make some warning.
>
> Comments and feedback are welcome.
>
> Vincent.
>
>
>
>
     
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: latexmk under MSYS

Eli Zaretskii
> From: Vincent Belaïche <[hidden email]>
> Date: Mon, 21 Jul 2014 19:43:47 +0200
>
> latexmk does not work properly MSYS because it uses the USER
> environement variable. It needs it because at some point of time it uses
> the ps command to find running processes, and it uses it this way:
>
> ps -f -u $USER
>
> This is for some special use case where you need to detect some viewer
> pid. When latexmk detects that the OS is MSWindow or Cygwin, this use ps
> is sort of disabled.

That sounds like a bug in latexmk: it should support MS-Windows by
checking USERNAME instead.

Why are you asking this here, rather than on the latexmk list?
         
> 3) And then the next question is how to detect that we are in the MSYS
> case and that we can do this, in the cygwin case this viewer pid
> detection function is disabled with the following perl code of
> latexmk:

To detect MSYS, you can test that $MSYSTEM is defined.

> -----------------------------------------------------------------------
> # When the OS is detected as cygwin, there are two possibilities:
> # a. Latexmk was run from an NT prompt, but cygwin is in the
> # path. Then the cygwin ps command will not see commands
> # started from latexmk. So we cannot use it.
> # b. Latexmk was started within a cygwin environment. Then
> # the ps command works as we need.
> # Only the user, not latemk knows which, so we default to not
> # using the ps command. The user can override this in a
> # configuration file.
> $pscmd =
> 'NONE $pscmd variable is not configured to detect running processes';
> $pid_position = -1; # offset of PID in output of pscmd.
> # Negative means I cannot use ps

According to this, there is already a way for users to get this
functionality to work, so I'm not sure what is still the problem.


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: latexmk under MSYS

Vincent Belaïche


[...]
>
> That sounds like a bug in latexmk: it should support MS-Windows by
> checking USERNAME instead.

That was my opinion indeed

>
> Why are you asking this here, rather than on the latexmk list?
>

In fact I had got in touch with latexmk maintainer in the first place,
he suggested that he could handle MSYS like a special case, as he
already does that sort of things for cygwin.

Then I decided to raise the issue on Mingw-users list for people to
confirm that this is a latexmk issue --- not MSYS wrongly not setting
$USER. The aim of my email was also to get some guidance how to fix
this in latexmk if confirmed that the issue is there.


>> 3) And then the next question is how to detect that we are in the MSYS
>> case and that we can do this, in the cygwin case this viewer pid
>> detection function is disabled with the following perl code of
>> latexmk:
>
> To detect MSYS, you can test that $MSYSTEM is defined.
>

Good, that was that sort of information that is

>> -----------------------------------------------------------------------
[...]
>
> According to this, there is already a way for users to get this
> functionality to work,
>
Yes, I agree, the simplest fix would be to do the same handling for
MSYS as for cygwin --- ie disable the function otherwise than if
hacking it with latexmk hooking mechanism.

> so I'm not sure what is still the problem.
>
I don't think there is any remaining problem after reading your
suggestion on using $MSYSTEM.

Anyway, my opinion is that this is more of a perl problem than
anything :  there should be some kind of standard perl module to detect
in a portable way what pid's are on the air whatever the environment is
(MSW, Linux, MSYS, etc...) and latexmk should delegate that work to
this standard perl module rather than do it on its own.

   Vincent.

     
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: latexmk under MSYS

Greg Jung
In reply to this post by Vincent Belaïche

I can have all three shells on my system. 
 $OS is evidently set to "Windows_NT" by windows. 
 CYGWIN and MSYS each have /bin/uname.exe's which give:
$ uname -s
Msys: MINGW32_NT-6.1 
CygWin: CYGWIN_NT-6.1

If you have msys or cygwin, then unless it is all screwed up, /bin will include
a certain number of msys*.dll files or of cyg*.dll files.
$ uname -a
MINGW32_NT-6.1 HOMERW7 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Msys
CYGWIN_NT-6.1 Homerw7 1.7.30(0.272/5/3) 2014-05-23 10:36 x86_64 Cygwin
Windows_NT Homerw7 6.1 7601+Service_Pack_1

USER is set by CYGWIN not by MSYS or windows
 "MSYSTEM" is set up in the msys.bat login procedure so you should probably not rely on it.

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: latexmk under MSYS

Vincent Belaïche
FYI, to my understanding, in the end latexmk was corrected not to rely on any of OS, OSTYPE or MSYSTEM variable. it simply assumes that

perl -e 'print "$^O\n"'


will output

msys

and will use USERNAME when USER is not defined.

for perl -e 'print "$^O\n"'
to output msys you probably need that your installation is done in a way that you have two instance of perl:
- msys perl (from the MingW download area)
- some MSWindow perl (say activeState as in my case)
and then you need that MSYS call the msys perl and DOS will call the activeState perl. I achieved that by
- having the activeState perl in the MSWindow PATH
- has some AWK script in my ~/.bash_profile to process $PATH so that activeState perl is removed from the path, and msys perl is added instead. To make this simpler I configured into /etc/fstab the MSYS perl root directory as /perl.

The bad side of this is that for MSYS it works only in --login mode for my ~/.bash_profile to be called.

VBR,
   Vincent.


________________________________

> Date: Sat, 26 Jul 2014 23:41:14 -0700
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [Mingw-users] latexmk under MSYS
>  
>  
> I can have all three shells on my system.
>   $OS is evidently set to "Windows_NT" by windows.
>   CYGWIN and MSYS each have /bin/uname.exe's which give:
> $ uname -s
> Msys: MINGW32_NT-6.1
> CygWin: CYGWIN_NT-6.1
>  
> If you have msys or cygwin, then unless it is all screwed up, /bin will  
> include
> a certain number of msys*.dll files or of cyg*.dll files.
> $ uname -a
> MINGW32_NT-6.1 HOMERW7 1.0.17(0.48/3/2) 2011-04-24 23:39 i686 Msys
> CYGWIN_NT-6.1 Homerw7 1.7.30(0.272/5/3) 2014-05-23 10:36 x86_64 Cygwin
> Windows_NT Homerw7 6.1 7601+Service_Pack_1
>  
> USER is set by CYGWIN not by MSYS or windows
>   "MSYSTEM" is set up in the msys.bat login procedure so you should  
> probably not rely on it.
>  
> ------------------------------------------------------------------------------  
> Want fast and easy access to all the code in your enterprise? Index and  
> search up to 200,000 lines of code with a free copy of Black Duck Code  
> Sight - the same software that powers the world's largest code search  
> on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds 
> _______________________________________________ MinGW-users mailing  
> list [hidden email] This list observes the Etiquette  
> found at http://www.mingw.org/Mailing_Lists. We ask that you be polite  
> and do the same. Disregard for the list etiquette may cause your  
> account to be moderated.  
> _______________________________________________ You may change your  
> MinGW Account Options or unsubscribe at:  
> https://lists.sourceforge.net/lists/listinfo/mingw-users Also:  
> mailto:[hidden email]?subject=unsubscribe
     
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: latexmk under MSYS

Keith Marshall
In reply to this post by Greg Jung
On 27/07/14 07:41, Greg Jung wrote:
> "MSYSTEM" is set up in the msys.bat login procedure so you should
> probably not rely on it.

Huh?  $MSYSTEM is *guaranteed* to be appropriately set up, for any
*correctly initialized* MSYS shell environment; you don't need to run
msys.bat to achieve that, although doing so may be the most convenient
way to set it up.  If you can't rely on $MSYSTEM, that's PEBKAC; you are
misusing MSYS.

I've lost count of the number of times this has been stated: the most
important phrase in the above is "correctly initialized MSYS shell
environment".  To get one of those, you *must* run MSYS commands from an
MSYS shell which has been started with the --login option, (and usually
also with the -i option).  If you are misusing MSYS in any other
fashion, (e.g. by adding the MSYS bin directory to cmd.exe's %PATH%),
then that's an unequivocal manifestation of PEBKAC -- *you* broke it, so
you get to keep all the pieces.

On 27/07/14 13:25, Vincent Belaïche wrote:
> The bad side of this is that for MSYS it works only in --login mode
> for my ~/.bash_profile to be called.

That's unfair!  There is nothing "bad" about using tools as they are
designed to be used.  Yes, you have to initialize the shell environment
by specifying the --login option; that's by design, and to do otherwise
is just a similar manifestation of PEBKAC.  Run your makefiles with the
MSYS implementation of make, from a properly initialized MSYS shell, if
they are dependent on the use of MSYS tools.

--
Regards,
Keith.

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe