Error running ansible-galaxy: fork/exec

Hello,

I have been at this for about 2 days now reading through old threads, and, new. Still can’t see to get this going, so decided to ask for help at this point.

I am running an M1 Macbook Pro (2021) so I followed the Github issue regarding using Parallels.

I am stuck when running trellis new sitename.com It leads off with this error:

Error running ansible-galaxy: fork/exec “INSERT PATH HERE” no such file or directory.

Then when going to run trellis up I constantly crash at:

default: [vagrant-hostmanager:guests] Updating hosts file on active guest virtual machines...
==> default: [vagrant-hostmanager:host] Updating hosts file on your workstation (password may be required)...
==> default: Running provisioner: ansible...
    default: Running ansible-playbook...
==> default: Forcing shutdown of VM...
==> default: Destroying VM and associated drives...
==> default: Destroying unused networking interface...
==> default: Pruning invalid NFS exports. Administrator privileges will be required...
Traceback (most recent call last):

Currently running: Python 3.9.10
Trellis Version: 1.5.1
Ansible Version: 2.9.27 (I have also uninstalled and reinstalled a few versions at this point based on some historical threads I have stumbled on).
VirtualEnv Version: 20.13.2
Vagrant Version: 2.2.18 (also tried 2.2.19)

In my vagrant.local.yml file

vagrant_box: 'jeffnoxon/ubuntu-20.04-arm64'
vagrant_box_version: '>= 1.0.0'

Based on this Trellis and Apple Silicon · Issue #1253 · roots/trellis · GitHub

Apologies ahead of time if I missed this resolution elsewhere, I have been digging through what feels like about 20 different posts, and blogs online for help before coming here.

If I can provide any further info I am happy to and appreciate any assistance!

Some further context, I did find this post: Error on `trellis new`: virtualenv & ansible galaxy "no such file" - githubhot

Seemed like it was a similar issue for the most part, but I wasn’t able to connect the dots and get it working. To help some more here is my terminal output when running “which” or virtualenv, trellis, python, ansible. Not sure if there is a clue here.

which virtualenv
/opt/homebrew/bin/virtualenv

which trellis
/opt/homebrew/bin/trellis

which ansible
/opt/homebrew/opt/ansible@2.9/bin/ansible

which python
python: aliased to python3

When navigating back to the project folder in terminal I get this as well:

[trellis] activated env
/dev/stdin:export:3: not valid in this context: Drive/sites/websitename.com/trellis/.trellis/virtualenv/bin:/opt/homebrew/opt/ansible@2.9/bin:/opt/homebrew/opt/ansible@2.9/bin:/opt/homebrew/opt/ansible@2.9/bin:/Users/username/.nvm/versions/node/v17.0.1/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
spaceship_jobs:3: command not found: awk
spaceship_jobs:3: command not found: wc
spaceship_jobs:3: command not found: t

Ok, so made some progress in case anyone ever stumbles on this. I need to look in the docs some more because maybe I missed this.

When trying to create the site in any folder on my machine it doesn’t work and the errors detailed in my first post happen.

If I create the projects in ~/projects/ folder it just worked. Is it not possible to map any folder I would like on the computer?

Thank you!

I’ve been dealing with similar issues, but in my case, the containing folder was something other than ~/projects/ and the project root was in a directory other than sitename.tld.

I changed sitename.tld to the actual FQDN, and I can now build/provision normally.

So, while I have not run into any requirement to organize within ~/projects/, I am a little surprised at the requirement to root the project in sitename.tld. I have two reasons for preferring to not use the site key (FQDN) as my project root:

  1. I prefer to keep as much consistency as possible between local directory names, repo names, etc, for clarity in general, but also because I have several automated workflows that depend upon my existing naming convention (which looks like site-name-com-gen4).

  2. In cases in which two projects are required to coexist on the same machine for the same site (like site-name-com-gen4 and site-name-com-gen5, for example), my existing naming convention makes life so much easier.

Any chance the apparent requirement to root in sitename.com can be opened up a bit? Or, if this is not actually a requirement, any hint as to what I might be doing wrong that would cause vagrant up (etc) to fail when rooting in a directory named something other than sitename.com?

I don’t entirely understand what you mean here. Do you mean that trellis new fails in any other directory than ~/projects/ on your computer? And you were running new with the same arguments?

trellis-cli isn’t tied to any specific parent directory, but obviously you might be running into some strange bug.

