zepgram / magento2-fast-vm

Optimal vagrant developer box for Magento2. Folders synced by nfs/rsync. This box includes Magento developer utilities.
MIT License
110 stars 35 forks source link

Magento pre-installation sequence - Operation Not Permitted #53

Closed Jkrane closed 4 years ago

Jkrane commented 4 years ago

I am having an issue where the chown command is NOT affecting the ownership of '/home/vagrant/magento'.

My Computer and VB/Vagrant: Mac OSX, Vagrant 2.2.7, VirtualBox Version 5.2.26 r128414 (Qt5.6.3)

Here is how I have the config.yaml file setup:

vmconf: machine_name: 'Vagrant Magento 2' network_ip: '192.168.60.6' host_name: 'local' memory: '4096' cpus: '1' mount: 'nfs' path: 'root' provision: 'all' composer: username: 'omitted' password: 'omitted' git: name: 'omitted' email: 'omitted@omitted.com' host: 'magento.cloud' repository: 'ssh://omitted@git.us-3.magento.cloud:omitted.git' magento: url: 'magento.leupold.test' source: 'integration' edition: 'enterprise' version: '2.3.4' php_version: 'default' sample: 'true' mode: 'developer' currency: 'USD' language: 'en_US' time_zone: 'America/Los_Angeles' crypt_key: ''

Pretty standard, except I am hoping to checkout the integration branch of our magento cloud repo.

The issue doesn't seem to get as far as checking pout from our repo, I get an error during the "Magento pre-installation sequence". Here is what I see:

local: chown: 
local: changing ownership of '/home/vagrant/magento'
local: : Operation not permitted

This causes the, "Magento Installation Sequence" to fail: local: --- Magento installation sequence --- local: Cloning into '/home/vagrant/magento'... local: fatal: No path specified. See 'man git-pull' for valid url syntax local: fatal: Not a git repository (or any parent up to mount point /home/vagrant/magento) local: Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). local: fatal: Not a git repository (or any parent up to mount point /home/vagrant/magento) local: Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). local: Composer could not find a composer.json file in /home/vagrant/magento local: To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section local: chmod: local: cannot access '/home/vagrant/magento/bin/magento' local: : No such file or directory local: sudo local: : local: /home/vagrant/magento/bin/magento: command not found local: sudo local: :

I vagrant ssh in after the errors to try the chown command used in the "Magento pre-installation sequence".

chown -R vagrant:vagrant /home/vagrant

Running this from the /home/vagrant directory, nothing happens!

If I run:

sudo chown -R vagrant:vagrant /home/vagrant

I get: chown: changing ownership of './magento': Operation not permitted

Am I missing something here? I am using the NFS setting on a Mac. I have used synced folders in the past with no issue.

zepgram commented 4 years ago

Hi Jkrane,

BindFS force permissions for NFS mount:

  config.bindfs.default_options = {
    force_user:   'vagrant',
    force_group:  'www-data',
    perms:        'u=rwx:g=rwx:o=r'
  }

So this is usual behavior, you can only set user to vagrant and group to www-data. And these permissions are enough to write and read directories, even with an other user. Could you try to clone this repository manually with NFS enabled ?

Jkrane commented 4 years ago

Benjamin, I am not sure I understand what you mean by cloning the repo manually with NFS enabled, as I have NFS enabled. Right?

Doesn't setting the mount to NFS do that?

Thanks, Jon

Jkrane commented 4 years ago

Here is what I am seeing when I vagrant ssh in:

vagrant@local:~/magento$ cd .. vagrant@local:~$ ls -lA total 48 drwx------ 3 vagrant vagrant 4096 Feb 9 19:50 .ansible -rw-r--r-- 1 vagrant vagrant 220 Feb 9 19:48 .bash_logout -rw-r--r-- 1 vagrant vagrant 3629 Feb 11 19:00 .bashrc drwxr-xr-x 4 vagrant vagrant 4096 Feb 11 19:05 .composer drwxr-xr-x 2 vagrant vagrant 4096 Feb 11 19:00 extra -rw-r--r-- 1 vagrant vagrant 84 Feb 11 19:05 .gitconfig drwxr-xr-x 2 466801362 1119337710 64 Feb 11 19:05 magento -rw-r--r-- 1 vagrant vagrant 9490 Jan 22 19:28 percona-release_latest.stretch_all.deb -rw-r--r-- 1 vagrant vagrant 675 Feb 9 19:48 .profile drwx------ 2 vagrant vagrant 4096 Feb 11 19:05 .ssh -rw-r--r-- 1 vagrant vagrant 5 Feb 9 19:49 .vbox_version

I am pretty sure vagrant creates that magento directory too...

zepgram commented 4 years ago

Yep vagrant create the repository on first start-up. Then clone is done during provisioning. Anyway, for me the issue is related to your settings for "host" under git node.

I'm suspecting this command didn't accomplish his work: ssh-keyscan -t rsa ${PROJECT_HOST_REPOSITORY} >> /home/vagrant/.ssh/known_hosts This allow us to clone the repository without interaction with command line interface, if the host is not correctly assigned the clone will fail. According to your git repository, the correct host in config.yaml should be: git.us-3.magento.cloud

Can you re-run the vagrant provisioning with this new settings ?

Jkrane commented 4 years ago

Benjamin, That fixed the issue. I had the wrong host in there! THANKS!

Moving on, nginx will not start in Vagrant:

When it is starting up, in the "/etc/nginx/sites-enabled/010-magento" file, it tries to include: /home/vagrant/extra/magento.nginx.conf

That file is not present when the $PROJECT_SOURCE is not "composer".

How is the nginx.conf file supposed to be included for non-"composer" builds?

zepgram commented 4 years ago

Nice for the host :+1:

Concerning the include, it's the default nginx configuration file for magento, I copy this file during the post installation phase from the root project: https://github.com/zepgram/magento2-fast-vm/blob/master/provision/120-magento-post.sh#L33

If this file is not in your project you just have to add it, it can be found here from magento repository: https://github.com/magento/magento2/blob/2.4-develop/nginx.conf.sample

Jkrane commented 4 years ago

I am up and going. Thank you so much for your help.

Jkrane commented 4 years ago

I used the vagrant file to copy over the nginx.conf.example during provisioning:

if File.file?('nginx.conf.sample') config.vm.provision 'file', source: 'nginx.conf.sample', destination: '/home/vagrant/nginx.conf.sample', run: 'always' end

I then edited the 120-magento-post.sh file, I added the else condition:

else if [ -f "/home/vagrant/nginx.conf.sample" ] && [ ! -f "/home/vagrant/nginx.conf" ]; then sudo -u vagrant cp /home/vagrant/nginx.conf.sample /home/vagrant/nginx.conf fi if [ -f "/home/vagrant/nginx.conf" ]; then sudo -u vagrant cp /home/vagrant/nginx.conf /home/vagrant/extra/${PROJECT_NAME}.nginx.conf; fi fi