Exporting to first-scope causes fatal error
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 - [34mdebug[39m: Establishing a new SSH connection to ssh://bit@[ ip redacted ]:/opt/bit/first-scope
2018-01-25T23:02:52.695Z - [34mdebug[39m: ssh: going to run a remote command _put, path: /opt/bit/first-scope
2018-01-25T23:02:53.627Z - [31merror[39m: 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 - [32minfo[39m: 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 - [34mdebug[39m: Establishing a new SSH connection to ssh://bit@[ ip redacted ]:/opt/bit/first-scope
2018-01-25T23:10:11.216Z - [34mdebug[39m: ssh: going to run a remote command _put, path: /opt/bit/first-scope
2018-01-25T23:10:12.108Z - [31merror[39m: 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 - [32minfo[39m: ssh: server had been exiting before closing. Exit code: 1
2018-01-25T23:10:12.111Z - [34mdebug[39m: 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.
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 - [31merror[39m: 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"}}
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 , 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