JHipster : Bower not found - bower

when I yo jhipster, I have a
Warning! bower is not found on your computer.
When I do a bower -v
Error: EACCES: permission denied, open '/home/esecly/.config/configstore/bower-github.json'
You don't have access to this file.
when I do a sudo bower -v
1.7.9
So where's the problem ? Thanks you :)

The problem is that when bower was installed in your computer, is has the wrong authorization, so you can't run it, and for some reason, we can't run bower with sudo because of "too much authorization" (I don't find that very clever but well there must be some reasons).
So by doing chown, you actually took the precise file with the wrong authorization and change the username and the group name.
To have access to your own username and group name you use for your files, go to the repository and write :
ls -l
There will be all your files and the name of users and the name of groups in the third and fourth columns.
Then run : sudo chown -R Username:groupName path/of/your/file

Finally found a way, I will record it somewhere cause it looks like nobody had this problem before :
If you got the message Warning! Bower is not found on your computer
Try a bower -v
If permission denied, try a sudo bower-v
Then, if it answers your version, you must change rights.
For my case Error: EACCES: permission denied, open '/home/esecly/.config/configstore/bower-github.json'
It is sudo chown -R esecly:esecly /home/esecly/.config/configstore/
Hope it will help someone :)

Related

Reading a file as sudo from Ruby on Rails

Surprisingly i did not find anyone trying to do this, that's why im making this question.
Thing is i have a file, where im storing some data. I want to have an option in my rails project, where you can "export" some objects that are defined in this file.
This file belongs to root, soo if i try to read it with File.read("myfile.json") it fails with this error:
#<Errno::EACCES: Permission denied # rb_sysopen - /opt/rb/etc/cep/state.json>
Is there a way i can read it as root? Maybe the solution is to run a "sudo cat myfile.json" as a command from ruby and inject the result into a variable?
My goal is to place the contents of this file inside another one that the user will download, so later he can upload this file and have all the objects from before. It was weird not seeing more people trying to do this so I don't know if maybe i'm asking something stupid. I found none information in google about this, maybe is not possible to open a file as sudo with File.open.
A simple way to quickly solve it is change the file's owner.
sudo chown $USER myfile.json
If you want to access a file, I think it's not a good idea to give your application sudo access. It is potentially dangerous.
You might change the permission on the file instead, by changing the owner/group for the file.
Here you can find how to get the user running the application.
This command will change the owner of the file
sudo chown <my_user> /opt/rb/etc/cep/state.json
Another option is to create a group with the current owner and the rails user and set that group as owner:
sudo groupadd mynewgroup
sudo usermod -a -G mynewgroup <my_user>
sudo usermod -a -G mynewgroup <current_user>
sudo chgrp mynewgroup /opt/rb/etc/cep/state.json

Ubuntu, shopsys install via composer, docker, still crashing

I wanna install shopsys via composer and docker, as is recommended.
https://github.com/shopsys/shopsys/blob/master/docs/installation/installation-using-docker-linux.md
I installed git, php-fpm (configured), postgres (configured), composer, docker, docker-compose.
sudo apt install git
sudo apt install php7.2-fpm
sudo apt install postgresql
sudo apt install composer
sudo apt install docker-ce
sudo apt install docker-compose
Everything ok.
I added my user to docker group.
sudo usermod -a -G docker $(whoami)
Ok.
Next I made folder /var/www/html/shopsys, created project shopsys via composer.
composer create-project shopsys/project-base --no-install --keep-vcs
cd project-base/
Then I run this in /var/www/html/shopsys/project-base.
./scripts/install.sh
Everything seems to be ok, until this.
[RuntimeException]
/var/www/html/vendor does not exist and could not be created.
I set rights to 777 for folder /var/www/html, and run it again, but same problem.
The I run this.
sudo composer install
It shows me this error.
....Exception\InvalidConfigurationException]
Invalid configuration for path "monolog.handlers.main": You can only use ex
cluded_http_codes/excluded_404s with a FingersCrossedHandler definition
In ScriptHandler.php line 294:
An error occurred when executing the "'shopsys:domains-urls:configure'" command:
In BaseNode.php line 319:
...\Exception\InvalidConfigurationException]
Invalid configuration for path "monolog.handlers.main": You can only use ex
cluded_http_codes/excluded_404s with a FingersCrossedHandler definition
...
etc., error is quite ugly.
Last error when i run script install.sh.
file_put_contents(/var/www/html/vendor/composer/installed.json): failed to open stream: Permission denied
But this folder does not exist.
ls: cannot access '/var/www/html/vendor/': No such file or directory
Just question, where could be the problem?
Is possible to download sources from some link, extract it, configure and display in web browser with easy way, for example as wordpress?
Thanks.
To solve problem with vendor:
It seems that your UID and GID is different than default 1000, that is set in docker-compose.yml for Linux by default.
To solve your issue you can continue by step 3 in https://github.com/shopsys/shopsys/blob/master/docs/installation/installation-using-docker-linux.md#3-set-the-uid-and-gid-to-allow-file-access-in-mounted-volumes
You found issue with installation script, I have created issue on GitHub.
To solve problem with Invalid configuration for path "monolog.handlers.main":
Currently there is problem with new minor version (3.4.0) of symfony/monolog-bundle that created BC break. There is already created issue about this problem and there is already merged fix in Shopsys master.
To solve problem in your project you have to add
"symfony/monolog-bundle": ">=3.4.0", in conflict section in your composer.json file and then run composer install again.
We are trying to answer questions on stackoverflow as soon as possible, but we also have Slack where is many users and you might get your question answered much faster.

