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] moon console VSCode extension unable to find moon binary. #1170

Closed
mctrafik opened this issue Nov 9, 2023 · 12 comments
Closed

[bug] moon console VSCode extension unable to find moon binary. #1170

mctrafik opened this issue Nov 9, 2023 · 12 comments
Assignees
Labels
bug Something isn't working

Comments

@mctrafik
Copy link

mctrafik commented Nov 9, 2023

Describe the bug

No matter what I tried, the VSCode extension doesn't find the workspace root.

Steps to reproduce

Not sure. My dir tree:

/Users/user/coding/workspace/project
 - .moon
    - workspace.xml etc
 - typescript
    - node_modules
      - moon stuff

But moon is installed using a bash script, so it's at: /Users/user/.moon/bin/moon. The extension asks for relative paths. Which is all very confusing. I tried pasting absolute path as well as relative to project. Nothing happens.

I tried finding any logs in the extensions host but there weren't any from the extension.

Expected behavior

I expect it to detect the moon workspace in the root of the repo. And if not, for there to be debug logs in the extension host that would be helpful for troubleshooting.

Screenshots

Screenshot 2023-11-08 at 5 05 58 PM

@mctrafik mctrafik added the bug Something isn't working label Nov 9, 2023
@milesj
Copy link
Collaborator

milesj commented Nov 9, 2023

@mctrafik

For the moon binary, it's probably finding it since we fallback to the global: https://github.com/moonrepo/dev/blob/master/packages/vscode-extension/src/moon.ts#L13

As for the workspace root, is the vscode root === the moon root? That should just work: https://github.com/moonrepo/dev/blob/master/packages/vscode-extension/src/moon.ts#L37

@mctrafik
Copy link
Author

mctrafik commented Nov 9, 2023

I'm not sure how to answer. I have many folders in my workspace.

But I've tried both . and ./my-specific-package as workspace root var with no results. Is there a way to force re-init or see init logs? I've been trying to do restart extension host but don't see any results in the moon extension from that.

@milesj
Copy link
Collaborator

milesj commented Nov 9, 2023

I'm not entirely sure how to debug a vscode extension. There's no logging in the extension itself, so if vscode doesn't provide anything, then we have nothing at the moment.

No one else has reported this issue. What vscode and moon versions?

@mctrafik
Copy link
Author

Okay, so I did some digging, and I'm pretty sure this is the bug:

https://github.com/moonrepo/dev/blob/master/packages/vscode-extension/src/extension.ts#L8

  const workingDir = vscode.workspace.workspaceFolders?.[0];
  const workspaceRoot = workingDir ? await findWorkspaceRoot(workingDir) : null;

I was very confused by the whole workspaceRoot concept because I have many repositories in my workspace. Looks like the extension only looks at the first folder in the workspace. My moonrepo based repository isn't the first one.

Oddly enough, I did try to set my workspace root to ../myOtherFolder but it still didn't find it. Too tired to keep troubleshooting now.

For context on making logs for the extension. In your code I was able to define a variable const extOut = vscode.window.createOutputChannel('moon'); and then I was able to make log statements like extOut.appendLine('INFO: Activating extension.');

@milesj
Copy link
Collaborator

milesj commented Nov 10, 2023

Can you briefly talk about/outline your repository structure, where moon is setup, and what folder youre opening with vscode, so that I can get a better picture?

@mctrafik
Copy link
Author

mctrafik commented Nov 11, 2023

Sure. I think what's missing here is that I have many folders in my workspace. I.e. my workspace is created by starting a blank workspace and then adding multiple folders to it via Add folder to workspace... button.

image

Now, for me, all of the repositories are in the same folder and I have a workspace folder for my vscode with the following structure:

/Users/user/workspace/
 - repo1-common/
 - repo2-apps/
 - repo3-shared-monorepo/ (using moon)

It is the third repo/folder that I'm trying to use moon at. It has structure like:

/Users/user/workspace/repo3-shared-monorepo/
 - .moon/
 --- workspace.yml
 --- tasks.yml
 - java/
 - shell/
 - typescript/
 --- package.json
 --- moon.yml (typescript root).

A tricky thing here that I'm reporting is that if my moom experiment goes well, I'll probably convert repo1-common to use moon as well eventually, which means a search for the moon binary will yield multiple resuts, but for now it would be nice if it found the only one.

@milesj
Copy link
Collaborator

milesj commented Nov 12, 2023

Ok yeah, right now the extension kind of assumes that you're opening it at the root of the moon workspace, but this is like a parent folder up. It should be easy enough to support, so let me tinker around a bit with it.

@milesj
Copy link
Collaborator

milesj commented Nov 14, 2023

@mctrafik Quick question, so setting the moon.workspaceRoot vscode setting to "./repo3-shared-monorepo" did not work?

@mctrafik
Copy link
Author

That's correct. That doesn't work.

@milesj
Copy link
Collaborator

milesj commented Nov 15, 2023

That's wild :o

@MadsLasso
Copy link

I have about the same problem as mctrafik. We have projects nested fairly deeply nested away from the monorepo/moon root, and prefer to open the individual project folder in VSCode. So I need to go upwards in the "Workspace Root" config path, something ../../../., but haven't been able to get it to work. I have managed to get it to work for the Bin Path, when using proto rather than npm, this path works ../../Users/Mads/.moon/bin/moon.

@milesj
Copy link
Collaborator

milesj commented Dec 31, 2023

This PR will support multiple workspace folders: moonrepo/dev#61

@milesj milesj closed this as completed Dec 31, 2023
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

3 participants