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

Warns users about non-ghcup channels #1230

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

qxrein
Copy link

@qxrein qxrein commented Feb 21, 2025

RESOLVES: #1225
example output

~: cabal run ghcup -- debug-info
Configuration is affected by the following files:
- cabal.project
[ Info  ] downloading: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.9.yaml as file /home/qxrein/.ghcup/cache/ghcup-0.0.9.yaml
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--  0     0    0     0    0     0      0      0 --:--:-- --:--  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
[ Warn  ] Warning: The channel DefaultChannel uses a non-ghcup URL: URI {uriScheme = Scheme {schemeBS = "https"}, uriAuthority = Just (Authority {authorityUserInfo = Nothing, authorityHost = Host {hostBS = "raw.githubusercontent.com"}, authorityPort = Nothing}), uriPath = "/haskell/ghcup-metadata/master/ghcup-0.0.9.yaml", uriQuery = Query {queryPairs = []}, uriFragment = Nothing}
[ Warn  ] Warning: The channel StackChannel uses a non-ghcup URL: URI {uriScheme = Scheme {schemeBS = "https"}, uriAuthority = Just (Authority {authorityUserInfo = Nothing, authorityHost = Host {hostBS = "raw.githubusercontent.com"}, authorityPort = Nothing}), uriPath = "/commercialhaskell/stackage-content/master/stack/stack-setup-2.yaml", uriQuery = Query {queryPairs = []}, uriFragment = Nothing}
[ Warn  ] Warning: The channel CrossChannel uses a non-ghcup URL: URI {uriScheme = Scheme {schemeBS = "https"}, uriAuthority = Just (Authority {authorityUserInfo = Nothing, authorityHost = Host {hostBS = "raw.githubusercontent.com"}, authorityPort = Nothing}), uriPath = "/haskell/ghcup-metadata/master/ghcup-cross-0.0.9.yaml", uriQuery = Query {queryPairs = []}, uriFragment = Nothing}
[ Warn  ] Warning: The channel PrereleasesChannel uses a non-ghcup URL: URI {uriScheme = Scheme {schemeBS = "https"}, uriAuthority = Just (Authority {authorityUserInfo = Nothing, authorityHost = Host {hostBS = "raw.githubusercontent.com"}, authorityPort = Nothing}), uriPath = "/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.9.yaml", uriQuery = Query {queryPairs = []}, uriFragment = Nothing}
[ Warn  ] Warning: The channel VanillaChannel uses a non-ghcup URL: URI {uriScheme = Scheme {schemeBS = "https"}, uriAuthority = Just (Authority {authorityUserInfo = Nothing, authorityHost = Host {hostBS = "raw.githubusercontent.com"}, authorityPort = Nothing}), uriPath = "/haskell/ghcup-metadata/master/ghcup-vanilla-0.0.9.yaml", uriQuery = Query {queryPairs = []}, uriFragment = Nothing}
===== Main ======
Architecture:  x86_64
Platform:      Linux UnknownLinux, 25.05
GHCup Version: v0.1.40.0-49-gc07d28ea

===== Directories ======
base:    /home/qxrein/.ghcup
bin:     /home/qxrein/.ghcup/bin
GHCs:    /home/qxrein/.ghcup/ghc
cache:   /home/qxrein/.ghcup/cache
logs:    /home/qxrein/.ghcup/logs
config:  /home/qxrein/.ghcup
db:      /home/qxrein/.ghcup/db
temp:    /home/qxrein/.ghcup/tmp

===== Metadata ======
default:     https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.9.yaml
stack:       https://raw.githubusercontent.com/commercialhaskell/stackage-content/master/stack/stack-setup-2.yaml
cross:       https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-cross-0.0.9.yaml
prereleases: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.9.yaml
vanilla:     https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-vanilla-0.0.9.yaml

@dfordivam
Copy link
Collaborator

@qxrein Thanks for the PR!
But I am afraid the solution implemented is not correct.
The urls being used by the ghcup via channelURL are in fact all official ghcup channels (they are hosted at haskell/ghcup-metadata repo)

In addition to using these official channels, the user could also provide (via ghcup config or command line options) a path to metadata file which does not have the "https://raw.githubusercontent.com/haskell/ghcup-metadata/" prefix. in this scenario we should warn users.

Also you may want to join the matrix chat (https://matrix.to/#/#ghcup:matrix.org) for more casual discussions on ghcup related dev

@qxrein
Copy link
Author

qxrein commented Feb 22, 2025

ok

@qxrein
Copy link
Author

qxrein commented Feb 22, 2025

this is working after introducing a random temporary channel to lib/GHCup/Version.hs.

~: cabal run ghcup -- debug-info
Configuration is affected by the following files:
- cabal.project
[ Warn  ] Warning: The channel StackChannel uses a non-official URL: https://raw.githubusercontent.com/commercialhaskell/stackage-content/master/stack/stack-setup-2.yaml
[ Warn  ] Warning: The channel TemporaryChannel uses a non-official URL: https://qxrein.com/custom-metadata/temporary.yaml
===== Main ======
Architecture:  x86_64
Platform:      Linux UnknownLinux, 25.05
GHCup Version: v0.1.40.0-50-g105f4be9

===== Directories ======
base:    /home/qxrein/.ghcup
bin:     /home/qxrein/.ghcup/bin
GHCs:    /home/qxrein/.ghcup/ghc
cache:   /home/qxrein/.ghcup/cache
logs:    /home/qxrein/.ghcup/logs
config:  /home/qxrein/.ghcup
db:      /home/qxrein/.ghcup/db
temp:    /home/qxrein/.ghcup/tmp

===== Metadata ======
default:     https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-0.0.9.yaml
stack:       https://raw.githubusercontent.com/commercialhaskell/stackage-content/master/stack/stack-setup-2.yaml
cross:       https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-cross-0.0.9.yaml
prereleases: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.9.yaml
vanilla:     https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-vanilla-0.0.9.yaml
temporary:   https://qxrein.com/custom-metadata/temporary.yaml

Copy link
Collaborator

@dfordivam dfordivam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few changes necessary, and please remove the code which is not used anywhere

@qxrein qxrein force-pushed the patch-1 branch 2 times, most recently from 226fc87 to 0928e45 Compare March 2, 2025 21:13
@qxrein qxrein requested a review from dfordivam March 2, 2025 21:17
not (any (`isPrefixOf` url) officialPrefixes) ||
url == "https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml") $
logWarn $ "The URL " <> T.pack url <> " is not an official GHCup metadata source and may not be maintained or QA'd by GHCup."
when (not (isOfficialURI uri) || isNightliesURI uri) $
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. we do not want to emit a warning every time a download is issued... instead we want to emit a warning if a user adds a new channel (either via ghcup config add-release-channel or ghcup config set url-source)
  2. nightlies are no exception... they are not maintained by GHCup, so we want to warn

, "https://mirror.sjtu.edu.cn/ghcup/yaml/haskell/ghcup-metadata/"
]
-- | Logic to check if it is an Official Channel
isOfficialURI :: URI -> Bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will trigger on file:// URLs... which we don't want.

@qxrein qxrein force-pushed the patch-1 branch 2 times, most recently from bd8b777 to 11e12c4 Compare March 3, 2025 14:49
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

Successfully merging this pull request may close these issues.

Warn users about non-ghcup channels
3 participants