Skip to content

fix: provision lua runtime and repair fish activation - #1858

Open
RAprogramm wants to merge 2 commits into
HyDE-Project:devfrom
RAprogramm:1852
Open

fix: provision lua runtime and repair fish activation#1858
RAprogramm wants to merge 2 commits into
HyDE-Project:devfrom
RAprogramm:1852

Conversation

@RAprogramm

@RAprogramm RAprogramm commented Jul 28, 2026

Copy link
Copy Markdown

Pull Request

Description

Closes #1852.

Rebased onto dev after fd70502f and 9db7cf1d landed. Everything those two
already cover is gone from this branch, so what follows describes the diff as
it stands now, not the original scope.

What upstream now covers

Was in this PR Status
Lua environment setup in install_pre.sh dropped, provisioning moved into install.sh
lua and luarocks in deps.toml dropped, already declared
luarocks in pkg_core.lst dropped, already listed

What is left

Activation no longer rejects a runtime the environment manager accepts.
check_lua_runtime looks for lua and luarocks by those exact names:

check_lua_runtime() {
    hyde_has lua || return 1
    hyde_has luarocks || return 1
}

pyutils/lua_env.py resolves versioned binaries too. On a distribution that
ships lua5.4 and luarocks-5.4 without unversioned symlinks, the
environment provisions correctly and activation then refuses it, leaving
HYPRLAND_CONFIG unset with only No valid HyDE configuration found to go
on. Both shell variants now use the same order as lua_env.py: $LUA, then
lua, lua5.5, lua5.4, lua5.3, and $LUAROCKS, then luarocks,
luarocks-5.5, luarocks-5.4, luarocks-5.3. When something really is
missing, the message names it.

A private runtime directory instead of a shared one. Both variants fell
back to XDG_RUNTIME_DIR=/tmp, which puts sockets from every session into one
namespace. The fallback now prefers /run/user/$(id -u) when it exists and is
writable, and otherwise creates ${TMPDIR:-/tmp}/hyde-$(id -u) with mode 700.

pkg_core.lst gains lua. Only luarocks was listed there; the
interpreter itself was missing.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (non-breaking change; modified files are limited to the documentations)
  • Technical debt (a code change that does not fix a bug or add a feature but makes something clearer for devs)
  • Other (provide details below)

Checklist

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My commit message follows the commit guidelines.
  • I have added necessary comments/documentation to my code.
  • I have tested my code locally and it works as expected.
  • All new and existing tests passed.

Testing

Syntax: sh -n activate, fish -n activate.fish — both clean. activate is
clean under shellcheck at error severity.

Behaviour, in an isolated environment with a stubbed PATH:

Setup POSIX activate activate.fish
only lua5.4 and luarocks-5.4 present accepted accepted
unversioned absent, $LUA and $LUAROCKS set accepted accepted
neither present Lua runtime incomplete, missing: lua luarocks same

Runtime directory: with /run/user present both shells report
/run/user/1000; with a stubbed id returning an unused uid both fall back to
the private directory, created drwx------.

Verified against Hyprland 0.56.1 on Arch Linux.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Improved runtime directory selection to prefer a writable per-user runtime folder, with a safer fallback when unavailable.
    • Enhanced Lua/LuaRocks detection by checking for multiple executable candidates and environment overrides.
    • Added more precise Lua runtime error reporting that lists exactly what’s missing.
  • Bug Fixes

    • Made environment (XDG and session) variables set consistently and exported by default across shell types.
    • Updated Lua-mode setup to fail cleanly with the improved missing-component details.
  • Chores

    • Added Lua to the core dependency list.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e0df1280-49cd-401b-adcc-4a7d584424aa

📥 Commits

Reviewing files that changed from the base of the PR and between e7eae81 and 2625e00.

📒 Files selected for processing (3)
  • Configs/.local/lib/hyde/shell/activate
  • Configs/.local/lib/hyde/shell/activate.fish
  • Scripts/pkg_core.lst
🚧 Files skipped from review as they are similar to previous changes (3)
  • Scripts/pkg_core.lst
  • Configs/.local/lib/hyde/shell/activate.fish
  • Configs/.local/lib/hyde/shell/activate

