Plugin Development Using Git-based Source Code Repository Hosting Service

Good day fellow Developers!

I currently installed Open EdX tutor (nutmeg) on my remote instance via AWS. I am quite new to this so please bear with my low-level programming skills.

I am using a software called PUTTY to reach my instance remotely via SSH.

I installed tutor there and I would like to install additional plugins available such as android, richie, etc. I would like to configure my plugins via VS Code because editing it in putty is quite difficult and I know that the only way to do it so is to clone it in my git-based source code repository hosting service (I am using BITBUCKET on my end), clone it in my local computer, then open it in VS Code. If I finished my changes, I will git pull it from the Bitbucket, then git pull it in my remote instance. But here’s my problem…

  1. I cannot locate the repository of my plugin (for example: the richie plugin) in my instance.
  2. If ever I find it, I don’t know how I could clone it in Bitbucket.

Furthermore, I don’t even know if I can even configure the plugins. I hope someone could help me. Thank you!

Welcome! Hopefully, I can point you to a few resources to get your going.

Firstly, using VS Code for development: Follow the Developing on Remote Machines using SSH and Visual Studio Code instructions to set up VS Code to access your VPS remotely.

  1. You will install this dev pack: Remote Development - Visual Studio Marketplace

  2. Here is a sample SSH config entry to place in your c:\users\MyUser\.ssh\config file (or equivalent on a Mac)

     Host edx-dev
        # Or use a FQ domain name
        HostName 1.2.3.4
        User edx
        Port 22
        # If using an SSH (in Windows), use this syntax. 
        # You can omit for password-based authentication (I think)
        IdentityFile "C:/Users/user/ssh-keys/edx@edx-dev.key"
    

Secondly, developing locally without a repository: The documentation at Open edX development — Tutor documentation is comprehensive, but there are a few holes.

  1. Put the dev DNS entries in your hosts file. On Windows, this is: C:\Windows\System32\drivers\etc\hosts

    Note! You must access the Open edX dev instance using the domain names listed below. Using localhost:8001 to access studio will not work.

    127.0.0.1    local.overhang.io
    127.0.0.1    studio.local.overhang.io
    127.0.0.1    preview.local.overhang.io
    127.0.0.1    apps.local.overhang.io
    
  2. You’ll have to set the port forwards in VS Code

    By default, Developing on Remote Machines using SSH and Visual Studio Code adds port forwarding for 8000. You will need to port 8001. You can also add additional port forwards for your apps

    Click the port tab (next to the terminal tab). Add these ports

    8000  ---> LMS
    8001  ---> CMS
    2000  ---> Learning (apps)
    8100  ---> XBlock dev
    
  3. You can clone a repository and add it to the requirements/private.txt file

    cd $(tutor config printroot)/env/build/openedx/requirements
    git clone https://url.to.repo/mypackage
    echo "-e ./mypackage" >> private.txt
    
  4. Then, rebuild your images to include the repository. Once rebuilt to include the new plugin, saving the modified code files in the requirements folder should trigger a recompile.

Regarding this, you’ll have to clone it from GitHub - openfun/tutor-contrib-richie: Tutor plugin for integration of Open edX with a Richie course catalog.

For a final point, there are plugins and XBlocks. They are different. :slight_smile: I’m not sure in which category the Richie plugin fits.

Thank you for this. I tried this method as well, but the only disadvantage of using this approach is that this method cannot access the hidden files that is accessible in putty. Take note of this as an example:

cd $(tutor config printroot)/env/build/openedx/requirements

where in this line, this locates to

root/.local/share/tutor//env/build/openedx/requirements.

I’m not sure that I’m following you entirely. Putty is just an SSH client, similar to using the command prompt to initiate an SSH session. Shell access using modern clients (PuTTY, MobaXterm, VS Code, ssh, etc.) should offer the same functionality. Basically, all SSH connections are equal. :slight_smile:

The command tutor config printroot simply prints the location of your Open edX Tutor folder. Encapsulating that command in another command allows for dynamic paths. For example, running this command will print the location of my installation, which is different from yours.

user@edx:~$ tutor config printroot
/home/user/.local/share/tutor
user@edx:~$ echo $(tutor config printroot)
/home/user/.local/share/tutor
sysadmin@edx:~$ 

Using Tutor as root might cause some permission or other problems (or so I’ve read). The recommended method is to use a regular user with sudo privileges.

For example:

# This command creates a user called "edx", but you can use any name
useradd -d /home/edx -m edx -s /bin/bash

# Set the password
passwd edx

# Add to sudo group
usermod -aG sudo edx

# Add the non-root user to the docker group
# https://docs.docker.com/engine/install/linux-postinstall/
groupadd docker
usermod -aG docker edx
newgrp docker

If you continue to have problems, you might stop and remove the version in root and then run tutor dev quickstart as your non-root user.

Thank you for this. I clearly understood everything you’ve indicated in this topic. In fact, I’ve followed your instructions and it is a great help. But the problem is still there because I cannot view the hidden directories. To make it clear, my only concern is that the hidden directories/files are not displaying in my VS Code. For an instance, consider these images:

