Giter VIP home page Giter VIP logo

ghcman's Introduction

ghcman; ghcup for PowerShell on Windows

GitHub Actions: test GitHub Actions: install GitHub Actions: lint PowerShell Gallery Join the chat at https://gitter.im/ghcman/community Sponsor

Install

Download and load ghcman to PowerShell.

> Install-Module ghcman
> Import-Module ghcman

Confirm its info.

> Get-Module ghcman

ModuleType Version    Name     ExportedCommands
---------- -------    ----     ----------------
Manifest   1.0        ghcman   {Clear-Cabal, Clear-Ghc, Install-Cabal, Install-Ghc...}

Show help. Add the -Full option for more details.

> Get-Help Set-Ghc

NAME
    Set-Ghc

SYNOPSIS
    Sets the version or variant of GHC to the Path environment variable of the current session.


SYNTAX
    Set-Ghc [-Ghc] <String> [<CommonParameters>]


DESCRIPTION


RELATED LINKS


How to use

Retrieve new versions data.

> Update-GhcmanVersionFile

Install a specified GHC and set it to $Env:Path.

> Install-Ghc 9.2.1
> Set-Ghc 9.2.1
> ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.2.1

Install a specified Cabal and set it to $Env:Path.

> Install-Cabal 3.4.0.0
> Set-Cabal 3.4.0.0
> cabal --version
cabal-install version 3.4.0.0
compiled using version 3.4.0.0 of the Cabal library

Check which versions are installed or not.

> Get-Ghc -HumanReadable
9.2.1    S C:\Users\kazuki\AppData\Roaming\ghcman\ghc-9.2.1
9.0.1    S
8.10.6   S
8.10.5   S
8.10.4   S
8.10.3   S
8.10.2   S
8.10.1   S
8.8.4    S
8.8.3    S
8.8.2    S
8.8.1    S
8.6.5    S
8.6.4    S
8.6.3    S
8.6.2    S
8.6.1    S
8.4.4    S
8.4.3    S
8.4.2    S
8.4.1    S
8.2.2    S
8.2.1    S
8.0.2    S
8.0.1    S
S: supported
> Get-Cabal -HumanReadable
3.4.0.0  S C:\Users\kazuki\AppData\Roaming\ghcman\cabal-3.4.0.0
3.2.0.0  S
3.0.0.0  S
2.4.1.0  S
2.4.0.0  S
2.2.0.0  S
2.0.0.1  S
2.0.0.0  S
S: supported

Configuration

ghcman.yaml is a local configuration file. ghcman searches it in the current directory and its parents recursively until $Env:USERPROFILE or the root. A user global configuration file is $Env:APPDATA\ghcman\config.yaml, and a system global one is $Env:ProgramData\ghcman\config.yaml.

This is a sample of ghcman.yaml and config.yaml.

ghc:
  HEAD: somewhere\directory\which\contains\ghc
  fix-some-issue: other\directory

cabal:
  HEAD: somewhere\directory\which\contains\cabal

Write-GhcmanConfigTemplate function creates ghcman.yaml with the template.

When you want to check the loaded configuration, use Get-GhcmanConfig function.

You can set $Env:GhcmanInstall to specify a directory where GHCs and Cabals are installed. Its default is $Env:APPDATA\ghcman.

  • .\ghcman.yaml
    • local configuration
  • $Env:APPDATA\ghcman\config.yaml
    • user global configuration
  • $Env:ProgramData\ghcman\config.yaml
    • system global configuration
  • $Env:GhcmanInstall
    • installation directory
    • default: $Env:APPDATA\ghcman

Functions

  • Install-Ghc
    • Installs the specified GHC.
  • Uninstall-Ghc
    • Uninstalls the specified GHC.
  • Set-Ghc
    • Sets the version or variant of GHC to the Path environment variable of the current session.
  • Get-Ghc
    • Gets the GHCs which are specified by the ghcman.yaml and config.yaml, which is installed by the Ghcman and which is not yet installed.
  • Clear-Ghc
    • Removes all GHC values from the Path environment variable of the current session.
  • Install-Cabal
    • Installs the specified Cabal.
  • Uninstall-Cabal
    • Uninstalls the specified Cabal.
  • Set-Cabal
    • Sets the version or variant of Cabal to the Path environment variable of the current session.
  • Get-Cabal
    • Gets the Cabals which is specified by the ghcman.yaml and config.yaml, which is installed by the Ghcman and which is not yet installed.
  • Clear-Cabal
    • Removes all Cabal values from the Path environment variable of the current session.
  • Write-GhcmanConfigTemplate
    • Creates the ghcman.yaml with the default contents.
  • Get-GhcmanConfig
    • Gets the loaded configurations which are re-generated to YAML.
  • Update-GhcmanVersionFile
    • Download version data.

Note

Previously this was called “ghcups”.

ghcman's People

Contributors

gitter-badger avatar kakkun61 avatar spamviech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ghcman's Issues

Install Chocolatey

When choco is not found, attempt to install Chocolatey.

  1. choco does not exist in $Env:Path
  2. Ask to the user
  3. Check whether the current shell is the administrative PowerShell
  4. Tell to update $Env:Path of the current shell or to restart the shell