Can you please post the exact command and output you get in either case? That would help debug and identify if there’s a bug or not.

I’m hesitant to go through the errors in your original post because if you got errors initially, it might have affected something.

trellis new --help contains this example:

Specify name and host to bypass the prompts:

  $ trellis new --name example.com --host www.example.com ~/projects/foo

The new command does require an initial host and site name to be provided so it can generate the configs properly. So if you specify those explicitly, you can provide any folder path you want.

~/projects/ is just an example path by the way… there’s no requirement around using that folder.

Saw it. Misread it. Skipped it.

That’s what I get for trying something new, late on a party night. :wink:

Indeed, trellis new --name example.com --host example.com ~/Websites/example-com-gen4 has worked as needed. Thanks!

1 Like

Hey @swalkinshaw,

First, thank you for taking the time to respond. I appreciate it!

To clarify your question:

I don’t entirely understand what you mean here. Do you mean that trellis new fails in any other directory than ~/projects/ on your computer? And you were running new with the same arguments?

That is correct. I run trellis new website.com in another directory on my laptop and I am presented with the initial Ansible error message from my first post: Error running ansible-galaxy: fork/exec “INSERT PATH HERE” no such file or directory.

However, if I run the exact same command inside of the ~/projects directory there were 0 issues.

Likewise, if I ignore that error message in my custom directory and run trellis up it begins its process for a good 1.5 minutes or so and looks like it will work, but once the process hits

==> default: Running provisioner: ansible...
    default: Running ansible-playbook...

It then crashes and Destroys the VM. If I run trellis up on my project from the ~/projects directory it runs flawlessly and there are no issues.

Attached is a screenshot from the terminal when I simply run trellis new which then gives me the output of expected input since I am not providing a name. It was here that I noticed all the references to ~/projects and made me even think to test creating a new trellis project in that ~/projects folder.

I am running another new test in the folder on my machine that is not ~/projects folder and copied the output below. This is now presenting a new error where once I cd into the directory of the new site trellis and vagrant commands in the terminal are no longer recognized.

 ~/AHome File Drive/sites
  trellis new test.com
Creating new Trellis project in /Users/dalbeck/AHome File Drive/sites/test.com

Site domain [test.com]: test.com

✔ test.com
Initializing project...

[✓] Created virtualenv (/Users/dalbeck/AHome File Drive/sites/test.com/trellis/.trellis/virtualenv)
[✓] Ensure pip is up to date
[✓] Dependencies installed

Error running ansible-galaxy: fork/exec /Users/dalbeck/AHome File Drive/sites/test.com/trellis/.trellis/virtualenv/bin/ansible-galaxy: no such file or directory

test.com project created with versions:
  Trellis v1.14.0
  Bedrock v1.19.1

in ~/AHome File Drive/sites took 56s

  cd test.com
[trellis] activated env
/dev/stdin:export:3: not valid in this context: Drive/sites/test.com/trellis/.trellis/virtualenv/bin:/Users/dalbeck/.nvm/versions/node/v17.0.1/bin:/Users/dalbeck/bin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
spaceship_jobs:3: command not found: awk
spaceship_jobs:3: command not found: wc
spaceship_jobs:3: command not found: tr

in AHome File Drive/sites/test.com dalbeck.trellis

dalbeck@Dannys-MacBook-Pro sites % cd test.com
[trellis] activated env
/dev/stdin:export:3: not valid in this context: Drive/sites/test.com/trellis/.trellis/virtualenv/bin:/Users/dalbeck/.nvm/versions/node/v17.0.1/bin:/Users/dalbeck/bin:/usr/local/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin

Let me know if you have any other questions. Again, appreciate the support!

I’m fairly certain you’re running into this issue: trellis new command fails when in directory with spaces and outputs project created · Issue #206 · roots/trellis-cli · GitHub. I never merged the “fix” because I wasn’t confident it wouldn’t something else.

The main path you tried has spaces in it, so it failed. ~/projects/ didn’t so it worked.

So for now, I do suggest using a path without spaces in it. I’ll try to look into that issue again, or just detect/warn people about this unsupported scenario.

2 Likes

@swalkinshaw

That appears to be the issue. I just tested putting a new trellis site in another folder with no spaces in it and it worked.

Thank you for taking the time to help diagnose this.

2 Likes

Update: v1.6.0 is out which supports spaces in paths