ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Update setpath to set the path
@ 2021-05-09 19:14 Thangalin
  2021-05-09 23:50 ` Thangalin
  2021-05-10  7:00 ` Aditya Mahajan
  0 siblings, 2 replies; 5+ messages in thread
From: Thangalin @ 2021-05-09 19:14 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2238 bytes --]

Thoughts on updating the setpath.bat file to persist setting the path?

Here's an updated version that sets the system environment variable while
preserving the existing unexpanded PATH value:

rem SOF
echo off
set OWNPATH=%~dp0
set PLATFORM=mswin

if defined ProgramFiles(x86)                        set PLATFORM=win64
if "%PROCESSOR_ARCHITECTURE%"=="AMD64"              set PLATFORM=win64
if exist "%OWNPATH%tex\texmf-mswin\bin\context.exe" set PLATFORM=mswin
if exist "%OWNPATH%tex\texmf-win64\bin\context.exe" set PLATFORM=win64

echo %PATH% | findstr "texmf-%PLATFORM%" > nul

rem Only update the PATH if not previously updated
if ERRORLEVEL 1 (
  set Key="HKLM\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment"
  set "CurrPath="
  for /F "USEBACKQ tokens=2*" %%A in (`reg query %%Key%% /v PATH`) do (
    if not "%%~B" == "" (
      rem Preserve the existing PATH
      echo %%B > currpath.txt

      rem Update the current session
      set PATH=%PATH%;%OWNPATH%tex\texmf-%PLATFORM%\bin

      rem Change the PATH environment variable
      setx PATH "%%B;%OWNPATH%tex\texmf-%PLATFORM%\bin" /M
    )
  )
)
rem EOF

