FMCorz / mdk

Moodle Development Kit. A collection of tools meant to make developers' lives easier.
GNU General Public License v3.0
84 stars 47 forks source link

help needed with ubuntu 18.04 #209

Closed marcoblancas closed 2 years ago

marcoblancas commented 2 years ago

My mdk environment was working and something has broken.

isaac.marco@portatil108 ~ $ mdk create -e mysqli -n test --version 311
Creating instance test...
Cloning stable repository into cache...
This is going to take a while...
Cloning repository...
Could not create symbolic link. Please manually create: ln -s /home/isaac.marco/git/moodles/test/extra /home/isaac.marco/git/moodles/www/mdk/test
Checking out branch...
Error creating test:
  This is not a Git repository
Traceback (most recent call last):
  File "/home/isaac.marco/.local/lib/python3.7/site-packages/mdk/commands/create.py", line 173, in do
    M = self.Wp.create(**kwargs)
  File "/home/isaac.marco/.local/lib/python3.7/site-packages/mdk/workplace.py", line 181, in create
    repo.delRemote('origin')
  File "/home/isaac.marco/.local/lib/python3.7/site-packages/mdk/git.py", line 116, in delRemote
    result = self.execute(cmd)
  File "/home/isaac.marco/.local/lib/python3.7/site-packages/mdk/git.py", line 124, in execute
    raise Exception('This is not a Git repository')
Exception: This is not a Git repository

Process complete!

I have uninstalled and reinstalled everything following https://github.com/FMCorz/mdk/wiki/FAQ#i-upgraded-mdk-from-1xx-to-2xx-and-it-stopped-working , but I think I was on 2xx

mdk doctor show some dependencies not found but I think those are not required for me, but not sure...

$ mdk doctor --all
Checking directories
Checking cached repositories
Checking dependencies
  The path to 'recess' is invalid: /usr/local/bin/recess
  The path to 'grunt' is invalid: /usr/local/bin/grunt
  The path to 'lessc' is invalid: /usr/local/bin/lessc
  The path to 'shifter' is invalid: /usr/bin/shifter
  The path to 'yuidoc' is invalid: /usr/local/bin/yuidoc
Checking remotes
Checking wwwroot
Checking symlinks
Checking integration instances branches
Checking master branch

My .moodle-sdk has just the config.json and no directory with the cached moodle repository is found, but I don't know if now this is in other place.

During the installation process or initialization none download from github happened.

Please help.

FMCorz commented 2 years ago

Hi @marcoblancas,

That is an odd issue.

If the folder is ~/.moodle-sdk/moodle.git is not a git repository, then MDK won't be able to clone it. There may be permission issues with the ~/.moodle-sdk folder. Please run mdk config set debug debug, and run mdk create again.

The MDK doctor errors shouldn't be an issue for creating instances.

marcoblancas commented 2 years ago

Thank you @FMCorz , the mdk config set debug debug was a good trick.

I think the problem arrived some weeks ago with the ~/.moodle-sdk/moodle.git because the remote origin path from github required to be changed... but I don't remember the problem. This weekend I removed completely this folder and recovered it with:

$ git@github.com:moodle/moodle.git /home/isaac.marco/.moodle-sdk/moodle.git 

By other hand I followed https://moodle.org/mod/forum/discuss.php?d=352360#p1462765 and then I was able to run succesfully the command:

$ mdk create -n testxx 

but this other was failing:

$ mdk create -n testxx  -v 311

My ~/.moodle-sdk/moodle.git is a git repository and no problems with permissions are detected.

isaac.marco@portatil108 ~ $ cd ~/.moodle-sdk/moodle.git
isaac.marco@portatil108 ~/.moodle-sdk/moodle.git (master=) $ git remote -v
origin  git@github.com:moodle/moodle.git (fetch)
origin  git@github.com:moodle/moodle.git (push)

Now I try with debug enabled:

isaac.marco@portatil108 ~/.moodle-sdk/moodle.git (master=) $ mdk config set debug debug
isaac.marco@portatil108 ~/.moodle-sdk/moodle.git (master=) $ mdk create
Creating instance stable_master...
Error creating stable_master:
  The Moodle instance stable_master already exists

Process complete!

That's OK because I have and instance named with stable_master. Should I remove it?

Retry the same with a different instance name:

isaac.marco@portatil108 ~/.moodle-sdk/moodle.git (master=) $ mdk create -n test01
Creating instance test01...
Fetching cached repository moodle.git...
/usr/bin/git fetch
Cloning repository...
/usr/bin/git clone --branch master --single-branch /home/isaac.marco/.moodle-sdk/moodle.git /home/isaac.marco/git/moodles/test01/moodle
Checking out branch...
/usr/bin/git remote rm origin
/usr/bin/git remote -v
/usr/bin/git remote add github git@github.com:marcoblancas/moodle.git
/usr/bin/git remote -v
/usr/bin/git remote add origin /home/isaac.marco/.moodle-sdk/moodle.git
/usr/bin/git fetch origin
/usr/bin/git show-ref --verify --quiet refs/heads/master
/usr/bin/git checkout master
/usr/bin/git pull origin
/usr/bin/git remote -v
/usr/bin/git config --get remote.origin.url