📝 Walkthrough

Walkthrough

The activation scripts now select per-user XDG runtime directories, export session defaults in fish, resolve Lua and LuaRocks through ordered candidates, and report missing runtime components. The core package list adds Lua as a dependency.

Changes

Lua runtime activation

Layer / File(s) Summary
Runtime directories and session exports
Configs/.local/lib/hyde/shell/activate, Configs/.local/lib/hyde/shell/activate.fish
Activation selects writable per-user runtime directories, while fish exports XDG and session defaults unconditionally.
Lua dependency discovery and validation
Scripts/pkg_core.lst, Configs/.local/lib/hyde/shell/activate, Configs/.local/lib/hyde/shell/activate.fish
Lua is added to core dependencies; activation resolves Lua executables and reports specific missing components before failing Lua mode setup.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Activation
  participant check_lua_runtime
  participant LuaResolvers
  participant stderr
  Activation->>check_lua_runtime: validate Lua runtime
  check_lua_runtime->>LuaResolvers: resolve lua and luarocks
  LuaResolvers-->>check_lua_runtime: return paths or missing components
  check_lua_runtime->>stderr: print detailed missing list
  check_lua_runtime-->>Activation: return success or failure
Loading

Possibly related PRs

  • HyDE-Project/HyDE#1851: Adds luarocks to the core package list, complementing this PR’s Lua runtime validation.

Suggested labels: bug

Poem

A bunny found Lua beneath the moon,
And gave runtime paths a private room.
“Missing rocks?” the shell will say,
While XDG hops the safer way.
Core packages now bloom in tune.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title clearly summarizes the main Lua runtime and fish activation fixes.
Linked Issues check ✅ Passed The PR addresses the remaining issue by improving Lua activation diagnostics and dependency handling; provisioning changes were noted as upstream.
Out of Scope Changes check ✅ Passed All changes stay within Lua runtime detection, activation behavior, and related dependency setup.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Configs/.local/lib/hyde/shell/activate.fish`:
- Around line 13-17: Update the XDG_RUNTIME_DIR fallback in the activation setup
to avoid assigning the shared /tmp directory. Use a validated per-user runtime
directory instead, or fail with an actionable diagnostic when none is available;
leave the other XDG_* defaults unchanged.
- Around line 13-17: The XDG variable initialization in the activation script
does not export values that already exist in Fish scopes. Update each affected
XDG assignment, including the session-variable block noted in the review, to
select the existing value or default first, then explicitly set the final value
with set -gx so child processes receive it.

In `@Scripts/install_pre.sh`:
- Around line 45-55: Use the same Lua executable-resolution contract everywhere:
update Scripts/install_pre.sh lines 45-55 to honor the LUA and LUAROCKS
overrides and versioned executables, or delegate preflight validation to
lua_env.py; update Configs/.local/lib/hyde/shell/activate lines 73-90 and
Configs/.local/lib/hyde/shell/activate.fish lines 64-77 to apply the identical
resolution logic during activation, preserving consistent behavior across
installation and both shell types.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 402e8398-84d3-47c6-8461-5e7813f8d70d

📥 Commits

Reviewing files that changed from the base of the PR and between 0259579 and 649812b.

📒 Files selected for processing (5)
  • Configs/.local/lib/hyde/shell/activate
  • Configs/.local/lib/hyde/shell/activate.fish
  • Scripts/dots/deps.toml
  • Scripts/install_pre.sh
  • Scripts/pkg_core.lst

Comment thread Configs/.local/lib/hyde/shell/activate.fish Outdated
Comment thread Scripts/install_pre.sh Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Configs/.local/lib/hyde/shell/activate`:
- Around line 22-35: The runtime-directory fallbacks must fail closed instead of
exporting a predictable or improperly secured path. In
Configs/.local/lib/hyde/shell/activate lines 22-35, update
hyde_runtime_dir/setup_xdg to create a unique owner-private directory atomically
or validate its owner and mode, return failure when setup or hardening fails,
and avoid assigning XDG_RUNTIME_DIR in that case. Apply the equivalent secure
creation/validation and failure guard in
Configs/.local/lib/hyde/shell/activate.fish lines 21-35, preventing set -gx
XDG_RUNTIME_DIR after failure.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6c2dd7ef-5058-4892-84ad-b6055bf0f682

