ghcup-hs
ghcup-hs copied to clipboard
Enhancement: add proxy names redirection for `ghcup` executable
ghcup
to Haskell is similar to rustup
to Rust.
Have a look on https://rust-lang.github.io/rustup/concepts/proxies.html, It would nice to bring this feature in ghcup
.
When create a symlink to ghcup
executable with a different name for example ghc
or stack
or cabal
, it will automatically redirect the command and arguments to its default related tools.
This would make it much easier for Linux distro maintainer to use ghcup
replace all the traditional haskell related toolchain.
This is rather easy with e.g. ghcup run --ghc recommended -- ghc "$@"
.
However, there's a complication on windows:
- symlinks are not enabled on all systems
- windows doesn't seem to have a proper
exec
function that stops the current process and lets the child process take fully over (at least not in process package)? That means it's subtly different from invoking ghc directly
@hasufell ,
The problem of why not using ghcup run --ghc recommended -- ghc "$@"
as shell script is:
If the shell script which is installed as /usr/bin/ghc
. Then it will fall into infinite shell recursion.
Because /usr/bin
is also a path where ghcup
search paths.
I don't see why that would be the case. The new ghc
binary location is prepended to PATH and the shell picks the first occurence.
[hasufell@localhost:~]
$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin
[hasufell@localhost:~]
$ cat /usr/bin/ghc
#!/bin/sh
$HOME/.ghcup/bin/ghcup run --ghc recommended -- ghc "$@"
[hasufell@localhost:~]
$ which ghc
/usr/bin/ghc
[hasufell@localhost:~]
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.4.8
@hasufell , as a packager, I want to make ghcup a system package.
Modifying user's .bashrc
or .bash_profile
is definitely not a good practice.
Want to just add new files in system-level instead of modifying any file or do options on user home directory.
Because for multiple users system, when new user added, the effect do against old user will not apply to new user.
Add name proxies for ghcup
executable will make thing a lot easier. Hope you can understand.
@evan0greenup you can already do what you want with shell wrappers. See ghcup run --help
.
Note that you'll have to make a choice whether those shell wrappers should install the tool when it's missing, which can affect the first invocation and trigger a metadata download (see ghcup run --install
).
I'd keep it off and print more verbose instructions.