microsoft / pxt-microbit

A Blocks / JavaScript code editor for the micro:bit built on Microsoft MakeCode
https://makecode.microbit.org
Other
721 stars 593 forks source link

pxt-cli command line issues #4932

Closed adamish closed 1 year ago

adamish commented 1 year ago

https://makecode.com/cli provides documentation of how to build locally, however this appears to now be outdated. There are a number of pitfalls and finding information on this topic is difficult.

To Reproduce 1) Run pxt build 2) Run pxt localbuild (this is documented on https://makecode.com/cli/build) 3) Run pxt build --local

Expected behaviour A successful build

Actual behaviour 1)

build failed

/usr/local/lib/python2.7/dist-packages/jwt/utils.py:8: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.

  from cryptography.hazmat.primitives.asymmetric.utils import (

info: get versions for bbc-microbit-classic-gcc

error: 403 {"documentation_url": "https://docs.github.com/rest/reference/repos#get-a-repository", "message": "`lancaster-university` forbids access via a personal access token (classic). Please use a GitHub App, OAuth App, or a personal access token with fine-grained permissions."}

TypeError: Cannot read property 'length' of null

    at compressHex (/home/adam/git/sam/node_modules/pxt-core/built/pxt.js:103756:37)

2) Command 'localbuild' not found -

3) Fails with errors warning: connection error: bad handshake: Error([('SSL routines', 'SSL3_GET_SERVER_CERTIFICATE', 'certificate verify failed')],), retrying.

Analysis of above 1) Some kind of login is required, but this is not documented how 2) This appears to have been changed to build --local, however documentation at https://makecode.com/cli/build still states localbuild 3) Appears that underlying yotta registry has been deprecated (https://support.microbit.org/support/solutions/articles/19000123284-arm-yotta-registry-deprecation) but the docker image is still trying to use it?

micro:bit version (please complete the following information):

Version 2

Desktop (please complete the following information):

microbit-carlos commented 1 year ago

Are you adding a GitHub token via config, env variables or any other method?

`lancaster-university` forbids access via a personal access token (classic). Please use a GitHub App, OAuth App, or a personal access token with fine-grained permissions."}

That suggest a "normal" PAT was used and the Lancaster GitHub org rejected it.

I had a similar error in the opposite direction last week, when I added a GitHub personal fined-grain access token it complained I could not use that. Changing it to use the older "standard" PAT seemed to work. Weird.

@JohnVidler we are seeing more GH PAT weirdness with the Lancaster org, was something changed this week?

adamish commented 1 year ago

A bit more information...

1) I've since discovered that yotta uses environment variable YOTTA_GITHUB_AUTHTOKEN. I was incorrectly using gh auth login

2) pxt target microbit defaults to 4.0.24 (this is the latest on npm registry)

I've tried npm install pxt-microbit@5.0.12 however this removes node_modules/pxtcli.json which means you need to run pxt target microbit again

So in summary the following is a recipe that works for me - from a clean repo

export YOTTA_GITHUB_AUTHTOKEN="my token..."
export PXT_NODOCKER=1

npm install pxt-microbit@5.0.12
pxt target microbit
pxt install
pxt build --local
adamish commented 1 year ago

Issue caused by default 4.0.24. workound in comments