Show-Ghc only shows old ghc versions

Using Show-Ghc only displays old ghc-versions, even though a newer on (8.10.1) is already installed using chocolatey:

PS C:\WINDOWS\system32> Show-Ghc                                                                                        Chocolatey v0.10.15
ghc 8.0.1 [Approved] Downloads cached for licensed users
ghc 7.6.1.1 [Approved]
ghc 7.6.2.1 [Approved]
ghc 7.6.3.1 [Approved]
ghc 7.8.2.1 [Approved]
ghc 7.8.1.1 [Approved]
6 packages found.

Using choco search returns the current version

PS C:\WINDOWS\system32> choco search ghc                                                                                Chocolatey v0.10.15
ghc 8.10.1 [Approved]
haskell-dev 0.0.1 [Approved]
cabal 3.2.0.0 [Approved] Downloads cached for licensed users
haskell-stack 2.3.1 [Approved] Downloads cached for licensed users
idris 1.1.1 [Approved] Downloads cached for licensed users - Possibly broken for FOSS users (due to original download location changes by vendor)
5 packages found.

Running in an admin-PS session with german region and Beta-UTF8-support enabled.
Current Codepage is 65001 (UTF-8).

Install msys2?

For windows users, msys2 is needed when compiling packages like network. For this reason stack installs msys2 along ghc by extracting a tarball. Maybe it's a useful thing to do here too; there's also msys2 on chocolatey so that can be used if convenient.

The global configuration is not read when the local configuration exists

The expected algorithm

When Set-Ghc foo,

  1. get ghc.foo in the local configuration
  2. when the step 1 fails, get ghc.foo in the global configuration

The implemented algorithm

  1. when the local configuration exists,
    1. get ghc.foo in the local configuration
    2. when not found, fails in the result
  2. when the global configuration else exists,
    1. get ghc.foo in the global configuration

Update-GhcmanVersionFile : 404 Not Found

Describe the bug

When invoking Update-GhcmanVersionFile the following error is raised:

PS C:\> Update-GhcmanVersionFile
Invoke-WebRequest: 404: Not Found

I don't know much about PS but i think the [Version] "attribute" when setting the $ghcmanVersion is at fault here:

PS C:\> Set-Variable ghcmanVersion -Option Constant -Value [Version]"4.8"
PS C:\> $ghcmanVersion
[Version]4.8
PS C:\> Write-Output "https://raw.githubusercontent.com/kakkun61/ghcman/master/version.$ghcmanVersion.yaml"
https://raw.githubusercontent.com/kakkun61/ghcman/master/version.[Version]4.8.yaml
PS C:\> Invoke-WebRequest "https://raw.githubusercontent.com/kakkun61/ghcman/master/version.$ghcmanVersion.yaml"
Invoke-WebRequest: 404: Not Found

PS C:\>  Set-Variable ghcmanVersion -Option Constant -Value "4.8"
PS C:\> $ghcmanVersion
4.8
PS C:\> Invoke-WebRequest "https://raw.githubusercontent.com/kakkun61/ghcman/master/version.$ghcmanVersion.yaml"

StatusCode        : 200
StatusDescription : OK
Content           : ...

To Reproduce

Steps to reproduce the behavior:

Following the Readme:

  1. Run Cmdlet Import-Module ghcman
  2. Run Cmdlet Get-Module ghcman
  3. Run Cmdlet Update-GhcmanVersionFile
  4. See error 'Invoke-WebRequest: 404: Not Found`

Expected behavior

The cmdlet invocation to succeed and the versionfile to be updated.

Environment

  • OS: [e.g. Windows 10 19044]
  • PowerShell:
Name                           Value
----                           -----
PSVersion                      7.2.1
PSEdition                      Core
GitCommitId                    7.2.1
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
  • Version: 4.8

Install-Cabal appears to fail

Attempting to install cabal with something like Install-Cabal 3.2.0.0 appears to fail.

This appears to be due to a call to an undefined function Expand-Archive in ghcups.psm1 (line 502).

User global configuration

Now there are two configuration:

  • the local configuration ($PWD)
  • the system global configuration ($Env:ProgramData\ghcups like C:\ProgramData\ghcups)

Add:

  • the user global configuration ($Env:APPDATA\ghcups like C:\Users\kazukiokamoto\AppData\Roaming\ghcups)

Cannot install using install-module

When I try to install this, I get the following:

PS C:\WINDOWS\system32> install-module -Name ghcups

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you
want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y
PackageManagement\Install-Package : The module 'ghcups' cannot be installed or updated because it is not a properly-formed module.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : InvalidManifestModule,Test-ValidManifestModule,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Suport of PowerShell Desktop edition may be removed

I'm implementing tab key completion for ghcups. I am planning to remove support for PowerShell Desktop edition for simplicity of implementation of the completion.

If you use PowerShell Desktop edition and you cannot move to use PowerShell Core edition, please tell me the reason of it.

The reason and its quantity may make ghcups keep to support Desktop edition.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.