comonicon / Comonicon.jl

Your best CLI generator in JuliaLang
https://comonicon.org
MIT License
282 stars 25 forks source link

use JULIA_DEPOT_PATH as default install path #240

Closed Roger-luo closed 1 year ago

Roger-luo commented 1 year ago

fix #238

MilesCranmer commented 1 year ago

Quick comments:

  1. Should use DEPOT_PATH rather than ENV[JULIA_DEPOT_PATH]. The global variable DEPOT_PATH is automatically populated in Julia and always exists.
  2. Note that DEPOT_PATH is a vector of directories. I think it should go through them until it finds one that is writeable.
Roger-luo commented 1 year ago

Note that DEPOT_PATH is a vector of directories. I think it should go through them until it finds one that is writeable.

I'm not sure how to check if it's writable, it seems there is a filemode function but I didn't find any way of checking path permissions unless we want to do a shell call

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (b3520ed) 82.84% compared to head (1c3089d) 82.84%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #240 +/- ## ======================================= Coverage 82.84% 82.84% ======================================= Files 21 21 Lines 1586 1586 ======================================= Hits 1314 1314 Misses 272 272 ``` | [Impacted Files](https://codecov.io/gh/comonicon/Comonicon.jl/pull/240?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [src/configs.jl](https://codecov.io/gh/comonicon/Comonicon.jl/pull/240?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2NvbmZpZ3Muamw=) | `76.92% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

MilesCranmer commented 1 year ago

I think first(DEPOT_PATH) as you wrote it is a good default strategy.

A more robust option, in case people have populated their JULIA_DEPOT_PATH with non-writeable directories (such as system-wide package registries), is to have path::Union{String,Nothing}=nothing. Then, if it's still nothing at the install step, you could loop through DEPOT_PATH, and wrap the writing in a try-catch. Once it succeeds writing you can exit the loop.

Roger-luo commented 1 year ago

Thanks I'm gonna do the simple fix.