alanshaw / alanshaw/iim

Unexpected behavior w/ $IPFS_PATH set

Đang mở
#5 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
TypeScript
Star
35
Fork
8
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

- Looks like `iim`'s `ipfs` bin (https://github.com/alanshaw/iim/blob/master/src/bin/ipfs.tpl.js) doesn't inherit my `$IPFS_PATH` env var, but it does respect it if I pass it in directly in the invocation line. [1] This was unexpected/confusing-- i'd say either respect it in both places, or not at all?
- if not respecting it at all, maybe warn the user if it is set [2]

- `ipfs -c $IPFS_PATH` works fine 👍

---

[0] demo that `ipfs` in my $PATH is indeed the wrapper from `iim`

```
> which ipfs
/usr/local/bin/ipfs
> cat $(which ipfs)
#!/usr/bin/env node

const Fs = require('fs')
const Path = require('path')
const Os = require('os')
const ChildProcess = require('child_process')

const env = Object.assign({}, process.env)

if (!env.IPFS_PATH) {
const ipfsPath = Path.join(Os.homedir(), '.iim/go-ipfs@0.4.18')
Fs.mkdirSync(ipfsPath, { recursive: true })
env.IPFS_PATH = ipfsPath
}

ChildProcess.spawn('/Users/jbenet/.iim/dists/go-ipfs@0.4.18/node_modules/go-ipfs-dep/go-ipfs/ipfs', process.argv.slice(2), { env, stdio: 'inherit' })
```

---

[1] demo that:
- `iim`'s wrapper does not use `$IPFS_PATH` var from environment, but does use it if passed in directly in the invocation. Not sure why, but this was unexpected.
- `ipfs -c` works fine.

```
> echo $IPFS_PATH
/Users/jbenet/.ipfs
> cat $IPFS_PATH/config | grep PeerID
"PeerID": "Qmbwqf292G3GbrNm1ydtKeqhqqgyqXDtDvsuBYuvXsPHHr",
> ipfs config show | grep PeerID
"PeerID": "QmfUQQTJzzPbqLbMhmxpEEEosx223tV59gTuhGM24CxZeN"
> IPFS_PATH="$IPFS_PATH" ipfs config show | grep PeerID
"PeerID": "Qmbwqf292G3GbrNm1ydtKeqhqqgyqXDtDvsuBYuvXsPHHr"
> ipfs -c "$IPFS_PATH" config show | grep PeerID
"PeerID": "Qmbwqf292G3GbrNm1ydtKeqhqqgyqXDtDvsuBYuvXsPHHr"
```

---

[2] potential ways to warn the user not to use `$IPFS_PATH` with `iim`:

```
> echo $IPFS_PATH
/Users/jbenet/.ipfs

# if it should be an error, dont run command and return non zero exit code, from the `iim` wrapper
> ipfs config show | grep PeerID
error: IPFS_PATH is not used by iim and the versions of ipfs it installs. use `ipfs -c` instead

# if it should be a warning, just output that to stderr, but then proceed.
> ipfs config show | grep PeerID
error: IPFS_PATH is set, but it is not used by iim and the versions of ipfs it installs. use `ipfs -c` instead
"PeerID": "QmfUQQTJzzPbqLbMhmxpEEEosx223tV59gTuhGM24CxZeN"
```

i'm divided either way, but good to get the feedback quickly to adjust usage

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.