Permissions issue when installing yarn in a docker image

My dev team is currently setting up the environment for the updates on a proyect we've developing. I'm going straight to the point.
In our DockerFile we are installing yarn with RUN npm install -g yarn
But when executing an .sh file that empties cache files, we got the error:
yarn error “EACCESS: permission denied, scandir '/root/.config/yarn/link'”
I've looking up for possible fixes, and we only found a workaround which is to give full permissions to that directory:
RUN chmode -R 777 '/root/
And we know this is highly not recommended.
Does anyone know a better answer? I've seen tons of issues like this one with yarn and docker.
Yarn version is 1.9.4
Edit1:
The problem is that yarn writes or read these file with the user that executes this action, so the solution would be to grant permission to all user. Maybe in a more retrictive way?
EDIT:
After lots of failures we decided to just use chmode -R 777 ~/.config && chmode -R 777 ~/.cache Those files were not created until we ran a yarn install, what due to how we developed the sistem, was triggered everytime an user entered the sistem. So the workaround was to just give 777 permissions to every user in order to let them write onto these files.
Anyway, if anything better comes up, I'll post the answer here.
Btw the system got deprecated
Try this In dockerfile
USER root
RUN npm install -g yarn
USER [user name]
RUN chown -R [user name] ~/.config && chown -R [user name] ~/.cache
https://docs.npmjs.com/getting-started/fixing-npm-permissions
try
sudo npm install yarn && yarn install
We ended up setting 777 permissions, but that system got deprecated.

Permission Denied while trying to install ruby gems on ubuntu 16.04

I am trying to install ruby gems on my computer running Ubuntu 16.04. I use bash with the oh-my-zsh framework.
When I run the command:
curl -L https://get.rvm.io | bash -s stable --ruby
I get the error message:
mktemp: failed to create file via template '/usr/share/rvm/rvm-exec-test.XXXXXX': Permission denied
How do I set up the permissions for this to work properly?
You can use:
curl -L https://get.rvm.io | sudo bash -s stable --ruby
NOTE: Running a script as sudo can be very dangerous if you don't know what it is actually doing. Make sure to check the script and if possible give the appropriate permissions to the required files and or folders it needs to access. For some more info regarding why it can be dangerous see https://elementaryos.stackexchange.com/questions/448/why-is-running-commands-with-sudo-dangerous
Quick example with your particular use case, as can be seen in the link:
"...If a website is asking you to curl http://link/to/script | sudo bash, don't do that. Download the script, take a quick look, and after that, you can run it. Even if the original author did not intend to make the script malicious, someone might have compromised the original author's accounts and uploaded a new, "updated" script. You are the one responsible for your computer's integrity, and therefore you need to be familiar with your system's capabilities."
Make The directory as read and write ... cd dirname chmod 777
or
sudo gem install 'gem name','version'

Permission denied when trying to install RVM?

I renamed my Macbook home directory to "hmumin" from "macbookpro".
I then tried to install RVM using:
$ curl -L https://get.rvm.io | bash -s
but I get an error:
mkdir: /Users/macbookpro/.rvm/src: Permission denied
Is this error from trying to install RVM in the previous home directory?
If I run:
open /Users/macbookpro
I get:
The file /Users/macbookpro does not exist.
Yet, if I run:
mkdir /Users/macbookpro
I get:
mkdir: /Users/macbookpro: Permission denied
It's pretty confusing, I just want to install RVM.
When I type RVM I also get this type of error:
cat: /Users/macbookpro/.rvm/VERSION: No such file or directory
Warning! PATH is not properly set up, '/Users/macbookpro/.rvm/gems/ruby-2.0.0- p353#railstutorial_rails_4_0/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.0.0-
p353#railstutorial_rails_4_0'.
-bash: /Users/macbookpro/.rvm/scripts/base: No such file or directory
-bash: /Users/macbookpro/.rvm/scripts/help: No such file or directory
hmumin:~ hmumin$
It sounds like you have multiple problems, and they need to be addressed individually before you can successfully install RVM:
You can't rename your home directory and expect a machine to be happy. There are multiple places that track your home directory name, including the security system that maintains the user and group information. You need to check on "Ask Different" for how to correctly recover from this situation, and then how to correctly change your home directory as it is off-topic for Stack Exchange.
Carefully read the instructions for RVM installation at http://rvm.io/rvm/install. RVM is a very easy-to-install Ruby manager, however there are decisions you have to make up front, before you begin installing it. I'd strongly recommend you do the single-user installation, but, no matter which you choose, read the entire page first.

Resources