algo-builder icon indicating copy to clipboard operation
algo-builder copied to clipboard

Unable to compile contracts on Windows machine

Open afcharliekong opened this issue 3 years ago • 11 comments

Describe the bug

I'm facing a couple of issues when using Algo Builder to compile contracts on windows machine. I've attached the screenshots as shown below.

  1. This occurs because the framework uses python3 command to compile the contracts. I'm currently using anaconda python virtual environment on Windows 10. It uses python instead. Screenshot 2022-05-20 at 6 37 28 PM

  2. This occurs after I've updated the file in node_modules/@algo-builder/runtime/build/lib/pycompile-op.js to use python instead of python3. Screenshot 2022-05-20 at 6 40 20 PM

I believe issue 2 is because of the different error numbers used by nodeJS for mac and windows machines. I had to replace the e?.errno === -2 with e?.errno === -4058 on line number 103 so that framework can detect missing generated yaml files and continue the process of compilation. The file is located in /node_modules/@algo-builder/algob/build/lib/compile.js

Possible Solution

  1. Not sure if there's a way to try running the compilation with python3 or python or py.
  2. Maybe we can detect the OS and dynamically change the error number detection accordingly?

Steps to Reproduce

  1. Run yarn run algob compile on a new Algo Builder project on Windows 10.

Environment

  • OS: Windows 10, Windows 11
  • Node.js version: v16.15.0
  • algob version: 3.2.0
  • Python: 3.9.12 (using anaconda)

afcharliekong avatar May 20 '22 11:05 afcharliekong

Thank @afcharliekong for report the issue! Could you share your source code?

vuvoth avatar May 20 '22 11:05 vuvoth

I also recommend use window WSL when work with algob.

vuvoth avatar May 20 '22 11:05 vuvoth

Hi @vuvoth, I've attached the source code of a new Algo Builder project with the changes made in these files,

node_modules/@algo-builder/runtime/build/lib/pycompile-op.js (lines 85, 89) node_modules/@algo-builder/algob/build/lib/compile.js (lines 103)

Hope it helps.

I had windows WSL installed as well when this compilation issue occured.

algo-builder.zip

afcharliekong avatar May 20 '22 16:05 afcharliekong

I had windows WSL installed as well when this compilation issue occured.

Did you install pyteal and pyyaml before run compile, @afcharliekong ?

I had to replace the e?.errno === -2 with e?.errno === -4058 on line number 103 so that framework can detect missing generated yaml files and continue the process of compilation.

Let change it back to default value.

vuvoth avatar May 20 '22 17:05 vuvoth

Hey @vuvoth, I did have pyteal and pyyaml installed. Did a pip list to verify this.

Screenshot 2022-05-21 at 12 49 48 PM

afcharliekong avatar May 21 '22 04:05 afcharliekong

What's your python version (when you run python)? It must be 3.9 or later , latest PyTEAL supports only Python 3.10 in fact, which will be required in our upcoming release (algo-builder v4.0).

robert-zaremba avatar May 24 '22 08:05 robert-zaremba

I'm running python version 3.9.12 on my anaconda virtual environment.

image

afcharliekong avatar May 24 '22 09:05 afcharliekong

Could you try to use Pipenv? https://algobuilder.dev/guide/README#pyteal

BTW, we have just released Algo Builder v4.0. It requires Python 3.10 (this is due to PyTEAL - it's latest release requires Python 3.10).

robert-zaremba avatar May 24 '22 13:05 robert-zaremba

Hey @robert-zaremba,

I've switched to Python 3.10 python310

Also using Pipenv and these are the packages installed based on the Pipfile in the repo, pip-packages

Tried to setup a clean installation using v4.0 algobuilder4

And there's a new error instead =( js-error

afcharliekong avatar May 25 '22 04:05 afcharliekong

hmm, could be related to Node... What is your version of Node.js? node --version? We require v16 or later.

robert-zaremba avatar May 27 '22 03:05 robert-zaremba

I'm using node v16.15.0

node

afcharliekong avatar May 27 '22 08:05 afcharliekong