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

Enhancement: add proxy names redirection for ghcup executable #1002

Open
evan0greenup opened this issue Feb 16, 2024 · 6 comments
Open

Enhancement: add proxy names redirection for ghcup executable #1002

evan0greenup opened this issue Feb 16, 2024 · 6 comments

Comments

@evan0greenup
Copy link

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.

@hasufell
Copy link
Member

This is rather easy with e.g. ghcup run --ghc recommended -- ghc "$@".

However, there's a complication on windows:

  1. symlinks are not enabled on all systems
  2. 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

@evan0greenup
Copy link
Author

@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.

@hasufell
Copy link
Member

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
Copy link
Member

[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

@evan0greenup
Copy link
Author

@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.

@hasufell
Copy link
Member

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants