bit icon indicating copy to clipboard operation
bit copied to clipboard

Exporting to first-scope causes fatal error

Open gscottolson opened this issue 8 years ago • 3 comments

Nice work on bit. But I have run into an issue. Any thoughts about this error when trying to export to a remote server (self-hosted)?

> bit export first-scope

fatal: unexpected network error has occurred

Looking at my local logs, I see:

2018-01-25T23:02:52.546Z - debug: Establishing a new SSH connection to ssh://bit@[ ip redacted ]:/opt/bit/first-scope
2018-01-25T23:02:52.695Z - debug: ssh: going to run a remote command _put, path: /opt/bit/first-scope
2018-01-25T23:02:53.627Z - error: ssh: got an error, {"payload":{"errno":-13,"code":"EACCES","syscall":"open","path":"/home/bit/Library/Caches/Bit/config/global-remotes.json","name":"Error","message":"EACCES: permission denied, open '/home/bit/Library/Caches/Bit/config/global-remotes.json'","stack":"Error: EACCES: permission denied, open '/home/bit/Library/Caches/Bit/config/global-remotes.json'"},"headers":{"version":"0.12.2"}}
2018-01-25T23:02:53.628Z - info: ssh: server had been exiting before closing. Exit code: 1

I sshed into the server and couldn’t find this file. Was it not installed with bit-bin?

I created it (touch global-remotes.json) and ran bit export first-scope again:

2018-01-25T23:10:11.076Z - debug: Establishing a new SSH connection to ssh://bit@[ ip redacted ]:/opt/bit/first-scope
2018-01-25T23:10:11.216Z - debug: ssh: going to run a remote command _put, path: /opt/bit/first-scope
2018-01-25T23:10:12.108Z - error: ssh: got an error, {"payload":{"name":"TypeError","message":"globalRemotes.toPlainObject is not a function","stack":"TypeError: globalRemotes.toPlainObject is not a function\n    at mergeRemotes (/usr/local/share/.config/yarn/global/node_modules/bit-bin/dist/scope/scope.js:423:39)\n    at <anonymous>"},"headers":{"version":"0.12.2"}}
2018-01-25T23:10:12.110Z - info: ssh: server had been exiting before closing. Exit code: 1
2018-01-25T23:10:12.111Z - debug: ssh: returned with code: 1, signal: undefined.

I am wondering if there a file missing from the bit-bin installation (for me, via yarn) or if I am missing something. I found a reference to globalRemotes.toPlainObject but I need to spend some more time digging in.

Any thoughts or tips would be appreciated. Thanks.

gscottolson avatar Jan 25 '18 23:01 gscottolson

I created the missing global-remotes.json and config.json files (after digging through the logs). Afterwards, I ran into this:

2018-01-25T23:35:28.466Z - error: ssh: got an error, {"payload":{"errno":-13,"code":"EACCES","syscall":"mkdir","path":"/opt/bit/first-scope/objects/c9","name":"Error","message":"EACCES: permission denied, mkdir '/opt/bit/first-scope/objects/c9'","stack":"Error: EACCES: permission denied, mkdir '/opt/bit/first-scope/objects/c9'"},"headers":{"version":"0.12.2"}}

gscottolson avatar Jan 25 '18 23:01 gscottolson

After some consistent mkdir errors, I realized that I needed to assign ownership for the /opt/bit/ subdirectories. For example…

sudo chown bit:sudo /opt/bit/first-scope/objects
sudo chown bit:sudo /opt/bit/first-scope/components
sudo chown bit:sudo /opt/bit/first-scope/tmp

Apologies for the issue noise. I hope this will be helpful for others who are trying to run bit on a server.

gscottolson avatar Jan 26 '18 06:01 gscottolson

@gscottolson , Glad you solved it. Thanks for your feedback and posting it for future users. Also, you can always reach us on gitter https://gitter.im/bit-src/Bit

GiladShoham avatar Jan 26 '18 12:01 GiladShoham