Error loading profile: no such file or directory #102

Closed
opened 2018-08-04 23:10:35 +00:00 by kardan · 2 comments

I constantly had issues to load profiles and looked at the code for a reason why I kept seeing "no such file or directory" and it seems that the path is only supplied when creating a new profile:

app.Peer = peer.NewCwtchPeer(name, password, path.Join(app.directory, name+".json"))

However during loading no path is supplied:

main.go:259   app.SetProfile(commands[1]+".json", string(bytePassword))
app.go:73 	profile, err := peer.LoadCwtchPeer(filename, password)
cwtch_peer.go:173 	encryptedbytes, err := ioutil.ReadFile(profilefile)

Does that make sense?

I constantly had issues to load profiles and looked at the code for a reason why I kept seeing "no such file or directory" and it seems that the path is only supplied when creating a new profile: ``` app.Peer = peer.NewCwtchPeer(name, password, path.Join(app.directory, name+".json")) ``` However during loading no path is supplied: ``` main.go:259 app.SetProfile(commands[1]+".json", string(bytePassword)) app.go:73 profile, err := peer.LoadCwtchPeer(filename, password) cwtch_peer.go:173 encryptedbytes, err := ioutil.ReadFile(profilefile) ``` Does that make sense?
Author

With

profile, err := peer.LoadCwtchPeer(path.Join(app.directory, filename), password)

it works:

2018/08/05 01:31:14 NewApp(/home/user/.cwtch, /usr/bin/tor)                                                      
2018/08/05 01:31:14 using existing tor proxy
cwtch [unset]> load-profile m                                                                                   
Enter a password to decrypt the profile:                                                                        
Error loading profile for m: open /home/user/.cwtch/m.json: no such file or directory                            
cwtch [unset]> load-profile me                                                                                  
Enter a password to decrypt the profile: 
Loaded profile for me

Until i fork the repo this is the patch:

$ git diff
diff --git a/app/app.go b/app/app.go
index e24304b..f2beb32 100644
--- a/app/app.go
+++ b/app/app.go
@@ -70,7 +70,7 @@ func (app *Application) startTor(torPath string) error {                                      

 // SetProfile loads an existing profile from the given filename.                                               
 func (app *Application) SetProfile(filename string, password string) error {                                   
-       profile, err := peer.LoadCwtchPeer(filename, password)                                                  
+       profile, err := peer.LoadCwtchPeer(path.Join(app.directory, filename), password)                        
        if err != nil {
                return err
        }
With ``` profile, err := peer.LoadCwtchPeer(path.Join(app.directory, filename), password) ``` it works: ``` 2018/08/05 01:31:14 NewApp(/home/user/.cwtch, /usr/bin/tor) 2018/08/05 01:31:14 using existing tor proxy cwtch [unset]> load-profile m Enter a password to decrypt the profile: Error loading profile for m: open /home/user/.cwtch/m.json: no such file or directory cwtch [unset]> load-profile me Enter a password to decrypt the profile: Loaded profile for me ``` Until i fork the repo this is the patch: ``` $ git diff diff --git a/app/app.go b/app/app.go index e24304b..f2beb32 100644 --- a/app/app.go +++ b/app/app.go @@ -70,7 +70,7 @@ func (app *Application) startTor(torPath string) error { // SetProfile loads an existing profile from the given filename. func (app *Application) SetProfile(filename string, password string) error { - profile, err := peer.LoadCwtchPeer(filename, password) + profile, err := peer.LoadCwtchPeer(path.Join(app.directory, filename), password) if err != nil { return err } ```
Author

PR: #104

PR: #104
sarah closed this issue 2018-08-05 03:47:22 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cwtch.im/cwtch#102
No description provided.