📥 Commits

Reviewing files that changed from the base of the PR and between 649812b and e29d241.

📒 Files selected for processing (3)
  • Configs/.local/lib/hyde/shell/activate
  • Configs/.local/lib/hyde/shell/activate.fish
  • Scripts/install_pre.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • Scripts/install_pre.sh

Comment on lines +22 to +35
_dir="${TMPDIR:-/tmp}/hyde-${_uid:-$$}"
mkdir -p "$_dir" 2>/dev/null && chmod 700 "$_dir" 2>/dev/null
printf '%s\n' "$_dir"
unset _uid _dir
}

setup_xdg() {
: "${XDG_CONFIG_HOME:=$HOME/.config}"
: "${XDG_CACHE_HOME:=$HOME/.cache}"
: "${XDG_DATA_HOME:=$HOME/.local/share}"
: "${XDG_STATE_HOME:=$HOME/.local/state}"

# fallback only
: "${XDG_RUNTIME_DIR:=/tmp}"
[ -n "${XDG_RUNTIME_DIR:-}" ] || XDG_RUNTIME_DIR=$(hyde_runtime_dir)

@coderabbitai coderabbitai Bot Jul 28, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Secure runtime-directory creation and fail closed in both activation scripts. Both fallbacks accept a predictable path under $TMPDIR and export it even if permission hardening fails, allowing a pre-created directory to become the session runtime namespace.

  • Configs/.local/lib/hyde/shell/activate#L22-L35: create a unique owner-private directory atomically (or validate owner/mode) and return failure without exporting it when setup fails.
  • Configs/.local/lib/hyde/shell/activate.fish#L21-L35: apply the equivalent secure creation/validation and prevent set -gx XDG_RUNTIME_DIR after failure.
📍 Affects 2 files
  • Configs/.local/lib/hyde/shell/activate#L22-L35 (this comment)
  • Configs/.local/lib/hyde/shell/activate.fish#L21-L35
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Configs/.local/lib/hyde/shell/activate` around lines 22 - 35, The
runtime-directory fallbacks must fail closed instead of exporting a predictable
or improperly secured path. In Configs/.local/lib/hyde/shell/activate lines
22-35, update hyde_runtime_dir/setup_xdg to create a unique owner-private
directory atomically or validate its owner and mode, return failure when setup
or hardening fails, and avoid assigning XDG_RUNTIME_DIR in that case. Apply the
equivalent secure creation/validation and failure guard in
Configs/.local/lib/hyde/shell/activate.fish lines 21-35, preventing set -gx
XDG_RUNTIME_DIR after failure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

was this handled ? @RAprogramm ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, that line is the fix rather than the old code. The /tmp default is gone:

[ -n "${XDG_RUNTIME_DIR:-}" ] || XDG_RUNTIME_DIR=$(hyde_runtime_dir)

hyde_runtime_dir prefers /run/user/$(id -u) when it exists and is writable, and only otherwise falls back to ${TMPDIR:-/tmp}/hyde-$(id -u) created with mode 700. Same change in activate.fish.

Checked both paths: with /run/user present both shells report /run/user/1000; with a stubbed id returning an unused uid both create the private directory as drwx------.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

@RAprogramm

Copy link
Copy Markdown
Author

All three findings are addressed in e29d241.

Shared runtime directory. /tmp is no longer used as the fallback. hyde_runtime_dir prefers /run/user/$(id -u) when it exists and is writable, and otherwise creates a private ${TMPDIR:-/tmp}/hyde-$(id -u) with mode 700. The POSIX variant carried the same /tmp default, so both are fixed together and stay in step. Checked in an isolated environment: with /run/user present both shells report /run/user/1000; with a stubbed id that returns an unused uid both fall back to the private directory, created as drwx------.

Pre-existing Fish variables. setup_xdg and setup_session now select the existing value or the default first and then assign it with set -gx unconditionally, matching what the POSIX variant does with export. Reproduced the gap before the change: sourcing the previous version with set -g XDG_DATA_HOME … and set -g XDG_CURRENT_DESKTOP Custom leaves both absent from a child's environment; after the change both are present and the pre-existing value is preserved rather than replaced by the default.

Resolution contract. All three shell layers now follow the same order as pyutils/lua_env.py: $LUA, then lua, lua5.5, lua5.4, lua5.3, and $LUAROCKS, then luarocks, luarocks-5.5, luarocks-5.4, luarocks-5.3. install_pre.sh reports each missing binary separately and names the override variable in the hint.

Verified against a stub PATH:

Setup POSIX activate activate.fish install_pre.sh
only lua5.4 and luarocks-5.4 accepted accepted accepted
unversioned binaries absent, $LUA and $LUAROCKS set accepted accepted accepted
neither present Lua runtime incomplete, missing: lua luarocks same No lua interpreter found in PATH with the override hint

@kRHYME7

kRHYME7 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@RAprogramm I somehow tweak a bit the install.sh to use deez-dots for deps installation. it should fix the missing lua situation. but some of your changes are a good guard. Can you resolve the conflict please. thank you!

@kRHYME7

kRHYME7 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@RAprogramm Maybe we can solve this first? I recently push deez-dots for core dependency installation. so lua and luraocks should exist first.

@RAprogramm

Copy link
Copy Markdown
Author

Rebased onto dev, conflict resolved.

Part of this was overtaken by upstream in the meantime, so the branch is now smaller:

Was in this PR Now
Lua environment setup in install_pre.sh dropped — fd70502f moved provisioning into install.sh
lua and luarocks in deps.toml dropped — 9db7cf1d already added both
luarocks in pkg_core.lst dropped — already there

What is left is the part upstream did not cover:

  • shell/activate and shell/activate.fish no longer abort the session when the Lua runtime looks incomplete, and they resolve versioned binaries (lua5.4, luarocks-5.4, …) in the same order as pyutils/lua_env.py, so a runtime the environment manager accepts is not rejected at activation.
  • activate.fish gets a private per-user runtime directory fallback instead of a shared one.
  • pkg_core.lst gains lua itself, which is still missing there — only luarocks was listed.

Both files parse clean and shell/activate is clean under shellcheck at error severity.

@RAprogramm RAprogramm added the bug Something isn't working label Jul 29, 2026
@RAprogramm

Copy link
Copy Markdown
Author

@kRHYME7 agreed, and that part is already out — I dropped the dependency declarations and the install_pre.sh block in the rebase, since deez-dots covers them now. Description above is rewritten to match the diff rather than the original scope.

What is left is only the guard, and one case where it is not just belt and braces: check_lua_runtime looks for the binaries by exact name.

check_lua_runtime() {
    hyde_has lua || return 1
    hyde_has luarocks || return 1
}

pyutils/lua_env.py resolves versioned names too, so on a distribution shipping lua5.4 and luarocks-5.4 without unversioned symlinks the environment provisions fine and activation then refuses it — session comes up with HYPRLAND_CONFIG unset and only No valid HyDE configuration found to go on. Installing the packages does not help there, because the names never match. Both shell variants now follow the same order as lua_env.py and name the missing binary when one really is absent.

The other two are independent of dependency installation: the XDG_RUNTIME_DIR fallback was /tmp, shared across sessions, now a private per-user directory; and pkg_core.lst was missing lua itself, only luarocks was listed.

Happy to cut it down further if you would rather keep just the resolution part.

Comment on lines +22 to +35
_dir="${TMPDIR:-/tmp}/hyde-${_uid:-$$}"
mkdir -p "$_dir" 2>/dev/null && chmod 700 "$_dir" 2>/dev/null
printf '%s\n' "$_dir"
unset _uid _dir
}

setup_xdg() {
: "${XDG_CONFIG_HOME:=$HOME/.config}"
: "${XDG_CACHE_HOME:=$HOME/.cache}"
: "${XDG_DATA_HOME:=$HOME/.local/share}"
: "${XDG_STATE_HOME:=$HOME/.local/state}"

# fallback only
: "${XDG_RUNTIME_DIR:=/tmp}"
[ -n "${XDG_RUNTIME_DIR:-}" ] || XDG_RUNTIME_DIR=$(hyde_runtime_dir)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

was this handled ? @RAprogramm ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants