Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added hermit
Binary file not shown.
7 changes: 5 additions & 2 deletions shell/files/activate.tmpl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ export {{ $ENV_NAME }}={{ $ENV_VALUE | Quote }}
{{ end }}

_hermit_deactivate() {
echo "Hermit environment $(${HERMIT_ENV}/bin/hermit env HERMIT_ENV) deactivated"
eval "$(${ACTIVE_HERMIT}/bin/hermit env --deactivate-from-ops="${HERMIT_ENV_OPS}")"
local hermit_exe=${HERMIT_ENV}/bin/hermit
test -e "${hermit_exe}" || hermit_exe=${HERMIT_EXE:-$HERMIT_ROOT_BIN}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure about this line:

  1. Are these the right defaults if the local ${hermit_exe} doesn't exist? i.e. should it first check for $HERMIT_EXE and then $HERMIT_ROOT_BIN?
  2. Should we handle the case where $HERMIT_ROOT_BIN doesn't exist, or is that expected to always be there?
  3. Are there reasons to just not even use defaults in the first place? Should we just skip the (new) line 28, and on 27 just print $HERMIT_ENV if $hermit_exe doesn't exist?

Copy link
Copy Markdown
Contributor

@nickajacks1 nickajacks1 Mar 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2: Yes please! I don't set HERMIT_ROOT_BIN, so this is what it looks like when I nuke the bin folder with this PR:

~/source/hermit$ mv bin/ bin2
Command '' not found, but can be installed with:
sudo apt install mailutils-mh  # version 1:3.14-1, or
sudo apt install mmh           # version 0.4-4
sudo apt install nmh           # version 1.7.1-11
sudo apt install termtris      # version 1.3-1ubuntu1
Hermit environment  deactivated
Command '' not found, but can be installed with:
sudo apt install mailutils-mh  # version 1:3.14-1, or
sudo apt install mmh           # version 0.4-4
sudo apt install nmh           # version 1.7.1-11
sudo apt install termtris      # version 1.3-1ubuntu1

It tries to execute '', which gives these confusing command-not-found messages (on Ubuntu).
If deactivate-hermit can't find a hermit executable, there's not much it can do, but perhaps a little message warning that it couldn't cleanly deactivate would be helpful.

3: Using HERMIT_EXE and HERMIT_ROOT_EXE as backups makes sense to me, but if they aren't found, your idea would fix my issue I mentioned above.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we expect people to have HERMIT_ROOT_BIN so we probably need to deal with it missing as well

echo "Hermit environment $("${hermit_exe}" env HERMIT_ENV) deactivated"
eval "$("${hermit_exe}" env --deactivate-from-ops="${HERMIT_ENV_OPS}")"
unset -f deactivate-hermit >/dev/null 2>&1
unset -f update_hermit_env >/dev/null 2>&1
unset ACTIVE_HERMIT
Expand Down Expand Up @@ -62,6 +64,7 @@ if test -n "${PS1+_}"; then export _HERMIT_OLD_PS1="${PS1}"; export PS1="{{if eq
{{- end}}

update_hermit_env() {
if test ! -e "${HERMIT_ENV}/bin/hermit"; then deactivate-hermit; return; fi
local CURRENT=$(date -r ${HERMIT_ENV}/bin +"%s")
test "$CURRENT" = "$HERMIT_BIN_CHANGE" && return 0
local CUR_HERMIT=${HERMIT_ENV}/bin/hermit
Expand Down