Permission Error Installing Yarn

Keywords: Magento - AWS - Technical issue - Permissions
bnsupport ID: 70a5cba5-c2ac-566d-adf9-68dbcc93278e
Description:
I have a Magento stack and have installed npm/node. I am trying to also install yarn and I get many permission errors.

npm ERR! Error: EACCES: permission denied, access ‘/opt/bitnami/apps/magento/htdocs’
npm ERR! [Error: EACCES: permission denied, access ‘/opt/bitnami/apps/magento/htdocs’]

I tried changing permissions from daemon:bitnami to bitnami;bitnami and that just broke the site. I tried sudo /opt/bitnami/use_magento and that didn’t work either. How can I make it so I can run scripts so files and directories can be installed?

Thanks!
Stan

Hi @matt6studios,

The Bitnami Magento solution uses the daemon user and group to serve the app’s files.

You can take a look at this video tutorial to recover the permissions configuration of the app

https://www.youtube.com/watch?v=V3yeN-Wkd-Y&list=PLGgVZHi3XQNl2T8Q1RMfgLIop3TIFwVad&index=2

You can use this command to install the node packages inside the Magento’s installation

sudo su daemon -s /bin/bash -c "YOUR COMMAND HERE"

Happy to help!


Was my answer helpful? Click on :heart:

Hi,

Thanks for the help! I am trying to run this:

sudo su daemon -s /bin/bash -c curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

and get this error:
su: invalid option – ‘o’
Try ‘su --help’ for more information.

Thanks!
Stan

Hi @matt6studios,

Please use quotation marks around the command to run using the daemon user.

sudo su daemon -s /bin/bash -c "curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash"

Hi,

Thanks, I was able to install node!

I tried to install yarn the same way but it failed. I was able to install it without using sudo su daemon -s /bin/bash -c and just running the curl command. I tried to build something using yarn yarn create @magento/pwa and I received an error:

Error: EACCES: permission denied, mkdir ‘/opt/bitnami/apps/magento/htdocs/pwa-studio’

Using what you suggested just gave me an error that yarn command was not found. What can I do so I don’t keep getting these permission errors?

Thanks,
Stan

If the daemon user doesn’t find yarn, you will need to specify the whole path to the yarn binary. Run which yarn to get the whole path and then use this

sudo su daemon -s /bin/bash -c "PATH/TO/YARN THE REST OF THE COMMAND HERE"

Keywords: Magento - AWS - Technical issue - Other
bnsupport ID: 56579475-0f4a-3ccf-6bbc-d6117cbcbbed
Description:
Hi,

I am trying to install/run PWA Studio and in the directory I am running:

yarn build

Which returns this error:
yarn run v1.22.4
$ yarn run build:prod
$ yarn run clean && webpack --no-progress --env.mode production
$ rimraf dist
/bin/sh: 1: rimraf: Permission denied
error Command failed with exit code 126.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 126.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 126.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

My directories are set to 755 and I also tried 775. My files are 664. Magento runs fine. I also ran:

sudo usermod -a -G daemon bitnami

So I could get yarn to run.

I have the owner:group at:
bitnami:daemin

The permissions seem so complicated. What do I need to do to get this to work?

Thanks,
Stan

This is not the configuration the video tutorial I mentioned above uses. Please use daemon:daemon and run the commands using the daemon user as I mentioned in my previous message

Hi,

I have all the users at daemon:daemon.
I have directories at 775.
I have files at 664.

I went to the directory I wanted Yarn installed in and ran:

sudo su daemon -s /bin/bash -c "curl -o- -L https://yarnpkg.com/install.sh | bash"

And I received this error:

WARNING: GPG is not installed, integrity can not be verified!
Extracting to ~/.yarn…
mktemp: failed to create directory via template ‘yarn.XXXXXXXXXX’: Permission denied

Thanks for the help!
Stan

Hi,

I also tried this:

bitnami@ip-172-31-72-97:~/apps/magento/htdocs/pwa-studio$ sudo su daemon -s /bin/bash -c “yarn build”
bash: yarn: command not found
bitnami@ip-172-31-72-97:~/apps/magento/htdocs/pwa-studio$ yarn build
yarn run v1.22.4
$ yarn run build:prod
$ yarn run clean && webpack --no-progress --env.mode production
$ rimraf dist
/bin/sh: 1: rimraf: Permission denied
error Command failed with exit code 126.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 126.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 126.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Hi @matt6studios,

