Why do I need `sudo` to start `ipfs daemon` inside `tmux`?

From @SCBuergel on Mon May 15 2017 14:35:49 GMT+0000 (UTC)

I need some ipfs hashes to remain available over months or years, therefore I want to run the ipfs daemon on my own machine. What is the best way to achieve this?

This is what I tried:

  1. I am running a cloud-hosted VM, installed the latest ipfs and did ipfs init, all working fine.
  2. I ipfs pin the objects that I want to remain available, all still fine.
  3. I run ipfs daemon inside a tmux session to run in background and also when I log out. Since the cloud machine might reboot at times I want ipfs daemon to run on boot. Therefore I added the following lines to /etc/rc.local
tmux new-session -d -s myipfs
tmux send -t myipfs ipfs\ daemon ENTER
exit 0

Unfortunately ipfs does not seem to be able to launch inside a tmux session - it gives me the following error:

root@xxx:~# ipfs daemon
Initializing daemon...
Adjusting current ulimit to 2048...
Successfully raised file descriptor limit to 2048.
Error: no IPFS repo found in ~/.ipfs.
please run: 'ipfs init'

When running ipfs daemon outside of tmux all is good.

Copied from original issue: https://github.com/ipfs/support/issues/62

From @SCBuergel on Mon May 15 2017 14:38:51 GMT+0000 (UTC)

I just realized that all works well when starting the daemon via sudo ipfs daemon. This is a default Ubuntu 16.04 machine on Digital Ocean - I am anyway root already and dont understand why this is required.

From @lgierth on Mon May 15 2017 15:34:38 GMT+0000 (UTC)

It just can’t find the repo, probably your session isn’t setup correctly and $HOME points who-knows-where. What does echo $HOME print?

We discourage running go-ipfs as root for security reasons – only run things as root if you know what you’re doing. (This applies to any software, not just go-ipfs.)