New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lando v3.0.0-rc1 - mv: cannot create regular file '/usr/local/bin/drush': Permission denied #1227

Closed
marceldobrica opened this Issue Oct 3, 2018 · 17 comments

Comments

Projects
None yet
6 participants
@marceldobrica
Copy link

marceldobrica commented Oct 3, 2018

System UBUNTU 18.04LTS; Docker version 18.06.1-ce, build e68fc7a; lando version v3.0.0-rc.1

How to reproduce:
In a new folder, lando init and edit .lando.yml file to be:

name: drupal-8-test
recipe: drupal8
config:
webroot: web
via: nginx

After lando start:
landoproxyhyperion5000gandalfedition_proxy_1 is up-to-date
Creating network "drupal8test_default" with the default driver
Creating volume "drupal8test_data" with default driver
Creating volume "drupal8test_appserver" with default driver
Creating volume "drupal8test_data_database" with default driver
Creating drupal8test_appserver_1 ... done
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 600 0 600 0 0 757 0 --:--:-- --:--:-- --:--:-- 758
100 303k 100 303k 0 0 77883 0 0:00:03 0:00:03 --:--:-- 99k
Drush Launcher Version: 0.6.0
mv: cannot create regular file '/usr/local/bin/drush': Permission denied
error: Looks like one of your build steps failed with [object Object]
warn: This MAY prevent your app from working
warn: Check for errors above, fix them, and try again
Starting drupal8test_appserver_1 ... done
Creating drupal8test_database_1 ... done
Creating drupal8test_nginx_1 ... done

in container (docker exec -it drupal8test_appserver_1 bash), I see drush.phar in /tmp folder but with user 33, group 33. As www-data in container I'm not able to mv drush.phar (not able to delete from /tmp folder)
root@9f6e068072a5:/tmp# ls -la
total 312
drwxrwxrwt 1 root root 4096 Oct 3 09:34 .
drwxr-xr-x 1 root root 4096 Oct 3 09:34 ..
-rwxr-xr-x 1 33 33 310920 Oct 3 09:32 drush.phar

.... So I'll not be able to use drush and drupal console.

A simple test should be to verify if for recipe drupal8 I have an working version of drush and drupal console....

@marceldobrica

This comment has been minimized.

Copy link
Author

marceldobrica commented Oct 3, 2018

Tested also on LUbuntu (18) on a virtualbox.
mkdir test
cd test
lando init
select drupal8, all other implicit settings.
lando start and same error
mv: cannot create regular file '/usr/local/bin/drush': Permission denied
docker exec -it into container... same situation, same user/group 33/33.

@marceldobrica

This comment has been minimized.

Copy link
Author

marceldobrica commented Oct 3, 2018

I have created a new LUbuntu 18 VirtualBox machine.
sudo apt-get update... Installed docker and lando as deb file.
mkdir test, cd test, lando init, lando start.... drush can't be moved - premission denied.

@marceldobrica

This comment has been minimized.

Copy link
Author

marceldobrica commented Oct 3, 2018

WORKS ON DEBIAN9
I have created a new Debian9 VirtualBox machine...
sudo apt-get update.... installed docker and lando as deb file.
mkdir test1, cd test1, lando init, lando start .... WORKS PERFECT...

@marceldobrica

This comment has been minimized.

Copy link
Author

marceldobrica commented Oct 3, 2018

ON CENTOS7 dosen't work.
Same as with ubuntu18 and Lubuntu18.... in container, in /tmp file remains drush.phar with user/group 33/33 and it can't be moved by user www-data from container.

@marceldobrica

This comment has been minimized.

Copy link
Author

marceldobrica commented Oct 3, 2018

On Ubuntu 18.04 now works... It is strange... After lando destroy, lando start.... it seams to work ok even in Ubuntu...
What is different: after lando start, now on terminal I have:

landoproxyhyperion5000gandalfedition_proxy_1 is up-to-date
Creating network "drupal8test_default" with the default driver
Creating volume "drupal8test_data" with default driver
Creating volume "drupal8test_appserver" with default driver
Creating volume "drupal8test_data_database" with default driver
Creating drupal8test_appserver_1 ... done
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 600 0 600 0 0 872 0 --:--:-- --:--:-- --:--:-- 872
100 303k 100 303k 0 0 68892 0 0:00:04 0:00:04 --:--:-- 93763
Drush Launcher Version: 0.6.0
Killing drupal8test_appserver_1 ... done
Starting drupal8test_appserver_1 ... done
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 713k 100 713k 0 0 430k 0 0:00:01 0:00:01 --:--:-- 430k
Killing drupal8test_appserver_1 ... done
Creating drupal8test_database_1 ... done
Starting drupal8test_appserver_1 ... done
Creating drupal8test_nginx_1 ... done
Waiting until nginx service is ready...
Waiting until database service is ready...
Waiting until appserver service is ready...
Waiting until nginx service is ready...
...
BOOMSHAKALAKA!!!

So this time after curl drush.phar is killing appserver and starting it again.... curl drupal console... then killing appserver and starting it again....

Why is so different? IT IS SO STRANGE...

@marceldobrica

This comment has been minimized.

Copy link
Author

marceldobrica commented Oct 4, 2018

I think a better documentation about what options we have for config would help.

@marceldobrica

This comment has been minimized.

Copy link
Author

marceldobrica commented Nov 6, 2018

I'm reopening this issue because too often appears on Ubuntu. I really don't know what to do. Sometimes destroy and start works ... to often rebuild dosen't work...
A solution may be to ... install_dependencies_as_root ?????

in ~/.lando/logs/lando.log
153 {"type":"php:7.1","via":"apache","ssl":true,"xdebug":false,"webroot":"lightning/docroot","config":{"conf":"/home/marcel/.lando/services/config/drupal8/php.ini"},"install_dependencies_as_me_internal":["cd /tmp && curl https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar -L -o drush.phar && chmod +x drush.phar && ./drush.phar --drush-launcher-version && mv drush.phar /usr/local/bin/drush","cd /tmp && curl https://drupalconsole.com/installer -L -o drupal.phar && chmod +x drupal.phar && true && mv drupal.phar /usr/local/bin/drupal"],"overrides":{"services":{"volumes":["/var/www/.drush","/var/www/.drupal"]}},"_app":"landolightning","_root":"/home/xxxxx/landoprojects/lando-lightning","_mount":"/app","version":"7.1","level":"debug","message":"Building appserver with config","timestamp":"2018-11-06T09:04:31.440Z"}

On terminal:
Creating landolightning_appserver_1 ... done
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 600 0 600 0 0 1420 0 --:--:-- --:--:-- --:--:-- 1421
100 303k 100 303k 0 0 167k 0 0:00:01 0:00:01 --:--:-- 290k
Drush Launcher Version: 0.6.0
mv: cannot create regular file '/usr/local/bin/drush': Permission denied
error: Looks like one of your build steps failed with [object Object]
warn: This MAY prevent your app from working
warn: Check for errors above, fix them, and try again
Creating landolightning_database_1 ... done
Starting landolightning_appserver_1 ... done
Waiting until database service is ready...
...
In CONTAINER
lando ssh
www-data@c1fa3dd02ac1:/app$ cd /tmp
www-data@c1fa3dd02ac1:/tmp$ ls
drush.phar
www-data@c1fa3dd02ac1:/tmp$ mv drush.phar /usr/local/bin/drush
mv: cannot remove 'drush.phar': Operation not permitted
www-data@c1fa3dd02ac1:/tmp$ ls -la
total 312
drwxrwxrwt 1 root root 4096 Nov 6 09:06 .
drwxr-xr-x 1 root root 4096 Nov 6 09:06 ..
-rwxr-xr-x 1 33 33 310920 Nov 6 09:04 drush.phar

@marceldobrica marceldobrica reopened this Nov 6, 2018

@marceldobrica

This comment has been minimized.

Copy link
Author

marceldobrica commented Nov 6, 2018

