solana-labs / example-helloworld

Hello world on Solana
MIT License
902 stars 870 forks source link

Build Error on a Mac #12

Closed brianlong closed 4 years ago

brianlong commented 4 years ago

Hi,

I am currently working through the "example-helloworld" instructions on a Mac. I have been taking notes along the way and will submit a PR to enhance the README file when I am done.

I am currently stuck on npm run build:program. Here is the error:

 $ npm run build:program

> helloworld@0.0.1 build:program /Users/brianlong/Library/Mobile Documents/com~apple~CloudDocs/Projects/example-helloworld
> npm run clean:store && ./src/program/do.sh build

> helloworld@0.0.1 clean:store /Users/brianlong/Library/Mobile Documents/com~apple~CloudDocs/Projects/example-helloworld
> rm -rf store

Building /Users/brianlong/Projects/example-helloworld/src/program
+ cargo + install xargo
error: no such subcommand: `+`

    Did you mean `doc`?
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! helloworld@0.0.1 build:program: `npm run clean:store && ./src/program/do.sh build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the helloworld@0.0.1 build:program script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/brianlong/.npm/_logs/2020-04-10T19_23_38_809Z-debug.log

Suggestions? TIA!

brianlong commented 4 years ago

Related log file: 2020-04-10T19_23_38_809Z-debug.log

jackcmay commented 4 years ago

Hi @brianlong, thanks for the issue!

What version of cargo do you have?

This should fix it: https://github.com/solana-labs/solana/pull/9437

brianlong commented 4 years ago

Hi @jackcmay cargo 1.42.0

jackcmay commented 4 years ago

Strange, same version as me, wonder why I don't see it on my mac :-(

If you try that patch out let me know if it works for you

jackcmay commented 4 years ago

@brianlong btw, you can make that change in the helloworld project here: node_modules/@solana/web3.js/bpf-sdk/scripts/install.sh

brianlong commented 4 years ago

Thanks, @jackcmay. That help me get a little further down the road. After running npm run build:program, I now see:

warning: be sure to add `/Users/brianlong/.cargo/bin` to your PATH to be able to run the installed binaries
+ xargo --version
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! helloworld@0.0.1 build:program: `npm run clean:store && ./src/program/do.sh build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the helloworld@0.0.1 build:program script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/brianlong/.npm/_logs/2020-04-10T22_49_45_861Z-debug.log
brianlong commented 4 years ago

Here's that log: 2020-04-10T22_49_45_861Z-debug.log

brianlong commented 4 years ago

@jackcmay I just updated my Solana version to 1.0.15 and I am making progress. Stay tuned...

jackcmay commented 4 years ago

@brianlong Not Solana v1.1.2? Did it work for you in gitpod?

brianlong commented 4 years ago

@jackcmay The funny thing is that I updated my default Solana from 1.0.7 to 1.0.15 and then I could move past that error. Hidden dependency?

I do see 1.1.2 being downloaded via npm. Current status:

$ npm run start

> helloworld@0.0.1 start /Users/brianlong/Library/Mobile Documents/com~apple~CloudDocs/Projects/example-helloworld
> babel-node src/client/main.js

Let's say hello to a Solana account...
Connection to cluster established: http://localhost:8899 { 'solana-core': '1.1.2' }
[Error: ENOENT: no such file or directory, open 'src/program/target/bpfel-unknown-unknown/release/solana_bpf_helloworld.so'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: 'src/program/target/bpfel-unknown-unknown/release/solana_bpf_helloworld.so'
}

I don't see 'solana_bpf_helloworld.so' on my system.

brianlong commented 4 years ago

At the moment, port forwarding from Mac OS to the Docker is only for 8899. Should I add forwarding for 8900 & 9900?

brianlong commented 4 years ago

I went back to the beginning for a clean start and this is the current status:

$ npm run build:program

> helloworld@0.0.1 build:program /Users/brianlong/Library/Mobile Documents/com~apple~CloudDocs/Projects/example-helloworld
> npm run clean:store && ./src/program/do.sh build

> helloworld@0.0.1 clean:store /Users/brianlong/Library/Mobile Documents/com~apple~CloudDocs/Projects/example-helloworld
> rm -rf store

Building /Users/brianlong/Projects/example-helloworld/src/program
+ [[ -n '' ]]
+ cargo install xargo
    Updating crates.io index
     Ignored package `xargo v0.3.20` is already installed, use --force to override
