-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Better error message when not initialized #1180
Comments
Hi @diasdavid I'm taking a look at this issue and found this Line 43 in 3bca165
There, you do not fail when a repo doesn't exists but just flag it. A few lines after you check if Line 72 in 3bca165
But the IPFS class is always instaciated with Line 48 in 3bca165
We have two options there
In go-ipfs if I try to run the same command I got this message:
Could you please instruct me what is the best way to accomplish that? Will be glad to make a PR to fix it :) |
I'm taking a look at this issue too, but I'm not sure if I'm taking the right path. Lines 39 to 49 in c1e8db1
We could replace the line 48 with the following code to get the same behaviour of const repoPath = process.env.IPFS_PATH || os.homedir() + '/.jsipfs'
process.stdout.write('Error: no initialized ipfs repo found in ' + repoPath)
process.stdout.write('\nplease run: jsipfs init')
process.exit(1) But I don't know if this should be in Any thoughts, @diasdavid @JonKrone? |
@fsdiogo we should never do The right implementation would be to know which commands needs to have a repository initialized before executing (not all commands needs a repository to work). For those commands, it should check the repository before running and if not initialized, return the callback with an error. This logic should hopefully be contained in one place and we can "tag" commands that needs a initialized repository to work. In the CLI, if we get this error, we simply display it and then we can do |
@victorbjelkholm makes sense. That's why it didn't feel right doing that there. But then it should be implemented both in the core and the CLI right? Abstracted and shared by both. |
@fsdiogo the For the issue @vmx reported, the check can happen all in CLI, from within this func https://github.com/ipfs/js-ipfs/blob/master/src/cli/utils.js#L41 |
Hm, then when you don't use the CLI (in browser for example), you won't get the error even if it's appropriate. I would say the error needs to come from core as a "repo not initialized" error, then printed in the CLI. The check should not just be in the CLI though, as if you don't use the CLI, you get the cryptic |
I'm getting this error from time to time using the package (v0.33.1) in a NodeJS project.
The happy path in my case is choosing I'm on Windows 7. |
Closing as this issue is very stale and is no longer a problem. |
ipfs pin [-r] <ipfs-path>
#1 SMP Debian 4.14.7-1 (2017-12-22) x86_64 GNU/LinuxType:
Bug
Severity:
Low
Description:
jsipfs block put
errors with an unhandled exception when IPFS wasn't previously initialized. Instead it should print a nice error that no repository was initialized and callingjsipfs init
first might make sense. Example:Steps to reproduce the error:
Make sure you don't have a repository (i.e.
rm -Rf ~/.jsipfs
). Then run:The text was updated successfully, but these errors were encountered: