Running IPFS Desktop and CLI simultaneously

1.6k Views Asked by At

This is a rather beginner question. Apologies for nothing more challening :)

I am running IPFS Desktop on my computer. I downloaded it via the Ubuntu Software Center. I believe it's a snap install. I am using Ubuntu 20.04

I want to be able to access some of the CLI commands for the node that is being run via the IPFS Desktop but when I enter any ipfs command in the terminal, it says command not found. etc.

If I install the ipfs cli then it runs a different node through the terminal. Am I missing something obvious here? How can I access the IPFS Desktop node through the command line?

Thanks!

3

There are 3 best solutions below

0
On BEST ANSWER

Thank you all for your answers. I believe the problem was in installing it using snap store (Ubuntu Software Center) because this changes the default path of the installations. So in effect, the desktop and cli were installed at separate paths.

I followed the installation on the IPFS site which uses the install script and that put it in the correct path.

So I re-installed only the CLI and use the webUI in place of the desktop. Along with IPFS Companion, desktop is not really needed. But I still wanted the functionality of having the desktop run the daemon behind the scenes without having a terminal open, so I created the following service unit file to do that:

Paste the following code in the file /etc/systemd/system/ipfs.service

[Unit]
Description=IPFS Daemon
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/ipfs daemon
User=user
Restart=on-failure

[Install]
WantedBy=default.target

Then I simply ran sudo systemctl start ipfs in a terminal to get the daemon running as a service.

Thanks!

0
On

Without running into distribution/package-specifics, below are two ways that should work on all systems.

Quick ad-hoc solution: point the ipfs CLI client at the node run by IPFS Desktop by passing an explicit API endpoint (ipfs --api=/ip4/127.0.0.1/tcp/5001). You can find exact address via Status_→_Advanced_→_API in WebUI provided by Desktop app.

Alternative is to set IPFS_PATH variable in your env to the directory used by IPFS Desktop, ensuring ipfs CLI tool uses the same repo as Desktop app. This is especially useful when you need to run a command that does not work over API and requires direct access the repository (like ipfs key export|rotate).

0
On

Yes IPFS should not be installed as a snap as you discovered it creates a second path. Installation is preferred by deb over appimage as the appimage limits user to only GUI interface. Another possible pitfall in the future could be the definition of "daemon" and "cluster". These are true to Unix definitions so a "daemon" is a service that manages a number of nodes on the same machine. Cluster is for multiple nodes that are physically seperated to different machines and locales. Other than that I'd say you are on the right path!