Let’s follow a different approach. You can install yarn using the root user and you can later use the root user to run the yarn commands. Every time you do that, you will need to recover the permissions configuration.

  • Install yarn
sudo rm -rf /root/.yarn
curl -o- -L https://yarnpkg.com/install.sh | sudo bash
  • Execute yarn commands
cd /opt/bitnami/apps/magento/htdocs/
sudo /root/.yarn/bin/yarn COMMAND HERE
  • Recover permissions

https://www.youtube.com/watch?v=V3yeN-Wkd-Y&list=PLGgVZHi3XQNl2T8Q1RMfgLIop3TIFwVad&index=2

I hope this helps

Hi @jota,

I ran the first set of commands and this was returned:

WARNING: GPG is not installed, integrity can not be verified!
Extracting to ~/.yarn…
Adding to $PATH…
We’ve added the following to your /root/.bashrc
If this isn’t the profile of your current shell then please add the following to your correct profile:

export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"

Yarn requires Node.js 4.0 or higher to be installed.
Yarn was installed, but doesn’t seem to be working :(.

bitnami@ip-172-31-72-97:~$ node -v
v14.7.0

What do I need to do now?

Thanks!
Stan

Hi @matt6studios,

How did you install node in the machine? Did you follow the official documentation?

https://github.com/nodesource/distributions/blob/master/README.md

I did and Node is installed properly

bitnami@bitnami-magento-30e7:~$ sudo node -v
v14.8.0
bitnami@bitnami-magento-30e7:~$ sudo which node
/usr/bin/node

and Yarn is installed properly

bitnami@bitnami-magento-30e7:~$ curl -o- -L https://yarnpkg.com/install.sh | sudo bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    54  100    54    0     0    524      0 --:--:-- --:--:-- --:--:--   524
100  7152  100  7152    0     0  35582      0 --:--:-- --:--:-- --:--:-- 35582
Installing Yarn!
> Downloading tarball...

[1/2]: https://yarnpkg.com/latest.tar.gz --> /tmp/yarn.tar.gz.q8eW5nD0FX
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    57  100    57    0     0    463      0 --:--:-- --:--:-- --:--:--   459
100    93  100    93    0     0    489      0 --:--:-- --:--:-- --:--:--   489
100   630  100   630    0     0   2825      0 --:--:-- --:--:-- --:--:--  2825
100 1215k  100 1215k    0     0  4206k      0 --:--:-- --:--:-- --:--:-- 4206k

[2/2]: https://yarnpkg.com/latest.tar.gz.asc --> /tmp/yarn.tar.gz.q8eW5nD0FX.asc
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    61  100    61    0     0   2259      0 --:--:-- --:--:-- --:--:--  2259
100    97  100    97    0     0   2771      0 --:--:-- --:--:-- --:--:--  2771
100   634  100   634    0     0  14409      0 --:--:-- --:--:-- --:--:-- 14409
100  1028  100  1028    0     0  18035      0 --:--:-- --:--:-- --:--:-- 18035
> Verifying integrity...
gpg: Signature made Mon 09 Mar 2020 03:52:13 PM UTC
gpg:                using RSA key 6D98490C6F1ACDDD448E45954F77679369475BAA
gpg: Good signature from "Yarn Packaging <yarn@dan.cx>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 72EC F46A 56B4 AD39 C907  BBB7 1646 B01B 86E5 0310
     Subkey fingerprint: 6D98 490C 6F1A CDDD 448E  4595 4F77 6793 6947 5BAA
> GPG signature looks good
> Extracting to ~/.yarn...
> Adding to $PATH...
> Successfully installed Yarn 1.22.4! Please open another terminal where the `yarn` command will now be available.

Hi @jota,

I was able to get everything to work following this:

sudo rm -rf /root/.yarn
curl -o- -L https://yarnpkg.com/install.sh | sudo bash

And following this:
https://github.com/nodesource/distributions/blob/master/README.md

I can run the commands and set things up the way i need so far. Thanks!

1 Like

I’m glad to hear that!

Enjoy! :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.