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 ability to customize the hidden dir path #8

Open
next-jesusmanuelnavarro opened this issue Sep 14, 2024 · 1 comment
Open

Add ability to customize the hidden dir path #8

next-jesusmanuelnavarro opened this issue Sep 14, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@next-jesusmanuelnavarro
Copy link
Collaborator

next-jesusmanuelnavarro commented Sep 14, 2024

BME tracks status, some project configurations, etc. under the hardcoded directory "${BME_PROJECT_DIR}/${BME_HIDDEN_DIR}/" (and also under "~/${BME_HIDDEN_DIR}/").

This has shown to be a problem under one usecase of mine: when taking advantage of the python virtualenvs module and sharing a project root's directory between a host and a container, it may happen that the built virtualenv is not compatible between both so when entering into the project space from the host, it creates a virtualenv that can't be used within the container and vice versa. I suppose this can also happen with other modules architecture-dependent, like the terraform one.

I think it'd be good if the project's hardcoded directory could be overwritten, say, by an environment variable, so the one from the host doesn't overlap with the one used within the container. This could mean some more wasted space and maybe some other directory to be added to .gitignore but I consider this to be a reasonable trade off.

WORKAROUND: right now I delete the offending directory each time I start my container but this leads to virtualenvs having to be rebuilt each time I go in and out of my container.

@next-jesusmanuelnavarro next-jesusmanuelnavarro added the enhancement New feature or request label Sep 14, 2024
@jmnavarrol jmnavarrol changed the title Add ability to customize the hidden dir Add ability to customize the hidden dir path Sep 14, 2024
@jmnavarrol
Copy link
Owner

jmnavarrol commented Sep 14, 2024

A possible workaround (still didn't consider all possible side effects):

Setting the environment variable BME_HIDDEN_DIR to a new value different to its '.bme.d' default should do the expected.

I.e.: within the project's .bme_project file you could do something like this (possibly adding some logic about when to set or not the new value):

(...)
old_hidden_dir="${BME_HIDDEN_DIR}"
BME_HIDDEN_DIR='.bme.different'

bme_custom_clean() {
	bme_log "Custom cleaning..." info 1
	BME_HIDDEN_DIR="${old_hidden_dir}"
	unset old_hidden_dir
	bme_log "Custom cleaning finished" info 1
}

Since it's set at session start, when BME is first loaded, global BME_CONFIG_DIR value should be preserved (pointing to ~/.bme.d) but the project's hidden dir would be set before any module is loaded so it would set and use the new value.

The value is properly restored before going out the project space with the help of bme_custom_clean() function.

BEWARE: I still didn't properly test this, but as of now I don't see any obvious drawback.

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

No branches or pull requests

2 participants