Process complete!
isaac.marco@portatil108 ~/.moodle-sdk/moodle.git (master=) $ cd /home/isaac.marco/git/moodles/test01/moodle
isaac.marco@portatil108 ~/git/moodles/test01/moodle (master) $ git status
En la rama master
nada para hacer commit, el árbol de trabajo está limpio

Everything it's OK.

Now I try the same with a moodle version 3.11

isaac.marco@portatil108 ~/git/moodles/test01/moodle (master) $ mdk create -v 311 -n test02
Creating instance test02...
Fetching cached repository moodle.git...
/usr/bin/git fetch
Cloning repository...
/usr/bin/git clone --branch MOODLE_311_STABLE --single-branch /home/isaac.marco/.moodle-sdk/moodle.git /home/isaac.marco/git/moodles/test02/moodle
Checking out branch...
Error creating test02:
  This is not a Git repository
Traceback (most recent call last):
  File "/home/isaac.marco/.local/lib/python3.7/site-packages/mdk/commands/create.py", line 173, in do
    M = self.Wp.create(**kwargs)
  File "/home/isaac.marco/.local/lib/python3.7/site-packages/mdk/workplace.py", line 181, in create
    repo.delRemote('origin')
  File "/home/isaac.marco/.local/lib/python3.7/site-packages/mdk/git.py", line 116, in delRemote
    result = self.execute(cmd)
  File "/home/isaac.marco/.local/lib/python3.7/site-packages/mdk/git.py", line 124, in execute
    raise Exception('This is not a Git repository')
Exception: This is not a Git repository

Process complete!

I think the problem is my cached ~/.moodle-sdk/moodle.git repository has no a local MOODLE_311_STABLE branch so I force a checkout for it:

$ cd ~/.moodle-sdk/moodle.git
$ git checkout MOODLE_311_STABLE
$ git checkout master

And now it works.

isaac.marco@portatil108 ~ $ mdk create -n test07 -v 311
Creating instance test07...
Fetching cached repository moodle.git...
/usr/bin/git fetch
Cloning repository...
/usr/bin/git clone --branch MOODLE_311_STABLE --single-branch /home/isaac.marco/.moodle-sdk/moodle.git /home/isaac.marco/git/moodles/test07/moodle
Checking out branch...
/usr/bin/git remote rm origin
/usr/bin/git remote -v
/usr/bin/git remote add github git@github.com:marcoblancas/moodle.git
/usr/bin/git remote -v
/usr/bin/git remote add origin /home/isaac.marco/.moodle-sdk/moodle.git
/usr/bin/git fetch origin
/usr/bin/git show-ref --verify --quiet refs/heads/MOODLE_311_STABLE
/usr/bin/git checkout MOODLE_311_STABLE
/usr/bin/git pull origin
/usr/bin/git remote -v
/usr/bin/git config --get remote.origin.url

Process complete!

Should I to force manually the checkout for all the MOODLE_xxx_STABLE branches I whould like to be able to create new instances? Any way to force the correct git clone for my `~/.moodle-sdk/moodle.git' ?

Thank you in advance.

FMCorz commented 2 years ago

Hey @marcoblancas

Glad you could make it work, but as you noticed there are a few things that won't be working as intended.

The local cache of the Moodle repository should be a mirror, and should not be using your repository as the reference. Making it a mirror will fix the issue you had whereby you could not clone a specific branch, that is because git would not automatically sync other branches when the repo is not a mirror. And you should not be using your own repo because it's unlikely to be as up-to-date as the official Moodle repository.

For reference, here are my remotes, they haven't changed in years. Note that stable and integration ones:

$ mdk config show remotes
remotes.integration: git://git.moodle.org/integration.git
remotes.mine: git@github.com:FMCorz/moodle.git
remotes.security: git@git.in.moodle.com:integration/security.git
remotes.stable: git://git.moodle.org/moodle.git

To fix your local ~/.moodle-sdk/moodle.git, the following should work: git clone --mirror git://git.moodle.org/moodle.git

And yes, you can remove your stable_master instance if you do not need it, or if it is broken. You may need to remove it from a few of the dirs.

marcoblancas commented 2 years ago

@FMCorz , well git clone --mirror git://git.moodle.org/moodle.git was not working for me:

isaac.marco@portatil108 ~/.moodle-sdk $ git clone --mirror git://git.moodle.org/moodle.git
Clonando en un repositorio vacío 'moodle.git'...
fatal: repository 'https://git.moodle.org/moodle.git/' not found

but reviewing my .gitconfig I found this:

...
[url "https://"]
       insteadOf = git://
...

I'm not sure when or why I set this config. I have removed this. I have removed my ~/.moodle-sdk/moodle.git and now with an mdk create my ~/.moodle-sdk/moodle.git has been correctly cloned and everything is working OK.

Thank you very much. Maybe in the future this will help to somebody.

You can close the issue.

FMCorz commented 2 years ago

Glad this is resolved. Thanks for sharing that the .gitconfig setting may have been an issue.