Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I force ipfs to change its repo if I am using ipfs that is installed via snap? #8580

Closed
3 tasks done
avatar-lavventura opened this issue Dec 3, 2021 · 4 comments
Closed
3 tasks done

Comments

@avatar-lavventura
Copy link

avatar-lavventura commented Dec 3, 2021

Checklist

Installation method

third-party binary

Version

$ ipfs version --all
go-ipfs version: 0.10.0-64b532fbb
Repo version: 11
System version: amd64/linux
Golang version: go1.16.8

Config

ipfs config show
{
  "API": {
    "HTTPHeaders": {}
  },
  "Addresses": {
    "API": "/ip4/127.0.0.1/tcp/5001",
    "Announce": [],
    "Gateway": "/ip4/127.0.0.1/tcp/8080",
    "NoAnnounce": [],
    "Swarm": [
      "/ip4/0.0.0.0/tcp/4001",
      "/ip6/::/tcp/4001",
      "/ip4/0.0.0.0/udp/4001/quic",
      "/ip6/::/udp/4001/quic"
    ]
  },
  "AutoNAT": {},
  "Bootstrap": [
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
    "/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
    "/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
    "/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"
  ],
  "DNS": {
    "Resolvers": {}
  },
  "Datastore": {
    "BloomFilterSize": 0,
    "GCPeriod": "1h",
    "HashOnRead": false,
    "Spec": {
      "mounts": [
        {
          "child": {
            "path": "blocks",
            "shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
            "sync": true,
            "type": "flatfs"
          },
          "mountpoint": "/blocks",
          "prefix": "flatfs.datastore",
          "type": "measure"
        },
        {
          "child": {
            "compression": "none",
            "path": "datastore",
            "type": "levelds"
          },
          "mountpoint": "/",
          "prefix": "leveldb.datastore",
          "type": "measure"
        }
      ],
      "type": "mount"
    },
    "StorageGCWatermark": 90,
    "StorageMax": "10GB"
  },
  "Discovery": {
    "MDNS": {
      "Enabled": true,
      "Interval": 10
    }
  },
  "Experimental": {
    "AcceleratedDHTClient": false,
    "FilestoreEnabled": false,
    "GraphsyncEnabled": false,
    "Libp2pStreamMounting": false,
    "P2pHttpProxy": false,
    "ShardingEnabled": false,
    "StrategicProviding": false,
    "UrlstoreEnabled": false
  },
  "Gateway": {
    "APICommands": [],
    "HTTPHeaders": {
      "Access-Control-Allow-Headers": [
        "X-Requested-With",
        "Range",
        "User-Agent"
      ],
      "Access-Control-Allow-Methods": [
        "GET"
      ],
      "Access-Control-Allow-Origin": [
        "*"
      ]
    },
    "NoDNSLink": false,
    "NoFetch": false,
    "PathPrefixes": [],
    "PublicGateways": null,
    "RootRedirect": "",
    "Writable": false
  },
  "Identity": {
    "PeerID": "12D3KooWNifpPKnZ1ZQTKVcjuj1uCHohzKQQthgcW4D5TnrrdKY8"
  },
  "Internal": {},
  "Ipns": {
    "RecordLifetime": "",
    "RepublishPeriod": "",
    "ResolveCacheSize": 128
  },
  "Migration": {
    "DownloadSources": [],
    "Keep": ""
  },
  "Mounts": {
    "FuseAllowOther": false,
    "IPFS": "/ipfs",
    "IPNS": "/ipns"
  },
  "Peering": {
    "Peers": null
  },
  "Pinning": {
    "RemoteServices": {}
  },
  "Plugins": {
    "Plugins": null
  },
  "Provider": {
    "Strategy": ""
  },
  "Pubsub": {
    "DisableSigning": false,
    "Router": ""
  },
  "Reprovider": {
    "Interval": "12h",
    "Strategy": "all"
  },
  "Routing": {
    "Type": "dht"
  },
  "Swarm": {
    "AddrFilters": null,
    "ConnMgr": {
      "GracePeriod": "20s",
      "HighWater": 900,
      "LowWater": 600,
      "Type": "basic"
    },
    "DisableBandwidthMetrics": false,
    "DisableNatPortMap": false,
    "EnableAutoRelay": false,
    "EnableRelayHop": false,
    "Transports": {
      "Multiplexers": {},
      "Network": {},
      "Security": {}
    }
  }
}

Description

I have installed ipfs using snap insall ipfs:

$ sudo snap install ipfs
snap "ipfs" is already installed, see 'snap help refresh'
$ which ipfs
/snap/bin/ipfs

When I set IPFS_PATH into ~/.ipfs it does not applied when I am using ipfs that is installed using snap (snap install ipfs). When it keeps creating the repo inside the /home/user/snap/ipfs/common repo.

How can I force ipfs to change its repo if I am using ipfs that is installed via snap?

❯ export IPFS_PATH=~/.ipfs && ipfs init
generating ED25519 keypair...done
peer identity: 12D3KooWAX7vQGfgzy95MFozA6RFz2Ri4BFz7Z5hzEFudUz5Rp5q
initializing IPFS node at /home/user/snap/ipfs/common
Error: ipfs configuration file already exists!
Reinitializing would overwrite your keys.
@avatar-lavventura avatar-lavventura added kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization labels Dec 3, 2021
@guseggert
Copy link
Contributor

The snap hardcodes IPFS_PATH to point to SNAP_USER_COMMON which is usually ~/snap/ipfs/common. So one way forward here is to bind-mount ~/.ipfs like this:

sudo mount --bind ~/.ipfs ~/snap/ipfs/common

Does that work for you?

@guseggert guseggert removed kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization labels Dec 3, 2021
@avatar-lavventura
Copy link
Author

avatar-lavventura commented Dec 4, 2021

@guseggert Yes it works for me, thank you

Is there any performance issue using the snap's directory?

@guseggert
Copy link
Contributor

There shouldn't be any performance difference with using a bind mount, the only drawbacks are that it requires root permission to mount it initially (or set it /etc/fstab) and administrative gotchas (e.g. backups may make two copies, some tools like df may ignore mounted filesystems, etc.).

@guseggert
Copy link
Contributor

PR to update the Snap section in the README with this info, since this isn't the first time we've had this question:

#8584

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants