Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage of source in the ahoy terminal #104

Closed
Corey-Lylyk opened this issue Mar 14, 2023 · 3 comments
Closed

Usage of source in the ahoy terminal #104

Corey-Lylyk opened this issue Mar 14, 2023 · 3 comments
Labels

Comments

@Corey-Lylyk
Copy link

Is your feature request related to a problem? Please describe.
I have a need to run source venv/bin/activate and I had run it in a sub command but I can't find a way to get it to run in the ahoy terminal. It is piped in bash and thats not the desired goal

I have tried source ahoy py activate that runs the subcommand but no success, is there a way for this to work?

@ocean
Copy link
Collaborator

ocean commented Mar 23, 2023

@Corey-Lylyk Hmm, can you give me a bit more information about what you're trying to run?

E.g. are you running this source command as part of a string of other commands, where you want the virtualenv to be active for those other commands?

@Corey-Lylyk
Copy link
Author

Yeah originally I'm using the command
source ./my_release_script.sh
and I would like to use something like
ahoy release

the ahoy file would have:

ahoyapi: v2
commands:
  release:
    cmd: source my_release_script.sh
    usage: Runs my_release_script.

I need the script to run in the ahoy command terminal

@ocean
Copy link
Collaborator

ocean commented May 3, 2023

@Corey-Lylyk Each command that ahoy runs is run inside a separate bash -c "<your-command-here>" subroutine, so if you run your source command outside that, it will not pick up the same environment variables when inside the bash subroutine.

I'm not sure I'm explaining this very clearly (and I'm not the original author of ahoy so I don't have complete domain knowledge), but I think you should be able to achieve what you want by making your my_release_script.sh have a shebang line (that is, start with #!/bin/bash) and be executable, and then running something like:

ahoyapi: v2
commands:
  release:
    cmd: |
      source venv/bin/activate &&
      ./my_release_script.sh
    usage: Runs my_release_script.

Notice that the command is now broken over multiple lines for ease of reading. In the first line the Python virtualenv is activated, then the Bash logical operator (&&) is used to make sure your release script command on the next line is only run if the virtualenv activation ran successfully.

@ocean ocean added question and removed enhancement labels May 3, 2023
@ocean ocean closed this as completed Aug 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants