SAFE Drive - OSX

Hi there,
trying to help @happybeing building SAFE Drive for mac.
Note: very basic knowledge here…but trying my best

Starting with the SAFE Desktop App tutorial at https://hub.safedev.org/platform/nodejs/
got stuck at installation of the safe-node-app package, at the command:

NODE_ENV=dev npm install @maidsafe/safe-node-app --save

log at https://www.dropbox.com/s/ja2aq7kyhjyllxk/2018-10-02T13_41_15_321Z-debug.log?dl=0
Using homebrew, not sure that’s the right way…

any idea on how to progress?

5 Likes

Skimming through the log it seems the error is about node-gyp. I don’t see what exactly is going wrong there, though there are requirements for node-gyp on MacOS (
GitHub - nodejs/node-gyp: Node.js native addon build tool):

  • python ( v2.7 recommended, v3.x.x is not supported) (already installed on macOS)
  • Xcode
    • You also need to install the Command Line Tools via Xcode. You can find this under the menu Xcode -> Preferences -> Locations (or by running xcode-select --install in your Terminal)
      • This step will install gcc and the related toolchain containing make

I thought I’ve seen a few developers on MacOS already on this forum. There might be some other issue that I’m not aware of.

4 Likes

@Stout77 That’s great that you are diving in to help happybeing.

This is a nice error to start with to bootstrap the education process.
The following details are meant for you, and whomever searches for this problem, to better understand the library and why this error might occur, so please excuse if you know all of this:

@maidsafe/safe-node-app depends on compiled binaries, providing operations written in a lower level client library. Also here.

Those binaries expose operations in a common C ABI convention.
Node requires native modules to be able to consume those exposed operations and it needs to be able to rebuild those native modules, depending on some local variables such as your version of NodeJS and electron, if using electron.

In your logs you’ll see that a child process was attempted to run node-gyp, a tool used to rebuild native modules, which resulted in the vague ELIFECYCLE error.

What you need are the build tools for node-gyp to utilize, as @bzee has pointed out.
Check for Xcode and install if not on your system.

7 Likes

@DGeddes The NodeJs tutorial lacks this - prerequisites for Mac OSX

5 Likes

I’ll get that added in to the thing.

DG

Edit: made the change - got a couple of other commits in the pipeline so I’ll juggle them around and get this one in there first I think.

2 Likes

thank you all for the input; after installing xcode and CLI tools, still same error I’m afraid (log https://www.dropbox.com/s/txcy2dh9shfgliv/2018-10-03T08_53_57_806Z-debug.log?dl=0)
I’m slightly stuck…

thinking my node.js installation might be the culprit.
Installed with homebrew
brew install node.js

1 Like

ok, worked uninstalling homebrew node.js version and installing node 8.12.
I’ll post progress later

1 Like

ok node 8.12 did the trick
after completing tutorial part (code excluded…) and getting into building safenetwork-fuse from source, got stuck at

Build for live network

unset NODE_ENV
npm run build

returning

safenetwork-fuse@0.1.0 build: `mkdir -p ./dist/prod/node_modules/@maidsafe/safe-node-app/src/native/prod/ && cp -R node_modules/@maidsafe/safe-node-app/src/native/prod/*.* ./dist/prod/node_modules/@maidsafe/safe-node-app/src/native/prod/ && pkg . -t host -o ./dist/prod/mount-safe`

npm ERR! Exit status 2

ideas?

pkg must be the problem, right?

It might be pkg - maybe not finding it. Not a very helpful error is it! :slight_smile:

Just to be sure, you’ve done the following yes?

git clone https://github.com/theWebalyst/safenetworkjs
cd safenetworkjs
npm install
npm link

git clone https://github.com/theWebalyst/safenetwork-fuse
cd safenetwork-fuse
NODE_ENV=dev npm install
npm link safenetworkjs

sudo apt-get install libfuse-dev libfuse2 xdg-utils

And no obvious errors?

And you are at ‘Build for live network’

Does that mean you’ve also done the steps above (ie under ‘Build for mock network’)?

I’m thinking not so want to check exactly what you have done so far. Cheers.

Also, as I pushed stuff to master last night, please can you go into your safenetwork-fuse folder and type git log and copy the first few lines here, something link this:

commit 4d6e464bead3c0011d349ed7d6a65643d2cb6601 (HEAD -> dev-savefile, origin/dev-savefile)
Author: theWebalyst <github@happybeing.com>
Date:   Tue Oct 2 18:19:27 2018 +0100

ok, starting from the bottom:

commit 189eb1929415f0b3511bd22738e2f26c9fdebdaa (HEAD -> master, origin/master, origin/dev-safenodeapp-v8, origin/HEAD)
Merge: a160858 5452fca
Author: theWebalyst <github@happybeing.com>
Date:   Mon Oct 1 20:57:47 2018 +0100

back to the top, yes here are the (crude) steps done…apologies for the …hm…formatting:

MacBook-Pro-2:~ Home$ brew install git

brew install node.js

note, installing node.js through homebrew turned out to be a bad move, so scraping last passage, but I’ll leave it there to show the sequence

$ mkdir safe_example

$ cd safe_example/
$ git clone https://github.com/maidsafe/safe_examples safe_examples

And then install its dependencies:

$ cd safe_examples/safe_app_electron_quick_start
$ npm install

electron installed and

$ npm start

shows the app as … expected

next step made me (and a few more…thanks @bzee @hunterlester) realise I might need xcode…so

install xcode from store
open xcode (installs components) from store

plus, node installed with homebrew…bad idea; so:

Node.js — Download

much better, node 8.12 installed

$ NODE_ENV=dev npm install @maidsafe/safe-node-app --save

installs ok
(when I say ok, still a few warnings like warning: arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension [-Wnull-pointer-arithmetic] - me ignoring)

that’s where I stop with the tutorial…
back to safe-network-fuse
sounds like I need yarn

MacBook-Pro-2:safenetworkjs Home$ brew install yarn

and then we’re flying:

git clone https://github.com/theWebalyst/safenetworkjs
cd safenetworkjs
npm install
npm link

git clone https://github.com/theWebalyst/safenetwork-fuse
cd safenetwork-fuse
NODE_ENV=dev npm install
npm link safenetworkjs

now, libfuse :thinking:

https://github.com/osxfuse/osxfuse/releases

why not

and then that’s where I jumped to ‘Build for live network’…
(and yes, you’re right, I did that…)

I’m not sure from this if you’ve installed OSXfuse? But indeed you should so we need to add the following to the README.md (from fuse-bindings requirements):

   - if you use Brew, install OSXFuse and brew install pkg-config
   - if you use MacPorts, sudo port install osxfuse +devel

I’ll follow up further later. :slight_smile:

1 Like

I have fixed some things I broke and created a new git branch to us to work on for Mac OSX, so to update your source code please do the following.

I’m not a git expert but have tested this so it should work (famous last words).

In your safenetwork-fuse directory:

  1. git status will list where you are to see if you have changed any files (these will appear in red). If there are any red files, don’t proceed, but give me a listing (or you could move them somewhere else and move them back at the end).

  2. Now type:

git pull
git fetch --all
git checkout dev-macosx
git checkout .

If you do git status now you should see that you are on branch dev-macosx and I can easily switch to the same code as you in case of problems.

After doing the above, change to your safenetworkjs directory and repeat exactly the same steps.

This is just so you are working with code I can easily look at too, and code I think should work ok for listing and reading files on SAFE.

1 Like

in safenetwork-fuse all good I think:

MacBook-Pro-2:safenetwork-fuse Home$ git status

On branch master

Your branch is up to date with 'origin/master'.

Untracked files:

(use "git add &lt;file&gt;..." to include in what will be committed)

.DS_Store

nothing added to commit but untracked files present (use "git add" to track)

MacBook-Pro-2:safenetwork-fuse Home$ git pull

remote: Enumerating objects: 24, done.

remote: Counting objects: 100% (24/24), done.

remote: Compressing objects: 100% (13/13), done.

remote: Total 24 (delta 11), reused 24 (delta 11), pack-reused 0

Unpacking objects: 100% (24/24), done.

From https://github.com/theWebalyst/safenetwork-fuse

 * [new branch] dev-macosx -&gt; origin/dev-macosx

 * [new branch] dev-savefile -&gt; origin/dev-savefile

f9427b9..3e99ab9 development -&gt; origin/development

Already up to date.

MacBook-Pro-2:safenetwork-fuse Home$ git fetch --all

Fetching origin

MacBook-Pro-2:safenetwork-fuse Home$ git checkout dev-macosx

Branch 'dev-macosx' set up to track remote branch 'dev-macosx' from 'origin'.

Switched to a new branch 'dev-macosx'

MacBook-Pro-2:safenetwork-fuse Home$ git checkout

Your branch is up to date with 'origin/dev-macosx'.

MacBook-Pro-2:safenetwork-fuse Home$ git status

On branch dev-macosx

Your branch is up to date with 'origin/dev-macosx'.

Untracked files:

(use "git add &lt;file&gt;..." to include in what will be committed)

.DS_Store

nothing added to commit but untracked files present (use "git add" to track)

In safenetworkjs I get:

modified: package-lock.json

Yep, that looks good.

No need to worry about that (it will have been updated automatically) so in safenetworkjs:

git checkout package-lock.json

Then git status should be clear and you can proceed.

BTW how are you finding this, not regretting it I hope? :slightly_smiling_face:

not regretting at all…happy to finally be able to (maybe?) help the SAFE community somehow…

so the update is, after the above, npm run build proceeds but with the following errors:

MacBook-Pro-2:safenetwork-fuse Home$ npm run build

&gt; safenetwork-fuse@0.1.0 build /Users/Home/safenetworkjs/safenetwork-fuse

&gt; mkdir -p ./dist/prod/node_modules/@maidsafe/safe-node-app/src/native/prod/ &amp;&amp; cp -R node_modules/@maidsafe/safe-node-app/src/native/prod/*.* ./dist/prod/node_modules/@maidsafe/safe-node-app/src/native/prod/ &amp;&amp; pkg . -t host -o ./dist/prod/mount-safe

&gt; pkg@4.3.4

&gt; Warning Cannot include addon %1 into executable.

The addon must be distributed with executable as %2.

/Users/Home/safenetworkjs/safenetwork-fuse/node_modules/fuse-bindings/prebuilds/linux-x64/electron-47.node

path-to-executable/electron-47.node

&gt; Warning Cannot include addon %1 into executable.

The addon must be distributed with executable as %2.

/Users/Home/safenetworkjs/safenetwork-fuse/node_modules/fuse-bindings/prebuilds/linux-x64/electron-48.node

path-to-executable/electron-48.node

&gt; Warning Cannot include addon %1 into executable.

The addon must be distributed with executable as %2.

/Users/Home/safenetworkjs/safenetwork-fuse/node_modules/fuse-bindings/prebuilds/linux-x64/electron-49.node

path-to-executable/electron-49.node

&gt; Warning Cannot include addon %1 into executable.

The addon must be distributed with executable as %2.

/Users/Home/safenetworkjs/safenetwork-fuse/node_modules/fuse-bindings/prebuilds/linux-x64/electron-50.node

path-to-executable/electron-50.node

&gt; Warning Cannot include addon %1 into executable.

The addon must be distributed with executable as %2.

/Users/Home/safenetworkjs/safenetwork-fuse/node_modules/fuse-bindings/prebuilds/linux-x64/electron-51.node

path-to-executable/electron-51.node

&gt; Warning Cannot include addon %1 into executable.

The addon must be distributed with executable as %2.

/Users/Home/safenetworkjs/safenetwork-fuse/node_modules/fuse-bindings/prebuilds/linux-x64/electron-53.node

path-to-executable/electron-53.node

&gt; Warning Cannot include addon %1 into executable.

The addon must be distributed with executable as %2.

/Users/Home/safenetworkjs/safenetwork-fuse/node_modules/fuse-bindings/prebuilds/linux-x64/electron-54.node

path-to-executable/electron-54.node

&gt; Warning Cannot include addon %1 into executable.

The addon must be distributed with executable as %2.

/Users/Home/safenetworkjs/safenetwork-fuse/node_modules/fuse-bindings/prebuilds/linux-x64/electron-57.node

path-to-executable/electron-57.node

&gt; Warning Cannot include addon %1 into executable.

The addon must be distributed with executable as %2.

/Users/Home/safenetworkjs/safenetwork-fuse/node_modules/fuse-bindings/prebuilds/linux-x64/node-46.node

path-to-executable/node-46.node

&gt; Warning Cannot include addon %1 into executable.

The addon must be distributed with executable as %2.

/Users/Home/safenetworkjs/safenetwork-fuse/node_modules/fuse-bindings/prebuilds/linux-x64/node-47.node

path-to-executable/node-47.node

&gt; Warning Cannot include addon %1 into executable.

The addon must be distributed with executable as %2.

/Users/Home/safenetworkjs/safenetwork-fuse/node_modules/fuse-bindings/prebuilds/linux-x64/node-48.node

path-to-executable/node-48.node

&gt; Warning Cannot include addon %1 into executable.

The addon must be distributed with executable as %2.

/Users/Home/safenetworkjs/safenetwork-fuse/node_modules/fuse-bindings/prebuilds/linux-x64/node-51.node

path-to-executable/node-51.node

&gt; Warning Cannot include addon %1 into executable.

The addon must be distributed with executable as %2.

/Users/Home/safenetworkjs/safenetwork-fuse/node_modules/fuse-bindings/prebuilds/linux-x64/node-57.node

path-to-executable/node-57.node

&gt; Warning Failed to make bytecode node8-x64 for file /snapshot/safenetwork-fuse/node_modules/borc/src/decoder.asm.js

and

./dist/prod/mount-safe

returns

pkg/prelude/bootstrap.js:1176
     throw error;
     ^

Error: No native build was found for runtime=node abi=57 platform=darwin arch=x64
   at Function.load.path (/snapshot/safenetwork-fuse/node_modules/node-gyp-build/index.js:31:9)
   at load (/snapshot/safenetwork-fuse/node_modules/node-gyp-build/index.js:13:23)
   at Object.<anonymous> (/snapshot/safenetwork-fuse/node_modules/fuse-bindings/index.js:1:99)
   at Module._compile (pkg/prelude/bootstrap.js:1252:22)
   at Object.Module._extensions..js (module.js:661:10)
   at Module.load (module.js:563:32)
   at tryModuleLoad (module.js:503:12)
   at Function.Module._load (module.js:495:3)
   at Module.require (module.js:594:17)
   at Module.require (pkg/prelude/bootstrap.js:1157:31)

This good, and I’m glad you are sticking with it and yes, you are helping a lot. :slight_smile:

The first bunch of warnings are just warnings. The second shows you have reached the same point as @lukas who is trying to get this built for Windows. Here is his report, which has the same error as you, and see my reply immediately below his post:

If you can make sense of that have a go, though I know it might not be enough. I’m not at my laptop much today though so take a look and let me know where how far you get.

1 Like

Ok wow, after reading @bzee comment in the windows testing post…
I can confirm node bin starts the app SAFE Network FUSE authenticated!

This is great.

If you set a DEBUG variable when you start it will give you useful output to the console. For example:

DEBUG=safe-fuse*,safenetworkjs* node bin.js

You can also try accessing your SAFE storage. I recommend NOT changing directory to your SAFE drive at the moment, but you should be able to use commands like ls ~/SAFE to examine the directories, and to be able to list the content of files with cat <path-to-file>. Just use full paths for everything for the time being.

And if you are adventurous try tree <some-folder-path>. That takes a while but is very nice to watch (eventually).

Let me know if that works. If it does it just leaves packaging outstanding, and you can also recommend updates to the README.md instructions for MacOS of course.

If you hit any bugs and want to investigate you can try to make sense of the console output, or easier, try the debugger (see the README.md for instructions).

1 Like