It was recently suggested to me that while working on a contrib projects, I could place a symlink in my local dev site to the local  git repo of the contrib module to avoid putting one git repo inside of another.  However, I'm working with Lando and this doesn't seem to work so well. I'm not sure that Lando knows how to look outside of the container with a symlink. 

I found this article which seems to be describing the same thing - https://leoloso.com/posts/lando-symlinks/

My attempt to set this up doesn't work. I have this in my .lando.yml file 

services:
  phpmyadmin:
    type: phpmyadmin
    hosts: database
  type: 
    php: 7.3
  appserver: 
    build:
      - wget -qO bee.zip https://github.com/backdrop-contrib/bee/archive/1.x-1.x.zip
      - unzip -q bee.zip && rm bee.zip
      - mv bee-1.x-1.x /usr/local/bin/bee
    extras:
      - apt-get update && apt install vim -y
    run_as_root:
      - ln -snf /home/tim/Sites/backdropcms/theme-projects/snazzy /app/themes/snazzy

In the site directory, when I navigate to /themes/snazzy/ - it seems to take me to the correct directory. 

However, snazzy is not showing up as an option in Backdrop CMS. 

Has anyone else done this successfully?

----------------

Just to repeat for clarification. If I follow the instructions in the blog post and configure my .lando.yml file as shown above. The symlink gets created when I start lando. I am able to navigate to the destination on the command line, using the symlink. BUT, the module or theme is not showing up in Backdrop CMS as expected. 

I'm not sure how to debug this any further. All suggestions would be welcome. 

Comments

Is this repo intended to be used for a production website, or is it just for local testing and development of themes/modules? 

Production

If you are using it for a production site, you can use the building scheme you used for installing bee.  In your code above, you download the latest version as a zip file, and install it into a proper location.  Then commit the code, and no worry about a git repo inside a git repo.  Every time you rebuild your containers, you get the latest version.

By selecting a tag or even a commit, you can lock your version if you need to.  

Git Repo Inside a Repo

In the outermost git repo, just ignore the module or theme folder. Then checkout the module repo in the ignored namespace.  

This will avoid committing the project within the outside git repo.  

Git Submodules

Of course you are not the only person to have this issue, and GIT provides an elegant solution to this problem with  Git Submodules. https://git-scm.com/book/en/v2/Git-Tools-Submodules

From your example just run this command:

`git submodule add /url-to-git-project/theme/snazzy`

When you clone a new project use:

`git clone --recurse-submodules  /full-project-github-url`

 

From my own experience, Git is a lot smarter than you or me, so just get googling and learn something new!

@wylbur - Thanks much, this is all very helpful.  I am not using this for production. I only use Lando for local development. Your suggestions would be an improvement over my current situation, but are not quite as good as the symlink solution in the following respect. 

I was hoping that I could (for example) clone the repo for a contrib project such as Opera theme, into a special place on my hard drive. Then, when working on a local project with Opera, I could just create a symlink to the definitive local copy and make all my changes to the theme in the definitive version.  In the last two weeks, I have used Opera on at least two different projects locally and found things that needed fixing. The Symlink solution allows me to make changes to the definitive local version but see the effects in whatever project I happen to be working on. 

The git repo within a git repo option means that I might have multiple local copies of Opera on my drive at any one given moment, any one of which I might be using to make changes that need to be pushed to the upstream repo.

As long as I keep pushing those changes to the upstream and keep each version current (git pull upstream), this doesn't have to be a problem. Yes, GIT is set up for exactly this kind of thing.

It's a bit frustrating, because I've found multiple people reporting to use Symlinks with Lando in exactly the way I envisioned, but it just isn't working for me. What am I missing? (rhetorical question) Thanks for your help.