janet-lang / vscode-janet

Janet language support for Visual Studio Code
MIT License
49 stars 14 forks source link

Instructions for building vsix locally #11

Closed foges closed 1 year ago

foges commented 1 year ago

As far as I can tell the documentation for installing this extension is incomplete (ie. just cloning the repo didn't work for me). I ended up following these instructions: https://stackoverflow.com/questions/50714638/install-extension-from-a-specific-repo-branch-on-github, which worked great. Updating the readme to reflect this.

NB: Will make sure to squash and merge.

sogaiu commented 1 year ago

For reference, there is some related discussion starting here.

I very much prefer methods that don't rely on -g.

foges commented 1 year ago

Thanks for the quick feedback sogaiu.

I had looked at the open issues and didn't see anything related to the local install. Didn't think to check the closed issues. It's a good call out to use npx instead. I've tested it with npx and it works fine too. I've updated the PR to now use that instead.

sogaiu commented 1 year ago

@foges Thanks for amending.

I tried to follow the instructions and it didn't quite work for me.

A few tweaks I tried included:

Possibly worth mentioning that Node.js version may matter -- 12.x doesn't work while 14.y does (likely more recent things do too).

foges commented 1 year ago

Sorry about that. I must have mistyped something when I was testing it. I've fixed up your comments and gone through it from top to bottom again.

sogaiu commented 1 year ago

Thanks for the refinements.

When I look at the latest I don't see an instance of npm install vsce.

IIUC, that's still necessary after npm install and before npx vsce package.

Possibly a minor point, but IIUC, cloning into the extension directory is not necessary. May be it makes no difference but it looks like the editor does remove stuff that's in there from time to time.

foges commented 1 year ago

Hmm. It works for me without the npm install vsce just using npx vsce package. That's after having done an npm uninstall vsce and npm uninstall -g vsce on my machine. Having a look online it doesn't seem to me that you first need an npm install, but maybe I'm missing something.

Regarding the directory. Do you mean that vscode might arbitrarily delete files from the extensions directory? I haven't come across that online. As a user I'd think the ~/.vscode/extensions directory would be the most convenient place so that I don't have to keep track of it elsewhere. Happy to change it up if you think another location would be better?

sogaiu commented 1 year ago

Hmm. It works for me without the npm install vsce just using npx vsce package.

Ah sorry. When I tried again, it did work as you described. :+1:

Do you mean that vscode might arbitrarily delete files from the extensions directory?

No, not exactly. It's just that when one uninstalls extensions, corresponding directories get removed (actually it requires a subsequent restart IIUC), so the application is known to remove some things from there, so I'm just hinting at caution.

I don't have the reference but I believe I saw a post about the scenario of cloning stuff to the extensions directory to be one that is not supported (though I'm pretty sure it used to work). If I turn that up again I'll post it here.

sogaiu commented 1 year ago

@foges I poked around a bit more and the following simple steps worked here:

cd ~/.vscode/extensions
git clone https://github.com/janet-lang/vscode-janet
mv extensions.json /tmp/

Then starting VSCode was sufficient.

The trick seemed to be a matter of eliminating extensions.json -- which appears to be created again (with updated content) anyway.

No clue whether there is anything important in that file that one might regret losing though.

foges commented 1 year ago

That indeed worked for me as well. A side effect of that seems to be that now every time when I run npx vsce package vscode cleans up the ~/.vscode/extensions directory and the vscode-janet directory disappears (as you'd previously mentioned). The only thing I've found that works consistently is to clone to the repo in a separate directory and build it there. I'll update the readme to include this.

foges commented 1 year ago

@sogaiu I've updated the PR to reflect your suggestions.

sogaiu commented 1 year ago

@foges Thanks, I took a look and it looks pretty good to me :+1:

foges commented 1 year ago

@sogaiu Awesome. Thank you.

I found that even with building locally sometimes it won't reload and then I still need to remove the extensions.json file. Amended that.

sogaiu commented 1 year ago

That is strange.

Glad there is at least a work-around.