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

auto-run ucm sometimes starts in wrong directory #18

Open
sellout opened this issue Feb 7, 2025 · 0 comments
Open

auto-run ucm sometimes starts in wrong directory #18

sellout opened this issue Feb 7, 2025 · 0 comments

Comments

@sellout
Copy link

sellout commented Feb 7, 2025

When ucm is auto-run by the extension, it doesn’t run from the directory of the file that triggered ucm, resulting in commands like edit writing to the wrong location.

replication

  1. Open a non-Unison workspace in VS Code.
  2. Make sure the Unison extension has unison.automaticallyOpenUCM set to true.
  3. Open or create a scratch.u file in a different directory.

At this point, ucm should auto-run in a terminal. However, it runs from the directory of the non-Unison workspace. And so edit, etc. will not use the scratch file you opened, but create a new one elsewhere.

notes

If you open VS Code without a workspace, or in a workspace with an existing scratch.u that you are using, it works fine, because the terminal will start in the expected directory, but there are cases where the terminal’s directory doesn’t match the directory we’d like ucm to run from.

solution

Change the launch command from ucm to cd "$(dirname FILE)"; ucm (or use && instead of ; – not sure what the best behavior is if the cd fails somehow).

Alternatively, we could add an option like --scratch-file /path/to/scratch.u or --watch-dir /path/to/to ucm and have the launch command be ucm --watch-dir "$(dirname FILE)". I like this option because it makes ucm more independent of its run context, but it does require more work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant