Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add switch to allow SystemVar Path add #24

Merged
merged 10 commits into from
Sep 8, 2022
Merged

Conversation

andrihitz
Copy link
Contributor

Adds a switch option /SystemVar to add it to the SystemVar Path aswell.

Adds a switch option /SystemVar to add it to the SystemVar Path aswell.
Comment on lines 22 to 27
# checks if choco switch var is in parameters
if ($pp['SystemVar'] -eq 'true') {
Write-Host "Running tlmgr SystemVar path add"
# Adds to SystemVar Path
[Environment]::SetEnvironmentVariable("PATH", $Env:PATH + ";C:\Program Files\Scripts", [EnvironmentVariableTarget]::Machine)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand the code correctly it adds C:\Program Files\Scripts to the system path. Is there any reason why C:\Program Files\Scripts needs to be added to the system path(TinyTex is installed to C:\tools\TinyTeX usually, where C:\tools can be customised)?

By the way, the installation can be added to the system path using the command tlmgr path --w32mode=admin add (I think this should be the default).

On the other hand, SystemVar isn't clear can you rename it to something else like AddToSystemPath instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your feedback, I accidentally copied the wrong code from my local files. Fixed it.

Does this mean that the installation should be touched again to add it to the system path?

A good point, I just renamed it to match your suggestion. Thanks

Copy link
Contributor

@cderv cderv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @andrihitz

It is not quite clear to me which issue we are trying to solve here.

tlmgr should be added to PATH using its own mechanism tlmg path add which we do

# Adds to Path
$statementsToRun = "/C `"$toolsDir\TinyTeX\bin\win32\tlmgr.bat path add`""
Start-ChocolateyProcessAsAdmin $statementsToRun "cmd.exe"

Is this not enough ? Is it not working ?

as @naveen521kk said, there is some configuration that can be done to this command. It is shown here
https://www.tug.org/texlive/doc/tlmgr.html#path
In some case, the flag is not even needed

If the user has admin rights, and the option --w32mode is not given, the setting w32_multi_user determines the location (i.e., if it is on then the system path, otherwise the user path is changed).

Does chocolatey is executed in Admin mode when you install ?

Anayway, If those configuration needs to be access we can make that happens.

Here we are adding a second way to add to PATH and I am not quite sure if this is a good solution as I don't fully comprehend the issue.

Can you explain what you are solving here ? Thank you.

changed to tlmgr command to add path var to the systemvars
@andrihitz
Copy link
Contributor Author

Hi @cderv

Thanks for your Feedback.

Well, the issue I have, by default, the path var is just installed at the user's path and not in the system path, even if the command prompt was launched as admin.

I misunderstood the note by @naveen521kk for installing the system path with the onboard command in tlmgr.
In the newest commits, I changed my PowerShell command to that command.

For my understanding, I wasn't able to get any information about the w32_multi_user setting and what I had to change to automatically add the system path, Can you explain where I can find this setting?

Thanks for your Support.

Comment on lines 22 to 28
# checks if choco switch AddToSystemPath var is in parameters
if ($pp['AddToSystemPath'] -eq 'true') {
Write-Host "Running tlmgr AddToSystemPath"
# AddToSystemPath
$statementsToRun = "/C `"$toolsDir\TinyTeX\bin\win32\tlmgr.bat path --w32mode=admin add`""
Start-ChocolateyProcessAsAdmin $statementsToRun "cmd.exe"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we were to do that, I think we just need to add the flag in the previous line when the option is passed to chocolatey.

https://github.com/rstudio/tinytex-releases/pull/24/files#diff-5a71f76f6ddf465237c7306d0e59eb56e11db5cfb7281b4a5a647306dda6efe5R19-R20

Here we are putting tlmgr twice in the PATH. First user, then system. It does not seem right.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

combined the two lines, but I am not sure if this is the way to do it.
At least it works with the if operator.

@cderv
Copy link
Contributor

cderv commented Aug 25, 2022

For my understanding, I wasn't able to get any information about the w32_multi_user setting and what I had to change to automatically add the system path, Can you explain where I can find this setting?

I think it is a conf for tlmgr. Probably something you can set with tlmgr conf tlmgr w32_multi_user=1 or tinytex::tlmgr_conf(c("tlmgr", "w32_multi_user=1"). Donc for tlmgr conf is in the man page: https://www.tug.org/texlive/doc/tlmgr.html#conf
There are also some config file : https://www.tug.org/texlive/doc/tlmgr.html#CONFIGURATION-FILE-FOR-TLMGR

This is probably what is controlling the default behavior of tlmgr.

Do you want to try one of this configuration file to see if that change something ?

Other we could add the flag, but in the first call of path add and not add a second call IMO

@andrihitz
Copy link
Contributor Author

I guess adding a choco param as we did is the best, quickest solution otherwise, we need to modify or import the config, as I understand this right.

@cderv
Copy link
Contributor

cderv commented Aug 25, 2022

The change looks good to me. Did you manage to build and test it yourself ? does it install as admin with this change ?
It looks it should

@andrihitz
Copy link
Contributor Author

Yes, I packed it on my local machine and installed it with and without the parameter, and it worked as intended. The path var will be removed while uninstalling.

Copy link
Collaborator

@naveen521kk naveen521kk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small typo, other than that sgtm

README.md Outdated Show resolved Hide resolved
andrihitz and others added 2 commits September 8, 2022 16:17
Co-authored-by: Naveen M K <naveen521kk@gmail.com>
Copy link
Contributor

@cderv cderv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me too !

@yihui ok to merge ?

Should we trigger a patch release of the chocolatey bundle ? Otherwise it will be available next month.

@yihui
Copy link
Member

yihui commented Sep 8, 2022

@yihui ok to merge ?

Yes.

Should we trigger a patch release of the chocolatey bundle ? Otherwise it will be available next month.

I don't have an opinion. It's up to @andrihitz (whether a release is needed right now).

@cderv cderv merged commit d6d9209 into rstudio:master Sep 8, 2022
@cderv
Copy link
Contributor

cderv commented Sep 8, 2022

I have just merged. @andrihitz can you wait for next month automatic release ?

Otherwise, I'll see what I can do for a path release for this version.

@andrihitz
Copy link
Contributor Author

Thanks for merging. We can wait for next month's automatic release. @cderv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

4 participants