Another possibility would be to define CONTEXT_HOME as an unexpanded value
added to both the system environment variables and  the PATH variable. For
example (haven't tried it):

setx CONTEXT_HOME "%OWNPATH%tex\texmf-%PLATFORM%\bin"
setx PATH "%%B;%%CONTEXT_HOME%%"

The advantage with this pattern is that subsequent updates need only check
for CONTEXT_HOME and change its value without having to worry about PATH
parsing, which can be hairy.

Yet another option to consider is changing the value for only the existing
user, rather than system-wide. Perhaps two different batch files?

The reason for this change is because the Windows installation instructions
(on the wiki) are incomplete: technically, the user must run setpath.bat
for each new session. This implies that any third-party program that wants
to make use of ConTeXt on Windows would have to communicate said fact to
the user, or let the user set the full path to ConTeXt within the
third-party program. Both of these can be avoided by persisting the PATH
setting across sessions.

Thank you!

P.S.
Pasted: https://pastebin.com/qpsqXZNB

[-- Attachment #1.2: Type: text/html, Size: 3007 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Update setpath to set the path
  2021-05-09 19:14 Update setpath to set the path Thangalin
@ 2021-05-09 23:50 ` Thangalin
  2021-05-10  7:00 ` Aditya Mahajan
  1 sibling, 0 replies; 5+ messages in thread
From: Thangalin @ 2021-05-09 23:50 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1221 bytes --]

Here's a version that persits the current user's PATH (i.e., not
system-wide):

rem SOF
@echo off
set "OWNPATH=%~dp0"
set "PLATFORM=mswin"

if defined ProgramFiles(x86)                        set "PLATFORM=win64"
if "%PROCESSOR_ARCHITECTURE%"=="AMD64"              set "PLATFORM=win64"
if exist "%OWNPATH%tex\texmf-mswin\bin\context.exe" set "PLATFORM=mswin"
if exist "%OWNPATH%tex\texmf-win64\bin\context.exe" set "PLATFORM=win64"

set "TeXPath=%OWNPATH%tex\texmf-%PLATFORM%\bin"

echo %PATH% | findstr "texmf-%PLATFORM%" > nul

rem Only update the PATH if not previously updated
if ERRORLEVEL 1 (
  setlocal enabledelayedexpansion
  set "Exists=false"
  set "Key=HKCU\Environment"

  for /F "USEBACKQ tokens=2*" %%A in (`reg query %%Key%% /v PATH 2^>nul`)
do (
    if not "%%~B" == "" (
      set "Exists=true"

      rem Preserve the existing PATH
      echo %%B > currpath.txt

      rem Change the PATH environment variable
      setx PATH "%%B;%TeXPath%"
    )
  )

  rem The user-defined PATH does not exist, create it
  if "!Exists!" == "false" (
    rem Change the user PATH environment variable
    setx PATH "%TeXPath%"
  )

  endlocal

  rem Update the current session
  set "PATH=%PATH%;%TeXPath%"
)
rem EOF

[-- Attachment #1.2: Type: text/html, Size: 1994 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Update setpath to set the path
  2021-05-09 19:14 Update setpath to set the path Thangalin
  2021-05-09 23:50 ` Thangalin
@ 2021-05-10  7:00 ` Aditya Mahajan
  2021-05-10  7:18   ` Thangalin
  1 sibling, 1 reply; 5+ messages in thread
From: Aditya Mahajan @ 2021-05-10  7:00 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Sun, 9 May 2021, Thangalin wrote:

> Thoughts on updating the setpath.bat file to persist setting the path?
> 
> Here's an updated version that sets the system environment variable while
> preserving the existing unexpanded PATH value:
> 
> [....] 
>
> The reason for this change is because the Windows installation instructions
> (on the wiki) are incomplete: technically, the user must run setpath.bat
> for each new session. 

This is how setuptex works on linux as well. 

> This implies that any third-party program that wants
> to make use of ConTeXt on Windows would have to communicate said fact to
> the user, or let the user set the full path to ConTeXt within the
> third-party program. Both of these can be avoided by persisting the PATH
> setting across sessions.

One of the benefits of context minimals is that you can install multiple versions in parallel, which allows the user to update frequently without the risk of breaking something for long-term projects. Specifically, you can keep a "frozen" version of context for long-term projects and install a newer version in parallel for newer projects. 

So, your suggestions should be included as a separate script and not as part of the default. Then there is the question of providing an uninstall script as well...

Aditya
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Update setpath to set the path
  2021-05-10  7:00 ` Aditya Mahajan
@ 2021-05-10  7:18   ` Thangalin
  2021-05-10  7:40     ` Hans Hagen
  0 siblings, 1 reply; 5+ messages in thread
From: Thangalin @ 2021-05-10  7:18 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1160 bytes --]

> One of the benefits of context minimals is that you can install multiple
> versions in parallel, which allows the user to update frequently without
> the risk of breaking something for long-term projects. Specifically, you
> can keep a "frozen" version of context for long-term projects and install a
> newer version in parallel for newer projects.
>

For sure! My environment looks as follows:

export CONTEXT_HOME=/opt/context
export PATH="$PATH:...:$CONTEXT_HOME/tex/texmf-linux-64/bin:..."

The /opt/context directory is a symbolic link, which eases switching
between versions: I seldom have to change the environment variables
settings.

So, your suggestions should be included as a separate script and not as
> part of the default. Then there is the question of providing an uninstall
> script as well...
>

Using a ConTeXt-specific environment variable (e.g., LMTX_HOME) would make
uninstalling a matter of removing it from the PATH and registry (on
Windows, anyway). Here are the current instructions:

https://github.com/DaveJarvis/keenwrite/blob/master/docs/typesetting.md#windows

Is there a way we can eliminate steps 3 - 6 for Windows installs?

[-- Attachment #1.2: Type: text/html, Size: 1846 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Update setpath to set the path
  2021-05-10  7:18   ` Thangalin
@ 2021-05-10  7:40     ` Hans Hagen
  0 siblings, 0 replies; 5+ messages in thread
From: Hans Hagen @ 2021-05-10  7:40 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Thangalin

On 5/10/2021 9:18 AM, Thangalin wrote:
> 
>     One of the benefits of context minimals is that you can install
>     multiple versions in parallel, which allows the user to update
>     frequently without the risk of breaking something for long-term
>     projects. Specifically, you can keep a "frozen" version of context
>     for long-term projects and install a newer version in parallel for
>     newer projects.
> 
> 
> For sure! My environment looks as follows:
> 
> export CONTEXT_HOME=/opt/context
> export PATH="$PATH:...:$CONTEXT_HOME/tex/texmf-linux-64/bin:..."
> 
> The /opt/context directory is a symbolic link, which eases switching 
> between versions: I seldom have to change the environment variables 
> settings.
> 
>     So, your suggestions should be included as a separate script and not
>     as part of the default. Then there is the question of providing an
>     uninstall script as well...
> 
> 
> Using a ConTeXt-specific environment variable (e.g., LMTX_HOME) would 
> make uninstalling a matter of removing it from the PATH and registry (on 
> Windows, anyway). Here are the current instructions:
> 
> https://github.com/DaveJarvis/keenwrite/blob/master/docs/typesetting.md#windows 
> <https://github.com/DaveJarvis/keenwrite/blob/master/docs/typesetting.md#windows>
> 
> Is there a way we can eliminate steps 3 - 6 for Windows installs?
if one starts up mtxrun or context with a fully quallified path it will 
work ok (because it then knows where it sits in the tex tree), like

c:\data\context\tex\texmf-win64\bin\mtxrun --script context ...

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-10  7:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-09 19:14 Update setpath to set the path Thangalin
2021-05-09 23:50 ` Thangalin
2021-05-10  7:00 ` Aditya Mahajan
2021-05-10  7:18   ` Thangalin
2021-05-10  7:40     ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).