www-data@c1fa3dd02ac1:/tmp$ id -u www-data
1000

@pirog pirog added this to the RC1 milestone Nov 28, 2018

@pirog pirog self-assigned this Nov 28, 2018

@generalredneck

This comment has been minimized.

Copy link
Contributor

generalredneck commented Dec 1, 2018

FYI... a workaround for this is to use tooling to override...
something like

tooling:
  drush:
    cmd: "/app/vendor/bin/drush --root=/app/web"
@marceldobrica

This comment has been minimized.

Copy link
Author

marceldobrica commented Dec 2, 2018

@generalredneck ... if I get the error "mv: cannot create regular file '/usr/local/bin/drush': Permission denied"... i'm usually destroying, rebuilding lando containers until works... sometimes works sometimes not... that's annoying... I think this error appears only on some linux systems... I haven't tried lando on Windows or Mac... more often after destroying containers everything works perfect... if I'm rebuilding containers not always works.... so usually I'm destroying containers... your solution also works but if drush dosen't work drupal console which is downloaded after drush dosen't download at all.... for me is better to destroy/rebuild and start again...if you have same problem after destroy/rebuild containers usually works...

@generalredneck

This comment has been minimized.

Copy link
Contributor

generalredneck commented Dec 2, 2018

Totally get it. I experience the same. as you can see here on my ubuntu 18.04 machine using 3.0.0-rc.1:
image
The difference is that I also added "drupal" to my tooling since I was having the same issues. Here is my full .lando.yml

name: open-kj-drupal
recipe: drupal8
config:
  webroot: web
tooling:
  drush:
    cmd: "/app/vendor/bin/drush --root=/app/web"
  drupal:
    cmd: "/app/vendor/bin/drupal"

Destorying and rebuilding is a craps shoot so I bent it to my will... was tired of rebuilding.

@robertgarrigos

This comment has been minimized.

Copy link

robertgarrigos commented Dec 14, 2018

I had this same problem and found it was related to apparmor. I had to enable it again (I disabled due to other problems I had with it). This error disappeared after enabling apparmor again.

@agilmore

This comment has been minimized.

Copy link

agilmore commented Jan 12, 2019

I seem to have resolved this locally by adding myself to the www-data group, the /usr/local/bin directory within the container is owned by www-data so I thought I'd give it a try, I don't really understand why this worked if I'm honest!

@robertgarrigos

This comment has been minimized.

Copy link

robertgarrigos commented Jan 13, 2019

This worked for me, at least once. I'll keep an eye on it. Thanks.

@pirog

This comment has been minimized.

Copy link
Member

pirog commented Jan 24, 2019

Alright so i was not able to replicate this issue ... but i was able to at least confirm the underlying problem which is a race condition, although a different one than the one mentioned up the thread here.

For those of you that are curious the issue here is that Lando does Linux permission mapping whenever one of the containers it manages starts up. This is a blocking operation to the process that the container ultimately runs with but it is not blocking to any docker execs that happen once the container has started. This causes a race between the start up user permission script and any docker exec that happens (like installing drush) directly after the container is started. The intermittent nature of the condition is likely impacted by the speed of the users computer and probably more importantly in the case of installing drush, the speed of the internet.

Good news here is that i think we should be able to resolve this by adding the user perm handling script before any build steps run which should make it blocking and eliminate the race condition.

Flagged this as a critical issue that needs to be in RC2

@pirog pirog added the bug label Jan 24, 2019

pirog added a commit that referenced this issue Jan 24, 2019

@pirog pirog referenced this issue Jan 24, 2019

Closed

wp: not found #1170

@pirog

This comment has been minimized.

Copy link
Member

pirog commented Jan 24, 2019

Alright alright alright!

Fix has been merged into the rc2 branch and will be in the next release. Going to close this for now

@pirog pirog closed this Jan 24, 2019

@nylen

This comment has been minimized.

Copy link

nylen commented Jan 25, 2019

@pirog do you know approximately when 3.0.0-rc2 will be out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment