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

[bug] $projectRoot is rendered with a leading tilde #888

Closed
shellscape opened this issue Jun 5, 2023 · 8 comments
Closed

[bug] $projectRoot is rendered with a leading tilde #888

shellscape opened this issue Jun 5, 2023 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@shellscape
Copy link

shellscape commented Jun 5, 2023

Describe the bug

The $projectRoot variable is being rendered with a leading tilde (~) when interpolated. This is causing issues with third parties which do not automatically expand paths. (e.g. most node package CLIs)

Using bash to expand the result is yielding a negative DX as it requires changing the paradigm of how the task command is constructed.

Steps to reproduce

Using a moon task:

  test:
    command: ava $projectRoot
    inputs:
      - src
      - test

Yields:

[DEBUG 10:47:22] moon_process::command_inspector  Running command node --title svc-test:test ../../node_modules/ava/entrypoints/cli.mjs ~/code/test/services/svc-test

Update: I upgraded to 1.7.1 to see if that had an effect and it looks like there's some more info, but the same bug:

[DEBUG 10:56:47] moon_process::command_inspector  Running command node --title svc-test:test ../../node_modules/ava/entrypoints/cli.mjs ~/code/test/services/svc-test  env_vars={"MOON_PROJECT_SOURCE": "services/svc-test", "MOON_CACHE_DIR": "/Users/user/code/test/.moon/cache", "MOON_TARGET": "svc-test:test", "MOON_PROJECT_RUNFILE": "/Users/user/code/test/.moon/cache/states/svc-test/runfile.json", "MOON_PROJECT_ID": "svc-test", "MOON_WORKSPACE_ROOT": "/Users/user/code/test", "MOON_PROJECT_ROOT": "/Users/user/code/test/services/svc-test", "MOON_TOOLCHAIN_DIR": "/Users/user/.proto", "MOON_WORKING_DIR": "/Users/user/code/test/services/svc-test"} working_dir=/Users/user/code/test/services/svc-test

Note that the MOON_PROJECT_ROOT environment variable is correct but the interpolation result is not.

Expected behavior

I expected moon to render Users/user/code/test/services/svc-test

As an aside; it would be very helpful and useful if the release notes could list the actual things fixed, and link back to their respective PRs/commits. I had looked there before opening this bug and couldn't determine quickly if it had already been addressed in 1.7.1.

Screenshots

n/a

Environment

MacOS Ventura 13.3.1 (22E261)
Moon 1.7.0

Additional context

@milesj
Copy link
Collaborator

milesj commented Jun 5, 2023

@shellscape The logs always replace the home dir with ~. Is this actually happening when the task is executed?

@shellscape
Copy link
Author

yeah I added some logging to Ava's source and it was receiving the tilde

@milesj
Copy link
Collaborator

milesj commented Jun 5, 2023

@shellscape I can't seem to reproduce this 🤔

tasks:
  tilde:
    command: 'echo "$projectRoot"'
[DEBUG 10:30:03] moon_process::command_inspector  Running command /bin/zsh -c 'echo ~/Projects/moon/website'  env_vars={"MOON_PROJECT_SOURCE": "website", "MOON_CACHE_DIR": "/Users/miles/Projects/moon/.moon/cache", "MOON_TARGET": "website:tilde", "MOON_PROJECT_RUNFILE": "/Users/miles/Projects/moon/.moon/cache/states/website/runfile.json", "MOON_PROJECT_ID": "website", "MOON_WORKSPACE_ROOT": "/Users/miles/Projects/moon", "MOON_PROJECT_ROOT": "/Users/miles/Projects/moon/website", "MOON_TOOLCHAIN_DIR": "/Users/miles/.proto", "MOON_WORKING_DIR": "/Users/miles/Projects/moon"} working_dir=/Users/miles/Projects/moon/website
▪▪▪▪ website:tilde
echo /Users/miles/Projects/moon/website (in ./website)
/Users/miles/Projects/moon/website
▪▪▪▪ website:tilde (6ms, 6a6c0645)

Tried it via node also:

tasks:
  tilde2:
    command:
      - node
      - '-e'
      - console.log("$projectRoot")
    platform: 'node'
[DEBUG 10:31:39] moon_process::command_inspector  Running command ~/.proto/tools/node/20.0.0/bin/node --title website:tilde2 -e 'console.log("~/Projects/moon/website")'  env_vars={"MOON_PROJECT_SOURCE": "website", "MOON_CACHE_DIR": "/Users/miles/Projects/moon/.moon/cache", "MOON_TARGET": "website:tilde2", "MOON_PROJECT_RUNFILE": "/Users/miles/Projects/moon/.moon/cache/states/website/runfile.json", "MOON_PROJECT_ID": "website", "MOON_WORKSPACE_ROOT": "/Users/miles/Projects/moon", "MOON_PROJECT_ROOT": "/Users/miles/Projects/moon/website", "MOON_TOOLCHAIN_DIR": "/Users/miles/.proto", "MOON_WORKING_DIR": "/Users/miles/Projects/moon"} working_dir=/Users/miles/Projects/moon/website
▪▪▪▪ website:tilde2
node -e 'console.log("/Users/miles/Projects/moon/website")' (in ./website)
/Users/miles/Projects/moon/website
▪▪▪▪ website:tilde2 (135ms, 9378a904)

@shellscape
Copy link
Author

shellscape commented Jun 5, 2023

Super weird. I'll nuke a few things and see if I can track down the cause.

Update 6/6: I have suspicions. Will be able to dive this deeper tomorrow.

@milesj
Copy link
Collaborator

milesj commented Jun 12, 2023

@shellscape Did you ever figure this out?

@shellscape
Copy link
Author

not as yet. traveling this week so I'm on pause.

@milesj
Copy link
Collaborator

milesj commented Jul 31, 2023

Closing this. Let me know if it's still a problem in v1.11.

@milesj milesj closed this as completed Jul 31, 2023
@shellscape
Copy link
Author

Will do. We're upgrading later this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants