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

Add handling of REBAR_CACHE_DIR env variable #457

Merged
merged 7 commits into from
Sep 10, 2023

Conversation

x0id
Copy link
Contributor

@x0id x0id commented Aug 21, 2023

The REBAR_CACHE_DIR should be separated between releases to avoid unexpected dialyzer errors caused by cached files from previous "rebar3 dialyzer" runs.
By default rebar3 uses ~/.cache/rebar3, this caused problems in different kerl environments.

Description

Handling of the REBAR_CACHE_DIR variable was added the same way as it was done for REBAR_PLT_DIR.

Closes #<issue>.

@x0id x0id force-pushed the add-rebar-cache-dir branch from 3d547c3 to 954f19f Compare August 21, 2023 02:34
@paulo-ferraz-oliveira
Copy link
Contributor

@jadeallenx, I'd like to have #452 approved and merged before I go for #454, then #455, then this one, as I'm sure there'll be conflicts.

@x0id, thanks for this. A couple of comments:

  • would you mind porting this to fish and csh?
    • if you do mind, would you create a task for this port to be done at a later date? (then maybe I can tackle it)?
  • maybe you'll want to wait on the previous action I mentioned - approve + merge
  • I think this solution is acceptable, though I wonder what'll happen to e.g. plugins that use rebar3's cache directly (I didn't look into rebar3 to see how the path to the folder is exposed - but I know for sure there are plugins that depend on it, and it'd be a pity to break local/CI compatibility)
    • in that case, if rebar3's public functions don't take this variable into account (which I would say is oversight, if it happens) maybe we could open an issue there, too?
  • this change is lacking tests - one could e.g. call the activate script on two different installations and make sure the $absdir/.cache/rebar3 folders are populated, have different content

@jadeallenx
Copy link
Collaborator

Yeah this is a great patch, thanks - does need a rebase but I'd hold off until those other two PRs are merged so you don't have to constantly rebase... thank you! ❤️

@x0id
Copy link
Contributor Author

x0id commented Aug 21, 2023

@jadeallenx, I'd like to have #452 approved and merged before I go for #454, then #455, then this one, as I'm sure there'll be conflicts.

@x0id, thanks for this. A couple of comments:

  • would you mind porting this to fish and csh?

what do you mean by that? I added lines to all variants of activate/deactivate including fish and csh I believe

  • if you do mind, would you create a task for this port to be done at a later date? (then maybe I can tackle it)?
  • maybe you'll want to wait on the previous action I mentioned - approve + merge
  • I think this solution is acceptable, though I wonder what'll happen to e.g. plugins that use rebar3's cache directly (I didn't look into rebar3 to see how the path to the folder is exposed - but I know for sure there are plugins that depend on it, and it'd be a pity to break local/CI compatibility)

What I could suggest - making that variable optional. I'll think about it.

  • in that case, if rebar3's public functions don't take this variable into account (which I would say is oversight, if it happens) maybe we could open an issue there, too?

Not sure I'm aware of these details, if you have an example let me know, but I agree with the point.

  • this change is lacking tests - one could e.g. call the activate script on two different installations and make sure the $absdir/.cache/rebar3 folders are populated, have different content

Is there any part of kerl code that is for testing? Sorry, I didn't look too deep so far, so I can't say I understand what is the testing strategy in this project.

@paulo-ferraz-oliveira
Copy link
Contributor

what do you mean by that? I added lines to all variants of activate/deactivate including fish and csh I believe

Right you are. The GitHub diff UI is so small I only saw the bash changes... good stuff!

What I could suggest - making that variable optional. I'll think about it.

I'm Ok as-is, though, as long as rebar3 honours it where it exposes the global cache folder... (later) I checked and it seems it does.

    State5 = case os:getenv("REBAR_CACHE_DIR") of
                false ->
                    State4;
                CachePath ->
                    rebar_state:set(State4, global_rebar_dir, CachePath)
            end,

then later...

global_cache_dir(Opts) ->
    Home = home_dir(),
    rebar_opts:get(Opts, global_rebar_dir, filename:join([Home, ".cache", "rebar3"])).

which I'd say is the "official" exposed function.

Is there any part of kerl code that is for testing? Sorry, I didn't look too deep so far, so I can't say I understand what is the testing strategy in this project.

