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

rakubrew init on Windows tells me to run rakubrew init for PowerShell instructions #81

Open
ugexe opened this issue Jan 19, 2025 · 1 comment

Comments

@ugexe
Copy link
Contributor

ugexe commented Jan 19, 2025

The instructions from rakubrew init tells me to run rakubrew init for powershell instructions. Yet I'm already running that command from powershell.

(Note that the above does not enable auto-loading in PowerShell, that needs a
separate installation procedure. Call C:\rakubrew\bin\rakubrew.exe init in a PowerShell window
for respective installation instructions.)

PS C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools> C:\rakubrew\bin\rakubrew.exe init
To load rakubrew in CMD automatically you have to do two things:

1. Check that you don't already have a CMD autorun script set.

    reg query "HKCU\Software\Microsoft\Command Processor" /v AutoRun

  If you don't have an autorun script set (the above command returns an error) you can set one using:

    reg add "HKCU\Software\Microsoft\Command Processor" /v AutoRun /t REG_EXPAND_SZ /d \""%"USERPROFILE"%\Documents\CMD_profile.cmd"\" /f

2. Add the following code to the end of the autorun script you linked in step 1:

    @echo off
    setlocal EnableDelayedExpansion
    set "cmd=!cmdcmdline!"
    if "!cmd!" == "!cmd:/=!" (
        endlocal
        FOR /f "delims=" %%i in ('"C:\rakubrew\bin\rakubrew.exe" init Cmd') do @%%i
    )

  You can easily do that from a CMD prompt using the following command:

    (
    echo @echo off
    echo setlocal EnableDelayedExpansion
    echo set "cmd=!cmdcmdline!"
    echo if "!cmd!" == "!cmd:/=!" ^(
    echo     endlocal
    echo     FOR /f "delims=" %%i in ^('"C:\rakubrew\bin\rakubrew.exe" init Cmd'^) do @%%i
    echo ^)
    ) >> "%USERPROFILE%\Documents\CMD_profile.cmd"

  If you use a different autorun script location, replace the path in the command above.

(Note that the above does *not* enable auto-loading in PowerShell, that needs a
separate installation procedure. Call `C:\rakubrew\bin\rakubrew.exe init` in a PowerShell window
for respective installation instructions.)
@patrickbkr
Copy link
Member

The logic to detect whether it's PS or CMD is here. It relies on some env var trickery. (See those 6 lines of code and the linked StackOverflow explanation.) Can you check how the environment looks on your machine? Maybe you can identify some other clue that gives away whether we're in a PS or CMD?

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

No branches or pull requests

2 participants