Permissions issue when installing yarn in a docker image - docker

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.

Related

"pipenv install" in empty directory doesn't create a Pipfile, but uses a Pipfile.lock from somewhere else

I ran pipenv install to create a Pipfile in the current directory that doesn't have a Pipfile. It gave the following output but did not create a Pipfile. Why not?
Installing dependencies from Pipfile.lock (639627)…
🐍 β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰β–‰ 0/0 β€” 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
It looks like it found a Pipfile.lock somewhere and used it? (similar to git behavior)
Use the PIPENV_NO_INHERIT environment variable to ignore inheriting from directories above the current directory, e.g.,
PIPENV_NO_INHERIT=True pipenv install
In your case, pipenv searched directories above the current directory and found a Pipfile there that it used (the location of which can be seen with pipenv --where).
(Incidently, I looked at the pipenv documentation but was unable to find where it discussed this behavior, so please add a link here to that documentation if you find it.)
I ran pipenv shell first (creat Pipfile), then pipenv install (creat Pipfile.lock)
'pip install pipenv' command returns "Requirement already satisfied ..."

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.

Error: parent directory is world writable but not sticky

I'm running into:
Error: parent directory is world writable but not sticky
While trying to do:
brew install yarn
Error: parent directory is world writable but not sticky
Please report this bug:
https://github.com/Linuxbrew/brew/blob/master/docs/Troubleshooting.md#troubleshooting
/var/lib/jenkins/.linuxbrew/Library/Homebrew/vendor/portable-ruby/2.0.0-p648/lib/ruby/2.0.0/tmpdir.rb:92:in `mktmpdir'
Does anybody know how to resolve this?
It is a permission problem, When I am trying to install brew install yarn --without-node, Got this error, on my Mac OSx Sierra
First, find out where is your tmp directory using ls -ld /tmp When I ran this command, got the output in following way,
ls -ld /tmp
lrwxr-xr-x# 1 root wheel 11 Jan 28 2017 /tmp -> private/tmp
which means tmp directory is using private/tmp So try giving the permission by using following command
sudo chmod +t /private/tmp
I had a similar error, but in my case the directory with bad permissions was ~/Library/Caches/Homebrew.
chmod +t ~/Library/Caches/Homebrew
fixed it.
Homebrew/Ruby wants to set sticky bit (+t) permission on /private/tmp folder. Set it explicitly using
sudo chmod +t /private/tmp
will solve the issue. Brew command should work fine after this.

Rails could not find a temporary directory (ArgumentError)

I'm uploading my Rails proyect to a Ubuntu Server running 12.04LTS and I can't seem to fix this issue! Whether I do a bundle install or try to use the whenever gem I get that error! I've read a lot but still I'm unable to fix it
/lib/ruby/2.0.0/tmpdir.rb:34:in `tmpdir': could not find a temporary directory (ArgumentError)
And my ls -la of the / folder
Any ideas?
P.s I tried chmod -R 777 on /tmp with no luck
The short answer is to just run this like #hagello suggests.
chmod +t /tmp
Then it should start working again.
edit: As suggested in the comments just run
chmod +t /tmp
========
Old answer:
Your Ubuntu installation probably doesn't have TMPDIR set. You should set that variable in your startup.
This link has more information on environment variables in Ubuntu: https://help.ubuntu.com/community/EnvironmentVariables

jhipster application files generated in wrong directory

When I try to create a jhipster application in ubuntu 13.10 with yo jhipster the generated output files are always dumped in the wrong directory.
For example I run yo jhipster in the directory /mnt/mercury/jhipster-test/alpha then the files are dumped out to /mnt/mercury. In fact if I run yo jhipster in any subdirectory of /mnt/mercury they are always dumped out to /mnt/mercury.
I'm using yo version 1.1.2 from the standard ubuntu repository
Please advise how to generate files to be output in current directory.
For the benefit of anyone else facing this problem.
I managed to get Yeoman working with the following
npm cache clean
sudo npm rm -g yo
npm cache clean
sudo npm install -g yo
My problem: Accidentally "yo generating" in the parent directory.
Solution: Delete the .yo-rc.json file in the parent directory, then running the yo generator command in the child directory.
As discussed in the comments, this is a Yeoman problem on Ubuntu 13.10:
We don't have this issue with Ubuntu 12.04
There is the same issue with other generators ("yo webapp") on Ubuntu 13.10
As a workaround, I recommend you have a look at our Docker container:
https://github.com/jhipster/jhipster-docker
This will allow you to run the full JHipster stack, with Ubuntu 12.04, inside a container! Just use it to generate the app, then you can work directly on your host machine.
On Mac OSX Maverick with Node v0.10.26, yo v1.1.2 and generator-jhipster v0.11, the yo hipster command was generating all the sources always in the same (wrong!) directory and not using my current directory.
I fixed this problem doing the following:
cd <WRONG_DIR_WHERE_CODE_IS_CREATED>
rm .yo-rc.json node_modules/
npm uninstall -g karma
npm install -g karma (Note: using sudo it was not working!)
sudo npm install -g generator-jhipster
Not sure why but I've then been able to install karma and generator-jhipster again and suddenly yo hipster starting generating code again in my current directory
Could it be caused by different environment variables when launching npm with sudo?
The file .yo-rc.json is hidden, if it is not deleted, the generator will constantly take the settings from it. You must delete .yo-rc.json.

Resources