warning: be sure to add `/Users/brianlong/.cargo/bin` to your PATH to be able to run the installed binaries
+ xargo --version
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! helloworld@0.0.1 build:program: `npm run clean:store && ./src/program/do.sh build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the helloworld@0.0.1 build:program script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/brianlong/.npm/_logs/2020-04-10T23_31_18_869Z-debug.log

FWIW, my installation notes are in this README: https://github.com/brianlong/example-helloworld/tree/202004-bl-changes

jackcmay commented 4 years ago

I haven't tried running the local net in virtialbox... Looks like you are getting a cargo error with paths? Is rust set up correctly on your machine?

brianlong commented 4 years ago

Hi, I used Mac Homebrew to install rust & docker. I made a little more progress and I now see some errors related to rustup. Are you using rustup? I think my next step is to uninstall rust & then install rustup.

brianlong commented 4 years ago

@jackcmay Good news! That worked.

I uninstalled rust and then installed rustup. (FWIW, I am an experienced Ruby developer, but this is my first time using Rust or Docker.) If you have a few minutes, please take a look at my proposed changes to the README: https://github.com/brianlong/example-helloworld/tree/202004-bl-changes

I have started a PR (still WIP) here: https://github.com/solana-labs/example-helloworld/pull/13 and I would like to get some feedback before I send that in for a merge.

Finally, your change above still needs to be merged in for this to work.

Thanks for your help!

brianlong commented 4 years ago

@jackcmay I have successfully run the hello world example on both Mac & Linux. I think we can close this issue. I will @ you on PR https://github.com/solana-labs/example-helloworld/pull/13 and ask for your help to review & merge that. Thanks for you help!

jackcmay commented 4 years ago

Great news @brianlong !

phenomax commented 4 years ago

Hi @jackcmay, sorry to revive this issue. I am experiencing similar building errors on OSX 10.15.2:

Running npm run build:program-c yields


0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/usr/local/Cellar/node/14.8.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'build:program-c'
1 verbose cli ]
2 info using npm@6.14.7
3 info using node@v14.8.0
4 verbose run-script [ 'prebuild:program-c', 'build:program-c', 'postbuild:program-c' ]
5 info lifecycle helloworld@0.0.1~prebuild:program-c: helloworld@0.0.1
6 info lifecycle helloworld@0.0.1~build:program-c: helloworld@0.0.1
7 verbose lifecycle helloworld@0.0.1~build:program-c: unsafe-perm in lifecycle true
8 verbose lifecycle helloworld@0.0.1~build:program-c: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/phenomax/projects/solana/example-helloworld/node_modules/.bin:/Users/phenomax/opt/anaconda3/bin:/Users/phenomax/opt/anaconda3/condabin:/Users/phenomax/.local/share/solana/install/active_release/bin:/usr/local/opt/php@7.2/sbin:/usr/local/opt/php@7.2/bin:/usr/local/opt/openssl/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/share/dotnet/dotnet:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/Library/TeX/texbin:/usr/local/MacGPG2/bin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Users/phenomax/projects/go/bin/Users/phenomax/.pyenv/shims:/Users/phenomax/.bashhub/bin
9 verbose lifecycle helloworld@0.0.1~build:program-c: CWD: /Users/phenomax/projects/solana/example-helloworld
10 silly lifecycle helloworld@0.0.1~build:program-c: Args: [
10 silly lifecycle   '-c',
10 silly lifecycle   'rm -f ./dist/program/helloworld.so && V=1 make -C ./src/program-c && npm run clean:store'
10 silly lifecycle ]
11 silly lifecycle helloworld@0.0.1~build:program-c: Returned: code: 2  signal: null
12 info lifecycle helloworld@0.0.1~build:program-c: Failed to exec build:program-c script
13 verbose stack Error: helloworld@0.0.1 build:program-c: `rm -f ./dist/program/helloworld.so && V=1 make -C ./src/program-c && npm run clean:store`
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:314:20)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:314:20)
13 verbose stack     at maybeClose (internal/child_process.js:1051:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
14 verbose pkgid helloworld@0.0.1
15 verbose cwd /Users/phenomax/projects/solana/example-helloworld
16 verbose Darwin 19.2.0
17 verbose argv "/usr/local/Cellar/node/14.8.0/bin/node" "/usr/local/bin/npm" "run" "build:program-c"
18 verbose node v14.8.0
19 verbose npm  v6.14.7
20 error code ELIFECYCLE
21 error errno 2
22 error helloworld@0.0.1 build:program-c: `rm -f ./dist/program/helloworld.so && V=1 make -C ./src/program-c && npm run clean:store`
22 error Exit status 2
23 error Failed at the helloworld@0.0.1 build:program-c script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

Versions

(base) ➜  example-helloworld git:(master) ✗ node --version
v14.8.0
(base) ➜  example-helloworld git:(master) ✗ npm --version
6.14.7
(base) ➜  example-helloworld git:(master) ✗ docker -v
Docker version 19.03.12, build 48a66213fe
(base) ➜  example-helloworld git:(master) ✗ wget --version
GNU Wget 1.20.3 built on darwin19.0.0.

-cares +digest -gpgme +https +ipv6 +iri +large-file -metalink +nls
+ntlm +opie -psl +ssl/openssl

Wgetrc:
    /usr/local/etc/wgetrc (system)
Locale:
    /usr/local/Cellar/wget/1.20.3_2/share/locale
Compile:
    clang -DHAVE_CONFIG_H -DSYSTEM_WGETRC="/usr/local/etc/wgetrc"
    -DLOCALEDIR="/usr/local/Cellar/wget/1.20.3_2/share/locale" -I.
    -I../lib -I../lib -I/usr/local/opt/openssl@1.1/include -DNDEBUG -g
    -O2
Link:
    clang -DNDEBUG -g -O2 -lidn2 -L/usr/local/opt/openssl@1.1/lib -lssl
    -lcrypto -ldl -lz ftp-opie.o openssl.o http-ntlm.o ../lib/libgnu.a
    -liconv -lintl -Wl,-framework -Wl,CoreFoundation -lunistring

Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://www.gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Originally written by Hrvoje Niksic <hniksic@xemacs.org>.
Please send bug reports and questions to <bug-wget@gnu.org>.
(base) ➜  example-helloworld git:(master) ✗ rustc --version
rustc 1.45.2
(base) ➜  example-helloworld git:(master) ✗ cargo --version
cargo 1.45.1