Based on the image above, in my terminal via SSH, I can cd to hidden directories. I entered
cd $(tutor config printroot) and it located me to /home/ubuntu/.local/share/tutor
using the ls command, I can view the files inside this directory such as config.yml, data, env
But again. I entered that directory via SSH TERMINAL.

Now I want to go to that same directory in my VS code and view the whole repositories. But here’s what is inside my /home/ubuntu/ directory when I open it via Remote-Containers (Open Folder in Container):

image

As you can see in the image above, I can’t locate the hidden file .local/share/tutor.

Therefore I cannot open the config.yml file in my VS Code. Take note that my user ubuntu has sudo privileges.

Is there a way where I can view these hidden directories/files via VS Code and not just the SSH terminal???

Glad to hear that it has been helpful!

Now I understand. You can view hidden files and directories using ls -a, or display the file properties in a list using ls -lha

The problem here is that your Tutor installation is likely in /root, not in /home/ubuntu. To work with files in the /root directory in VS Code, you’ll have to log in as root, not as ubuntu. Even though you can su to root in the terminal, the files in the tree are still limited to your non-privileged user. You might have to modify the /root/.ssh/authorized_keys file to allow root SSH login.

Also, even though you are in the /home/ubuntu directory, you changed to root using sudo su. Therefore, the home directory marker ~ will point to /root, not to /home/ubuntu.

You can verify if the files are in your /home/ubuntu directory or not:

ls -lh /home/ubuntu/.local/share/

# Expected output (you should see tutor here).
drwx------ 2 ubuntu ubuntu 4.0K Mar 12  2021 nano
drwxrwxr-x 4 ubuntu ubuntu 4.0K Apr 16  2021 tutor
drwxrwxr-x 3 ubuntu ubuntu4.0K Aug 22 10:05 tutor-plugins

To confirm, this does work if the logged-in user has access to the files:

You are right. I tried the ls -lh /home/ubuntu/.local/share/ command and it returned an error indicating that it is not there.

So i tried ls -lh /root/.local/share/ and returned this:

image

Therefore it is in the root directory. But still if I open the root directory in my VS Code, the root directory is empty.

image

Thank you for your quick response though. I appreciate that. Please bear with my lack of knowledge regarding this matter. Quite new to this :sweat_smile:

The problem here is that your Tutor installation is likely in /root, not in /home/ubuntu. To work with files in the /root directory in VS Code, you’ll have to log in as root, not as ubuntu. Even though you can su to root in the terminal, the files in the tree are still limited to your non-privileged user. You might have to modify the /root/.ssh/authorized_keys file to allow root SSH login.

Regarding this, I think this might be the problem.

My configuration file appears to be like this:

Host <host_title>
HostName <my_domain>
User ubuntu
Port 22
IdentityFile <my_pem_key>

Should I change anything here? If not, how can I enter the sudo privileges in my Remote-Containers? Is there a detailed instruction to which I can modify the /root/.ssh/authorized_keys file to allow root SSH login?

We all start there. :slight_smile:

Duplicate that entry and change the values so that you can log in as root and ubuntu depending. The only thing you will change is the User field.

Host <host_title>
    HostName <my_domain>
    User root
    Port 22
    IdentityFile <my_pem_key>

Next, you will need to add your public key from ubuntu to the root profile. Let’s keep it simple and copy the auth key file to root (with the understanding of security risks).

sudo su
cd ~

# verify you are in /root
pwd

# rename the default root authorized_keys file
mv ~/.ssh/authorized_keys ~/.ssh/authorized_keys.bak

# create a copy of the ubuntu user's auth key file
cp /home/ubuntu/.ssh/authorized_keys ~/.ssh/authorized_keys

# verify that both are identical
cat /root/.ssh/authorized_keys
cat /home/ubuntu/.ssh/authorized_keys

I don’t think that the default sshd_config config limits root login, so the above should work.

Later, you should consider adding a layer of security if you will keep the root login open.

# edit the sshd_config and disable root login with a password by adding this setting:
nano /etc/ssh/sshd_config

PermitRootLogin prohibit-password

# test the config (returns an empty result if the config is valid)
sshd -t

# Then, apply the config. 
systemctl restart sshd

IT WORKED! I can now access the hidden directories by entering as root user :smile:
Now I can also edit the cloned repository added in
$(tutor config printroot)/env/build/openedx/requirements (which in my case are plugins) and it is working! By editing these repositories, I can now configure my plugins.

Thank you so much! Will mark your explanation as a Solution now.

1 Like

I installed tutor there and I would like to install additional plugins available such as android, richie, etc.

I would like to configure my plugins via VS Code because editing it in putty is quite difficult and I know that the only way to do it so is to clone it in my git-based source code repository hosting service I am using BITBUCKET on my end, clone it in my local computer.

Then open it in VS Code. If I finished my changes, I will git pull it from the Bitbucket, then git pull it in my remote instance. But here’s my problem.

Reliable Permit Solutions, LLC