Skip to content

[Feature Request] Allow fvm use/install to function on windows without admin privileges. #1024

@TDuffinNTU

Description

@TDuffinNTU

Before creating a feature request make sure the suggestion fit within our principles

Is your feature request related to a problem? Please describe.
We shouldn't need to rely on user privilege escalation to install and manage FVM on Windows. It's a massive attack surface and opens up supply-change attacks from dependencies of FVM or the project itself.

And sure, I can personally get my IT support to let me into admin for a day, but the moment I need to run fvm use again? I gotta make a new ticket!

The reliance on admin rights for FVM is largely moot, too, as there are ways to create symlinks as unprivileged users on Windows, they simply rely on application devs to implement them instead of being backwards compatible (silly, I know).

Describe the solution you'd like
fvm install and use should not need to have admin rights to function on Windows. Whether this is implemented via symlinking changes to work for unprivileged accounts, or some other change (eg. fvm using an environment variable instead of a symlink at all) is not up to me, but I

Describe alternatives you've considered
I've written this small powershell script that I can use as a proxy for fvm commands. For use and install commands, it simply does the symlinking step itself afterwards. It'll still show the symlink error (I've tried to suppress this but it's more work than it's worth) and only works if your fvm cache is in ~/fvm/versions but otherwise seems to be fine for my usecase..? Not tested it much yet tbh

# Runs an FVM command, then attempts to symlink the cache to the project folder.
# Only attempts symlinking if "use" or "install" commands are invoked.
function Main {
    fvm $args
    if ($args[0] -eq "use") {
        SymlinkManually
    }
    if ($args[0] -eq "install" -and $args.Length -lt 2) {
        SymlinkManually
    }
}

# Symlinks ".fvm/versions" to "~/fvm/versions". 
function SymlinkManually {
    Write-Output "Symlinking manually..."
    Remove-Item .\.fvm\versions

    # May not be correct for your configuration!
    # Source: https://stackoverflow.com/questions/66609154/symlinks-cannot-be-created-in-powershell-5-1-but-can-be-created-by-powershell-7
    cmd /c mklink /J .\.fvm\versions %USERPROFILE%\fvm\versions
}


Main @args

Additional context

Workaround | https://stackoverflow.com/questions/66609154/symlinks-cannot-be-created-in-powershell-5-1-but-can-be-created-by-powershell-7

Discussion over unprivileged symlinking support in Windows | https://superuser.com/questions/1274164/how-to-use-the-symlinks-without-elevation-feature-from-the-windows-10-creators

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions