flofreud / posh-gvm

GVM for Powershell
Apache License 2.0
210 stars 60 forks source link

The term 'gradle' is not recognized as the name of a cmdlet #15

Closed shambalaxx closed 8 years ago

shambalaxx commented 8 years ago

After first run of powershell system cannot find any installed software for example:

PS C:\Users\username> gradle -v gradle : The term 'gradle' is not recognized as the name of a cmdlet, function, script file, or operable program. Check

So to make gradle command available we have to run 'gvm c' first.

And there is noway to call gradle from 'cmd'.

flofreud commented 8 years ago

Like mentioned in the installation guide you have to load gvm in the powershell session. You could do this by adding Import-Module posh-gvm to your profile. I didn't automate this because I didn't like a script to modify my profile. Probably this could be changed so that the installation prompts the user.

When you enter gvm without loading the module, powershell doesn't know the command and checks if there is a module available which could provide it and then loads the posh-gvm module.

posh-gvm manages the SDKs for your powershell environment and not for CMD. There is no CMD implementation (as best as I know). But you could add gradle to your global path variable (eg the current symlink).

If you start CMD within the powershell session (type cmd) than the started cmd would work with the same PATH as powershell and therefore it would also work in CMD.

shambalaxx commented 8 years ago

Thanks for comprehensive answer.

But why we can't just update the global path variable in installation script?

flofreud commented 8 years ago

Do you mean why do we not change always the global var? If yes, because:

  1. I didn't want to change global scope but the powershell scope by design.
  2. Even if we would like to do it global in general it would be really slow. The change would have to be done in the Windows Registry. The changes will than be automatically propagated to all windows application. Only after all windows have recieved the event the registry change call would finish.
  3. The current solution to update the PATH variable is really simple (prepend new values) and this would get fast really messy for the global variable. For the powershell scope this works, because the variable will be reset on shell start.

You are using CMD in general and you only start the PowerShell for posh-gvm? Or why do you need CMD to know which the gradle path?

shambalaxx commented 8 years ago

I don't use powershell most of the time because it cmd is just faster. At least first loading of powershell is very slow.

I didn't know the point that updating global PATH variable could be that slow. For me 'setx' command works pretty fast. But requires restart of any application that we want to use the new value.

flofreud commented 8 years ago

Last time I tested the needed .net method [environment]::SetEnvironmentVariable('PATH', xy, 'Machine') (probably 'User' would be enough) took sometimes several seconds. But this was years ago.

I will not change the default behavior. You could provide a pull request which will set it globally if especially configurated. But most likely the easiest solution for you would be to change the global path once manually. If you add something like <userhome>/.posh_gvm/gradle/current to your PATH, it should be working for your use case for now.

shambalaxx commented 8 years ago

Yes, workaround works fine for me. Thank you.