Look in the GitHub actions file, under .github. I can help you set something up if you're stuck...

@paulo-ferraz-oliveira
Copy link
Contributor

So what's missing now is:

@jadeallenx
Copy link
Collaborator

Once we get this in I'll do a new release <3

x0id added 3 commits September 3, 2023 19:36
The REBAR_CACHE_DIR should be separated between releases
to avoid unexpected dialyzer errors caused by cached files
from previous "rebar3 dialyzer" runs.
Take into account if REBAR_{PLT,CACHE}_DIR was set

If REBAR_CACHE_DIR and REBAR_PLT_DIR were empty, the
corresponding _KERL_SAVED_* are also empty, so cleanup
does not work leaving garbage like this:
_KERL_SAVED_REBAR_CACHED_DIR=
REBAR_CACHED_DIR=/Users/user/kerl/25.2/.cache/rebar3
_KERL_SAVED_REBAR_PLT_DIR=
REBAR_PLT_DIR=/Users/user/kerl/25.2

The fix adds _KERL_REBAR_{PLT,CACHE}_DIR_SET vars to account that
@x0id x0id force-pushed the add-rebar-cache-dir branch from 954f19f to 60ea625 Compare September 4, 2023 00:08
@x0id
Copy link
Contributor Author

x0id commented Sep 4, 2023

I have rebased the PR onto the latest master after adding a couple of cleanup-improving updates.
Will work on the tests...

@x0id
Copy link
Contributor Author

x0id commented Sep 6, 2023

I added tests/activate_test.sh script for testing sh-based activate and kerl_deactivate cleanup. This is a basic test. It may be improved/extended later.
I have also tried to work on the fish version and suddenly realized that the fish-activate/deactivate is far from perfect. The cleanup code just didn't work out of the box - maybe nobody tested it.
My suggestion is to run CI, verify what has been done so far, and merge/release it as is if no problems are found. I can work on validating/improving/testing fish (and csh) versions later in a separate branch/PR.

@jadeallenx
Copy link
Collaborator

I have also tried to work on the fish version and suddenly realized that the fish-activate/deactivate is far from perfect. The cleanup code just didn't work out of the box - maybe nobody tested it.

Undoubtedly true - unless it’s zsh or bash it doesn’t get a lot of love.

My suggestion is to run CI, verify what has been done so far, and merge/release it as is if no problems are found.

ok that seems reasonable

I can work on validating/improving/testing fish (and csh) versions later in a separate branch/PR.

that would be very welcome- thanks!

@paulo-ferraz-oliveira
Copy link
Contributor

Looking good. ❤️ 2 minor changes requested, and a code update suggestion added.

I can work on validating/improving/testing fish (and csh) versions later in a separate branch/PR

Agreed. Would you open an issue for this, referencing your comment, in that case? Thanks. Maybe we can even try do see what an AI would do for "convert this bash to that fish" and then adapt? For tests too, but that's "for the future".

Tests are failing and so is the Lint action. I can help with the lint, if you want, by doing it locally and proposing changes. For the tests, there's very little information, so I'm actually not sure what's breaking: maybe in case of error we could also output the diff?

@x0id
Copy link
Contributor Author

x0id commented Sep 8, 2023

I have fixed lint errors, activate-test integration in CI, and corrected activate/deactivate code slightly.
Now all tests went green (in my account).
https://github.com/x0id/kerl/actions/runs/6121381052

@paulo-ferraz-oliveira
Copy link
Contributor

Looks good to me. I'll wait for @jadeallenx.

@x0id, is the stuff you plan to do identified in the Issues? Or not interesting to have there (e.g. for pre-discussion before a pull request)?

@jadeallenx
Copy link
Collaborator

Let's ship it :) Thanks!

@jadeallenx jadeallenx merged commit 859e549 into kerl:master Sep 10, 2023
@x0id
Copy link
Contributor Author

x0id commented Sep 10, 2023

@x0id, is the stuff you plan to do identified in the Issues? Or not interesting to have there (e.g. for pre-discussion before a pull request)?

Tried to briefly describe in #458.
I have a branch for the fish version already, still WIP.

@paulo-ferraz-oliveira
Copy link
Contributor

Perfect, stuff, thanks much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants