Shopify / tapioca

The swiss army knife of RBI generation
MIT License
720 stars 120 forks source link

Allow user to override raw github sources #1992

Open glyh opened 3 weeks ago

glyh commented 3 weeks ago

As title, access to raw.githubusercontent.com is an issue for Chinese users, and when running bundle exec tapioca init, I got the following:

$ bundle exec tapioca init
   identical  sorbet/config
   identical  sorbet/tapioca/config.yml
   identical  sorbet/tapioca/require.rb
       force  bin/tapioca
Retrieving index from central repository... 
Can't fetch file `index.json` from https://raw.githubusercontent.com/Shopify/rbi-central/main (Failed to open TCP connection to raw.githubusercontent.com:443 (Connection refused - connect(2) for "raw.githubusercontent.com" port 443))

Tapioca can't access the annotations at https://raw.githubusercontent.com/Shopify/rbi-central/main.

Are you trying to access a private repository?
If so, please specify your Github credentials in your ~/.netrc file or by specifying the --auth option.

See https://github.com/Shopify/tapioca#using-a-netrc-file for more details.
Can't fetch annotations without sources (no index fetched)
glyh commented 3 weeks ago

Okay I figure it out:

bundle exec tapioca configure
bundle exec tapioca annotations --sources https://raw.kkgithub.com/Shopify/rbi-central/main
bundle exec tapioca gem
glyh commented 3 weeks ago

I think we'd better have a way to configure the raw sources from the init command, the above fix seems hacky.

glyh commented 3 weeks ago

Looks like there's just no way I can get it work as I don't have srb exectuable. Having a system proxy also won't make it work, as I still get the SSL error from the proxy. No clue.

amomchilov commented 2 weeks ago

Hey @glyh

This isn't something we have capacity to tackle at the moment, but this looks like a really good "first issue" for community contribution, if that's something you'd be interested in.

Some thoughts:

  1. We wouldn't want to add configuration flags to tapioca init. After all, users are just getting started with Tapioca, we'd be making a bad first impression if we require them to dive into man pages right from square 1.
  2. It sounds reasonable to me that tapioca init should try to fetch annotations from the default source, but not "give up completely" if it can't connect.
  3. Instead, it'd be nice if it just said something along the lines of:

    $ bundle exec tapioca init
    identical  sorbet/config
    identical  sorbet/tapioca/config.yml
    identical  sorbet/tapioca/require.rb
        force  bin/tapioca
    Retrieving index from central repository... 
    Can't fetch file `index.json` from https://raw.githubusercontent.com/Shopify/rbi-central/main (Failed to open TCP connection to raw.githubusercontent.com:443 (Connection refused - connect(2) for "raw.githubusercontent.com" port 443))
    
    Tapioca can't access the annotations at https://raw.githubusercontent.com/Shopify/rbi-central/main.
    
    Here are some things you can try:
        1. Check that your internet connection is online.
    
        2. Are trying to access a private repository?
           If so, please specify your Github credentials in your ~/.netrc file or by specifying the --auth option.
    
        3. Is GitHub available in your region?
    
           If not, you'll need to use an alternative source for RBI annotations.
           You can rerun this with:
    
           bundle exec tapioca annotations --sources https://example.com/your/source/here
    
    <... continue on with the rest of the init command>
glyh commented 2 weeks ago

I already said the hack I gave above won't fix this issue.