theme-tools icon indicating copy to clipboard operation
theme-tools copied to clipboard

Extension errors without a git repository

Open skelouse opened this issue 11 months ago • 4 comments

Describe the bug Without a .git config the extension searches for "//.config" and errors continuously with "[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")"

Expected behaviour No errors

Actual behaviour Many errors

Debugging information

  • Ubuntu 24.04.1 LTS
  • Theme Check Version [3.5.0, 3.4.0]

skelouse avatar Jan 17 '25 18:01 skelouse

I couldn't recreate this error after i deleted my .git directory in my theme. Did you create this theme by running shopify theme init? Also, are you running the extension in VSCode or are you running a language server manually?

aswamy avatar Jan 21 '25 21:01 aswamy

I ran into this error. This error occurs when you are missing all 3 of these things: shopify.extension.toml, .theme-check.yml, and .git. The extension is trying to find the root of the project, and relies on one of these files being there to do so. Without them, it will end up going to the filesystem root, and the rootUri will look like this: file:///. It will then try to recursively find files ending with .extension.toml. On my Windows machine, this leads to attempting to read file:////$Recycle.Bin, which triggers the error. The problem with this URI is that the drive letter is missing, which causes 2 slashes to exist at the beginning of the file path.

You might be wondering: Why don't I have these files? The answer is that I'm not trying to work with a Shopify theme. I'm trying to work with a Shopify email template that uses the liquid syntax, which I have saved into a file on my desktop. More specifically, I want to re-format the file automatically, as the default indentation is awful for finding out where a very large section ends. This re-format isn't working (there's another issue about that), so I figured it may be related to the errors that the extension is spewing, which led me here.

I will try to work around this for now, but this ought to be fixed. A failure to find the project root or a config file should be reported as such, and not as a confusing UriError about the path beginning with 2 slashes.

johnw-bluemark avatar Feb 27 '25 21:02 johnw-bluemark

@johnw-bluemark bro you save my day 😄

StreakingMan avatar Mar 27 '25 03:03 StreakingMan

Possible long term solution would be to add a new "unknown" mode here: https://github.com/Shopify/theme-tools/blob/main/packages/theme-check-common/src/types.ts#L33

If that mode is selected we would disable certain features like multi-file checks, translation completion, etc.

graygilmore avatar Sep 17 '25 18:09 graygilmore