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

Execute the Windows installer as normal user #2628

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mardukbp
Copy link

@mardukbp mardukbp commented May 30, 2024

Currently the Windows installer requires admin privileges, which are typically not available in an enterprise environment. This PR produces a Windows installer that runs without admin privileges.

Three of the four reasons why the installer requires admin rights have been addressed:

  • HKCR registry keys were replaced by HKCU registry keys
  • The name of the Erlang node of the Livebook app includes the host IP (since name resolution apparently requires admin rights)
  • The vc_redist.x64.exe installer was removed and the Livebook.exe app no longer targets .NET Framewok 4. Now it targets .NET 8 and is completely self-contained.

OTP (or rather erl.exe) requires vcruntime140.dll. This DLL can be added after extracting the OTP distribution.

@CLAassistant
Copy link

CLAassistant commented May 30, 2024

CLA assistant check
All committers have signed the CLA.

@wojtekmach
Copy link
Contributor

OTP (or rather erl.exe) requires vcruntime140.dll. This DLL can be added after extracting the OTP distribution.

Can you elaborate on this? If we still need .dll but we are not shipping its installer and thus not installing it ourselves, how does this work in practice?

@mardukbp
Copy link
Author

I just learned that the windows-latest image of GH actions includes VS 2022 with the component Microsoft.VisualStudio.Component.VC.Redist.14.Latest. And I found a script that copies the DLL from it.

Python, VS Code and many Rust CLI apps ship this DLL.

@wojtekmach
Copy link
Contributor

Sorry I still don’t understand how it works. If we are not shipping the .dll how does Livebook work without it? Are you saying users would have gotten it after installing, say, VSCode? But then it wouldn’t work without it, right?

@wojtekmach
Copy link
Contributor

Are you saying we should ship .dll ourselves (as opposed to shipping the vc_redist.exe which installs it into location which requires admin)? If so, yes, that’d be great and help on that front would be very appreciated.

@mardukbp
Copy link
Author

Yes, that's what I mean. I will ask the Erlang people why don't they do it themselves. This issue leaves students and people in companies out of the BEAM world. If for some reason they don't want to do it, I will implement it for Livebook :)

@wojtekmach
Copy link
Contributor

Right, thanks.

So about the other changes. Switching to HKCU sounds good to me.

About dropping Windows.Forms and .NET 4.6 with self-contained=false in favor of .NET 8.0 with self-contained=true and using third party plugins, what is the installer size difference? Could you list upsides/downsides of what you are proposing? In isolation from other issues (vc redist and HKCU) because I believe, and correct me if I’m wrong, it is completely orthogonal?

@mardukbp
Copy link
Author

The installer size is almost the same, thanks to trimming. I thought that Livebook.exe depends on vcredist. I didn't realize it was due to Erlang. Windows Forms can be used with .NET 8, but it currently does not support trimming. That is planned for .NET 9. So I removed it in order to use trimming. The third-party libraries are thin wrappers on top of the Windows API. One could just include the code. But now that I know that we only need vcruntime140.dll I reverted the changes to Livebook.exe.

@wojtekmach
Copy link
Contributor

The PR looks good to me assuming OTP will ship with required .dll files. If you could start the conversation and/or PR and if accepted it would be released in OTP 27.1, I think we can wait. Otherwise, eg it is deamed to big of a change and so scheduled for OTP 28, we’d appreciate doing the change in Livebook.

@wojtekmach
Copy link
Contributor

If you start issue/PR in OTP please cc me and/or mention it here so we can keep track!

@mardukbp
Copy link
Author

I opened an issue in the OTP repo. Subscribe and we'll see what they say :)

@wojtekmach
Copy link
Contributor

Hey @mardukbp, thanks again for working on this. I tried the PR locally and noticed that Livebook was no longer showing up in "Settings / Apps / Installed Apps", i.e. we cannot delete it from that place anymore. Is it because to have that, we're writing to HKLM and we no longer have permission to do so when not running as an admin, i.e. it silently fails? I tested .livemd file association and livebook:// url scheme and it works well.

Please revert removal of vc_redist.exe. We shouldn't wait for OTP to make it obsolete. I just tested this and even with RequestExecutionLevel user in the installer, I was able to install vc_redist.exe. In other words, I assume that for users with low privileges it is OK to attempt installing vc_redist they'd just say no when asked whether to install it. Would this work?

@mardukbp
Copy link
Author

Hi @wojtekmach, I just updated the installer so that uninstalling works. I also reverted the removal of vc_redist.exe.

The Livebook installer would work for anybody who already has vcruntime140.dll. Hopefully that is a large percentage of users. And hopefully OTP will one day ship the DLL. Then Livebook will not need vc_redist.exe at all.

@wojtekmach
Copy link
Contributor

Could you rebase with latest main? I’d expect your changes around node naming and similar are no longer necessary.

@mardukbp
Copy link
Author

Done

@mardukbp
Copy link
Author

I tested it with a user with no admin rights and Livebook does not work. The notebook cannot connect to Elixir. Something is missing in the new env.bat. I will have to investigate, unless you have an idea.

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

Successfully merging this pull request may close these issues.

None yet

3 participants