ipfs / js-ipfs

IPFS implementation in JavaScript
https://js.ipfs.tech
Other
7.44k stars 1.25k forks source link

lacking installation instructions for libp2p and prometheus when installing ipfs -g #3241

Closed Tcll closed 4 years ago

Tcll commented 4 years ago

Severity:

Critical or High (installation fails)

Description:

ran sudo npm install ipfs --global and sudo npm install -g ipfs got:

npm WARN deprecated peer-info@0.17.5: No longer supported for js-libp2p0.28.0 or later
/usr/local/bin/jsipfs -> /usr/local/lib/node_modules/ipfs/src/cli/bin.js

> iso-constants@0.1.2 install /usr/local/lib/node_modules/ipfs/node_modules/iso-constants
> node build.js > index.browser.js

sh: 1: cannot create index.browser.js: Permission denied
npm WARN libp2p-delegated-content-routing@0.5.0 requires a peer of ipfs-http-client@^44.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN libp2p-delegated-peer-routing@0.5.0 requires a peer of ipfs-http-client@^44.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN prometheus-gc-stats@0.6.2 requires a peer of prom-client@>= 10 < 12 but none is installed. You must install peer dependencies yourself.

Steps to reproduce the error:

1: sudo npm install -g ipfs 2: wait for error

I'm not sure exactly what the error is asking me to do as this is my first time actually using npm... I'm not a fan of JS being anything more than a web script (ActiveX died for a good reason and shouldn't've been reborn), but I need a feature specific to js-ipfs

EDIT: btw, if you have a portable .appimage or .tar.gz anywhere that I can just download and run, I'd prefer that method instead of this nightmare of an installation procedure ;) (sudo apt-get install npm was broken to the point the initial upgrade broke npm so badly that purged reinstallation didn't even fix npm to a runnable state) ^ got it working through an unsupported curl link and upgraded from there.

welcome[bot] commented 4 years ago

Thank you for submitting your first issue to this repository! A maintainer will be here shortly to triage and review. In the meantime, please double-check that you have provided all the necessary information to make this process easy! Any information that can help save additional round trips is useful! We currently aim to give initial feedback within two business days. If this does not happen, feel free to leave a comment. Please keep an eye on how this issue will be labeled, as labels give an overview of priorities, assignments and additional actions requested by the maintainers:

Finally, remember to use https://discuss.ipfs.io if you just need general support.

achingbrain commented 4 years ago

You are trying to install as a superuser, which there's rarely a good reason for.

When running post-install scripts (like iso-constants build step from the logs above), npm will drop to an unprivileged user account which can lead to permission errors if those scripts try to create files as you have found.

If you add the --unsafe-perm flag to the install command, npm will not drop to an unprivileged account, but you'll also be running the post-install scripts as root which is a big security risk.

Instead you should either use a node version manager like nvm or n which will install everything in your home directory, or if you have node installed globally, make sure your current user can write to /usr/local/lib/node_modules before doing the install.

If all this is too much, pre-built Docker images are available.

Tcll commented 4 years ago

thank you for informing me about nvm (I'm actually glad I don't have to sudo) I'm not sure if it actually fixed anything as I still got the same warning, BUT it did seem to successfully install:

Thank you for using level!
If you rely on this package, please consider supporting our open collective:
> https://opencollective.com/level/donate

npm WARN libp2p-delegated-peer-routing@0.5.0 requires a peer of ipfs-http-client@^44.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN libp2p-delegated-content-routing@0.5.0 requires a peer of ipfs-http-client@^44.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN prometheus-gc-stats@0.6.2 requires a peer of prom-client@>= 10 < 12 but none is installed. You must install peer dependencies yourself.

+ ipfs@0.49.0
added 812 packages from 1157 contributors in 473.505s
tcll@tcll-compact:~$ jsipfs
jsipfs <command>

Commands:
  jsipfs add [file...]                    Add a file to IPFS using the UnixFS
                                          data format
  jsipfs bitswap <command>                Interact with the bitswap agent.
  jsipfs block <command>                  Manipulate raw IPFS blocks.
  jsipfs bootstrap <command>              Show or edit the list of bootstrap
                                          peers.
  jsipfs cat <ipfsPath>                   Fetch and cat an IPFS path referencing
                                          a file
  jsipfs cid <command>                    Convert, format and discover
                                          properties of CIDs.
  jsipfs commands                         List all available commands
  jsipfs config <key> [value]             Get and set IPFS config values.
  jsipfs daemon                           Start a long-running daemon process
  jsipfs dag <command>                    Interact with ipld dag objects.
  jsipfs dht <command>                    Issue commands directly through the
                                          DHT.
  jsipfs dns <domain>                     Resolve DNS links
  jsipfs files <command>                  Operations over mfs files (ls, mkdir,
                                          rm, etc)
  jsipfs get <ipfsPath>                   Fetch a file or directory with files
                                          references from an IPFS Path
  jsipfs id                               Shows IPFS Node ID info
  jsipfs init [default-config] [options]  Initialize a local IPFS node

                                          If you are going to run IPFS in a
                                          server environment, you may want to
                                          initialize it using the 'server'
                                          profile.

                                          For the list of available profiles run
                                          `jsipfs config profile ls`
  jsipfs key <command>                    Manage your keys
  jsipfs ls <key>                         List files for the given directory
  jsipfs name <command>                   Publish and resolve IPNS names.
  jsipfs object <command>                 Interact with ipfs objects.
  jsipfs pin <command>                    Pin and unpin objects to local
                                          storage.
  jsipfs ping <peerId>                    Measure the latency of a connection
  jsipfs pubsub <command>                 pubsub commands
  jsipfs refs-local                       List all local references.
  jsipfs refs <key> [keys..]              List links (references) from an object
  jsipfs repo <command>                   Manipulate the IPFS repo.
  jsipfs resolve <name>                   Resolve the value of names to IPFS
  jsipfs shutdown                         Shut down the ipfs daemon
  jsipfs stats <command>                  Query IPFS statistics.
  jsipfs swarm <command>                  Swarm inspection tool.
  jsipfs version                          Shows IPFS version information
  jsipfs completion                       generate completion script

Options:
  --version  Show version number                                       [boolean]
  --silent   Write no output                          [boolean] [default: false]
  --pass     Pass phrase for the keys                     [string] [default: ""]
  --migrate  Enable/disable automatic repo migrations [boolean] [default: false]
  --api      Remote API multiaddr to use                                [string]
  --help     Show help                                                 [boolean]

ipfs uses a repository in the local file system. By default, the repo is located
at ~/.jsipfs. To change the repo location, set the $IPFS_PATH environment
variable:

export IPFS_PATH=/path/to/ipfsrepo

Error: Please specify a command
tcll@tcll-compact:~$ 

I just hope the warning there doesn't mean there's issues >_>

god npm makes me feel like a child staying with a bad sitter while their mother goes into service for years makes me glad I'm a python developer to the point I want to glomp it I hope I never have to use npm again >.<

achingbrain commented 4 years ago

If you don't like npm you can try yarn?

Anyway, glad you got to the bottom of it.

Tcll commented 4 years ago

@achingbrain

glad you got to the bottom of it.

uhhhh, yeah, about that there may be problems if this link doesn't work for you... I've just added a ~600MiB Pictures directory containing ~30 contiguous subdirectories and ~1000 images within those directories that link is just 1 of those images the problem I have is the webui contains no files, but the block data is ~600MiB

if the link doesn't work, there's a chance it could be 1 of 2 issues 1: the ipfs installation was an unstable installation with the new CID generation that isn't fully implemented yet. 2: the packages I'm warned to install myself play a role in getting things working properly. 3: I'm just a noob and probably did something incorrectly when running the commands

I'm gonna place my bets on issue 2 being the cause of my problems... if so, how would I go about resolving this?? is assuming npm install -g package the right thing to do?? or should I just realize my mistake and purge everything, and go for the prebuilt docker image??

EDIT: yep it seems I'm just a noob and didn't realize I needed to publish my files after adding them but so far that only gets the primary url (Pictures/) working through ipfs.io and not the individual sub-files/folders to add, the web ui still says there's no files despite the fact I can access /Pictures through ipfs.io my guess is I just need to research a bit more

EDIT2: yeah I can't seem to find anything about what I have to do to publish a folder of files through the cli... what else do I have to do to make the folder appear in the web ui?? cause the tutorials only inform me about adding basic files...

jsipfs add -r --preserve-mtime /.../Pictures/
jsipfs name publish /ipfs/<hash of /Pictures>
??

after running those commands and refreshing: Screenshot_2020-08-24_20-04-05 but I can access through ipfs.io: Screenshot_2020-08-24_20-09-22 ^ I'm aware this is more of a general lack of documentation than anything related to the initial issue if you need me to create a separate issue on this, I will.

EDIT3: just did some exploring and found I could import hashes from ipfs, which seems to have worked for my /Pictures folder hash... Screenshot_2020-08-24_20-43-58 I don't prefer hoping about like this between the CLI and WUI, but at least it got things working this should really be documented better :/

EDIT4: well, as it turns out, it looks like all this work for preserving modification time was a wasted effort u.u all dates are set to 12/31/1969 that's a shame as I use mtime quite often for backtracking when I talked about something and took the image. sometimes it's really useful to know I worked on something in 2010 or so :P hope this gets fixed soon :)

achingbrain commented 4 years ago

How do you mean the mtime is not preserved?

$ jsipfs add --preserve-mtime foo.txt
added QmPTKh7c6t5Z8ghXnabJiKUQHNab1X6Fi8yEVDw4ngLAX2 foo.txt
$ jsipfs files stat /ipfs/QmPTKh7c6t5Z8ghXnabJiKUQHNab1X6Fi8yEVDw4ngLAX2
QmPTKh7c6t5Z8ghXnabJiKUQHNab1X6Fi8yEVDw4ngLAX2
Size: 454
CumulativeSize: 478
ChildBlocks: 0
Type: file
Mode: -rw-r--r--
Mtime: 25 Aug 2020, 21:44:01 BST     <----- mtime is preserved
Tcll commented 4 years ago

oh I see what's going on ok so when I download the file with wget, the mtime is stripped to 12/31/1969 (nextcloud preserves it) but when I just stat through the ipfs cloud/VFS, the mtime is maintained: image and no, the browser isn't even in question as the mtime is the download time (it's expected browsers do their own thing just because it's web)

guess it's just a factor of this being alpha software then :P thanks :)

btw, I say VFS because of what I'm working on, which functions quite similarly except IPFS doesn't seem to have network saturation (can close my daemon and still have granular access to my files), nor does it seem to make malicious intrusion irrelevant (interval-activated re-encryption of solid partial blocks), and it also integrates over TCP protocols... (mine is also blockchain-based rather than git-based) so yeah, I'm not trying to reinvent a wheel as I didn't know ipfs did what it did until recently, despite knowing it's existed for a few years ;)

EDIT: clearing confusion: when I say "solid", I mean the dynamics will override any changes a malicious hacker attempts to make to your data, and when I say "partial", I mean you actually store about 1/10th of your data on your system, the rest is saturated by those who view your data.

I don't mind sharing my ideas as I actually hope IPFS (or anyone else) takes them on for better security :) (I don't see much of this stuff (security in general) openly discussed for whatever reason)