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

invalid argument when dir has environment variable substitution #561

Closed
culhatsker opened this issue Apr 25, 2024 · 3 comments
Closed

invalid argument when dir has environment variable substitution #561

culhatsker opened this issue Apr 25, 2024 · 3 comments

Comments

@culhatsker
Copy link

Running this simple DAG

env:
  - WDIR: somedir
steps:
  - name: step1
    dir: ${WDIR}
    command: bash
    script: |
      mkdir -p ${WDIR}
      cd ${WDIR}
      pwd

Would yield this result:

2024/04/25 16:43:02 frontend is running at "/tmp/@dagu-test2-00990e9229c3ef5fec5dd68a0ae43e0c.sock"
2024/04/25 16:43:02 start running: step1
2024/04/25 16:43:02 step1 failed
2024/04/25 16:43:02 schedule finished.
2024/04/25 16:43:02 
Summary ->
+--------------------------------------+-------+---------------------+---------------------+--------+--------+------------------+
| REQUESTID                            | NAME  | STARTED AT          | FINISHED AT         | STATUS | PARAMS | ERROR            |
+--------------------------------------+-------+---------------------+---------------------+--------+--------+------------------+
| f340d5a8-3f04-494c-9fe7-5d61d96cbe42 | test2 | 2024-04-25 16:43:02 | 2024-04-25 16:43:02 | failed |        | invalid argument |
+--------------------------------------+-------+---------------------+---------------------+--------+--------+------------------+
Details ->
+---+-------+---------------------+---------------------+--------+---------+------------------+
| # | STEP  | STARTED AT          | FINISHED AT         | STATUS | COMMAND | ERROR            |
+---+-------+---------------------+---------------------+--------+---------+------------------+
| 1 | step1 | 2024-04-25 16:43:02 | 2024-04-25 16:43:02 | failed | bash    | invalid argument |
+---+-------+---------------------+---------------------+--------+---------+------------------+

Running dagu 1.12.11 on Ubuntu 22.04

@yohamta yohamta added bug Something isn't working good first issue Good for newcomers labels Apr 25, 2024
@culhatsker
Copy link
Author

Sorry, while making a minimal reproduction I made a mistake: ${WDIR} does not exist at the moment of running step1 but it depends on it.

Here's another example when the problem occurs:

env:
  - WDIR: ./somedir
steps:
  - name: create dir
    command: bash
    script: |
      rm -rf ${WDIR}
      mkdir -p ${WDIR}
  - name: interact with dir
    dir: ${WDIR}
    command: bash
    script: |
      pwd

But everything works as expected if you change this to:

env:
  - WDIR: ./somedir
steps:
  - name: create dir
    command: bash
    script: |
      rm -rf ${WDIR}
      mkdir -p ${WDIR}
  - name: interact with dir
    command: bash
    script: |
      cd ${WDIR}
      pwd

notice: second step doesn't have dir: ${WDIR} option but has cd ${WDIR} in script

@culhatsker
Copy link
Author

Okay, I realized while trying to debug goroutines (of what I have no experience), that my second example is also bad, because I did not set up the dependency that second step has on the first step.
There's still a bug though, but it feels much less important now as I understand my mistake.

@yohamta yohamta added question confirming and removed bug Something isn't working good first issue Good for newcomers question labels May 11, 2024
@yohamta
Copy link
Collaborator

yohamta commented May 25, 2024

I think that the example needs an adjustment:

env:
  - WDIR: ./somedir
steps:
  - name: create dir
    command: bash
    script: |
      rm -rf ${WDIR}
      mkdir -p ${WDIR}
  - name: interact with dir
    command: bash
    script: |
      cd ${WDIR}
      pwd
+    depends:
+      - create dir

I'd like to close this issue, please reopen if there's more issues.

@yohamta yohamta closed this as completed May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants