jbangdev / jbang

Unleash the power of Java - JBang Lets Students, Educators and Professional Developers create, edit and run self-contained source-only Java programs with unprecedented ease.
https://jbang.dev
MIT License
1.43k stars 159 forks source link

error when repo dir are not writeable #851

Open mmoser18 opened 3 years ago

mmoser18 commented 3 years ago

Wanted to give jbang a try. I downloaded the .zip, unpacked it and added .../jbang/bin to my path.

Then I started with the tutorial it but I got stalled already on line 2:

> jbang init --template=cli hello.java
[jbang] File initialized. You can now run it with 'jbang hello.java' or edit it using 'jbang edit --open=[editor] hello.java' where [editor] is your editor or IDE, e.g. 'emacs'
> jbang hello.java Michael
[jbang] Resolving dependencies...
[jbang]     Resolving info.picocli:picocli:4.5.0...[jbang] [ERROR] Could not resolve dependency
[jbang] Run with --verbose for more details
>

What am I missing? Or what do I need to add/install/configure to enable jbang to resolve dependencies?

mmoser18 commented 3 years ago

Digging a bit deeper and with the --verbose option revealed that jbang seems to expect to find a directory ~\.m2\repository. That does not exist on my system. In ~\.m2\settings.xml I redirect that to a different drive and directory and I enforce that by having a write-protected file (not directory!) at location ~\.m2\repository. This is because I want to keep repos distinct for different projects. I had more than once the case that different projects affected each other by all using the same local repo-cache! Apparently jbang does not inspect the settings.xml file. Can one teach it somehow to do that?

maxandersen commented 3 years ago

haven't bumped into write protected directory - should check for that and give better error message.

you can set JBANG_REPO environment variable to override the default.

if you are after using different repo per project then using JBANG_REPO env var seems like the best option for you rather than reading central ~.m2\settings.xml would it not ?

mmoser18 commented 3 years ago

yep, that sounds like a good solution. Will use that. Thanks!