Roots Discourse

Create symlinks for files

Using Bridge theme (for my sins) and I’m trying to set up symlinks for CSS/JS files that are created or updated when saving the theme options. I’m editing project_shared_children in roles/deploy/default/main (see in repo). The comments here state if the files/folders don’t exist, they will be created, yet I keep getting ‘file is absent’ errors.

If I symlink the whole folder, then create the files by saving the theme options and then list the files under project_shared_children, deploy works. I can remove the whole folder symlink then, too.

Here’s one of the files I’m trying to symlink:

project_shared_children:
    - path: web/app/uploads
      src: uploads
    - path: web/app/themes/bridge/css/custom_css.css
      src: themes/bridge/css/custom_css.css
      mode: "0755"
      type: "file"

And the error:

failed: [staging] (item={u'path': u'web/app/themes/bridge/css/custom_css.css', u'type': u'file', u'mode': u'0755', u'src': u'themes/bridge/css/custom_css.css'}) => {"failed": true, "item": {"mode": "0755", "path": "web/app/themes/bridge/css/custom_css.css", "src": "themes/bridge/css/custom_css.css", "type": "file"}, "msg": "file (/srv/www/domain.com/shared/themes/bridge/css/custom_css.css) is absent, cannot continue", "path": "/srv/www/domain.com/shared/themes/bridge/css/custom_css.css", "state": "absent"}

My question is: is Trellis meant to create this file if it doesn’t exist as indicated in the comments, or is that only relevant to folders and we have to manually create the files ourselves?

1 Like

Having the same issue here. Did you ever find a solution?

@dalepgrant @Luke_Abell Thank you for these notes!

I’ve proposed a fix in roots/trellis#706. Would love to know if it solves it for you.

Note that with the current setup, the shared file /srv/www/example.com/shared/themes/bridge/css/custom_css.css would always overwrite a file deployed with your project at web/app/themes/bridge/css/custom_css.css. So, without more setup, your deploy would not update custom_css.css with changes from your git repo.

With a lot of helpful review and suggestions from @swalkinshaw, the fix in roots/trellis#706 has been merged.

1 Like

Thanks @fullyint! Not tested yet but I’ll report back here with any issues/findings.

Been a while, but for anyone with the same issue using Bridge theme, specifically:

example.com.au:
    site_hosts:
    - canonical: www.example.com.au
    ...
    project_shared_children:
      - path: web/app/uploads # Needs to be here.
        src: uploads          # Needs to be here.
      - path: web/app/themes/bridge/css/style_dynamic.css # Bridge theme dynamic asset
        src: bridge/dynamic_assets/style_dynamic.css      # Bridge theme dynamic asset
        type: file
      - path: web/app/themes/bridge/css/style_dynamic_responsive.css # Bridge theme dynamic asset
        src: bridge/dynamic_assets/style_dynamic_responsive.css      # Bridge theme dynamic asset
        type: file
      - path: web/app/themes/bridge/js/default_dynamic.js # Bridge theme dynamic asset
        src: bridge/dynamic_assets/default_dynamic.js     # Bridge theme dynamic asset
        type: file

You’ll need to deploy & save theme options. Then on subsequent deploys you won’t need to save theme options again.

The files will be created under /srv/www/example.com.au/shared/bridge/dynamic_assets on the server.

1 Like