In case on Mac and Linux I do not have ~/.local directory, after installing CLI with sudo sudo npm i -g nativescript, I cannot access ~/.local and ~/.local/share directories. Some other applications are trying to use them after that and they are failing as the directories are created with root owner instead of my own user.
The reason is that we are creating .nativescript-cli cache directory insider ~/.local/share and if the path above does not exist, installing CLI with sudo leads to creation of ~/.local and ~/.local/share directories with root owner. Inside CLI we have code to change the owner of .nativescript-cli directory to current user, but it is not applied to ~/.local and ~/.local/share directories which may have been created from the same process.
The workaround is to change the owner of ~/.local and all its subdirectories to your user.
sudo chown -R <username> ~/.local
I assume the reason for this is as follows:
On Ubuntu you install nativescript as root in order to install it globally
sudo npm install -g nativescript
During the setup the nativescript installer creates a config file when asking for permission to send usage data to telerik. This file and correspondin directory is created still as super user.
Therefore when creating a new project - as a regular user - the permissions forbid to create the lock file
EACCES: permission denied, open '/home/user/.local/share/.nativescript-cli/.lock'
A simple workaround would be to delay the question and configuration file creation until the first run of tns, which then is performed with the correct user account.
Make a note on the docs about this issue for linux users; http://docs.nativescript.org/angular/tutorial/ng-chapter-1
Hey guys, @Makiavelo @everflux
We now have a fix for that in our @next, so if you're still encountering it you can try the latest bits and share if it works for you.
sudo chown -R
thanks the above solved it for me
I have similar issue
I have ubuntu 14.04, tried sudo chown ammar -R ~/.local where ammar is my user name but the issue still there
EACCES: permission denied, open '/home/ammar/.local/share/.nativescript-cli/user-settings.json.lock'
Most helpful comment
sudo chown -R ~/.local
thanks the above solved it for me