Skip to content

Conversation

@erdajt
Copy link

@erdajt erdajt commented Jul 25, 2025

Pull Request: Fix BeEF installer permission and PATH issues

Category

Bug

Feature/Issue Description

  1. Permission errors when installing gems to system directories (Ruby gems not added to PATH #3373)

  2. PATH configuration for Bundler executables after gem installation

as referenced at issue #3373 gems werent being added to path after being installed automatically since the bundle gem was referenced/called right after that in the install script it caused the script to crash ok

fixed this and other permission issues that were occurring due to specific user paths and permissions

  1. User-specific gem installation
    Instead of installing gems to system directories (which requires root), we now install to the user's gem directory by:
    • Setting BUNDLE_PATH to the user's gem directory
    • Creating the directory if it doesn't exist
    USER_GEM_HOME=$(ruby${RUBYSUFFIX} -e "require 'rubygems'; puts Gem.user_dir")
    export BUNDLE_PATH="${USER_GEM_HOME}"
    mkdir -p "${USER_GEM_HOME}"
    

Test Cases

Same case as #3373 now fixed
It successfully adds the Gems to PATH and installation is complete

[INFO]  Detecting Ruby environment...
[INFO]  Ruby version 3.4.4 is installed
[INFO]  Detecting bundler gem...
[INFO]  Installing bundler gem...
WARNING:  You don't have /home/erdajtt/.local/share/gem/ruby/3.4.0/bin in your PATH,
	  gem executables (bundle, bundler) will not run.
Successfully installed bundler-2.7.1
Parsing documentation for bundler-2.7.1
Done installing documentation for bundler after 0 seconds
1 gem installed
[INFO]  Added /home/erdajtt/.local/share/gem/ruby/3.4.0/bin to PATH for this session
[INFO]  bundle command is now available in PATH
Installing required Ruby gems...
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Bundle complete! 42 Gemfile dependencies, 83 gems now installed.
Gems in the groups 'development' and 'test' were not installed.
Bundled gems are installed into `/home/erdajtt/.local/share/gem/ruby/3.4.0`
1 installed gem you directly depend on is looking for funding.
  Run `bundle fund` for details

#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#

[INFO]  Install completed successfully!
[INFO]  Run './beef' to launch BeEF

- as referenced at issue beefproject#3373 gems werent being added to path after being installed automatically
since the bundle gem was referenced/called right after that in the install script it caused the script to crash ok

fixed this and other permission issues that were occurring due to specific user paths and permissions
@erdajt erdajt had a problem deploying to Integrate Pull Request July 25, 2025 15:23 — with GitHub Actions Failure
@erdajt erdajt had a problem deploying to Integrate Pull Request August 21, 2025 01:40 — with GitHub Actions Failure
@zinduolis zinduolis requested a review from Copilot August 21, 2025 01:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes permission and PATH issues when installing Ruby gems for BeEF, specifically addressing issue #3373. The changes ensure gems are installed to user directories instead of system locations and properly configure the PATH to make bundle commands available.

  • Refactored bundler detection to use a separate command availability check function
  • Added automatic PATH configuration for user gem directories when bundle command is not found
  • Modified gem installation to use user-specific gem paths instead of system directories

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@erdajt erdajt had a problem deploying to Integrate Pull Request August 21, 2025 01:45 — with GitHub Actions Failure
@zinduolis zinduolis self-requested a review August 21, 2025 01:46
@github-actions
Copy link
Contributor

Stale pull request message

@zinduolis zinduolis temporarily deployed to Integrate Pull Request October 16, 2025 05:50 — with GitHub Actions Inactive
@zinduolis zinduolis temporarily deployed to Integrate Pull Request October 20, 2025 06:09 — with GitHub Actions Inactive
@zinduolis zinduolis temporarily deployed to Integrate Pull Request October 24, 2025 00:19 — with GitHub Actions Inactive
@zinduolis
Copy link
Contributor

Hi @erdajt , thanks for this PR. Could you please review the Copilot suggested changes and accept them if they make sense or reject with the justification? Also, it would be helpful to know the Arch version you this is happening in as I will need to setup a VM for myself to reproduce the issue and see that your fix has solved it.

@erdajt erdajt temporarily deployed to Integrate Pull Request October 29, 2025 13:20 — with GitHub Actions Inactive
@erdajt erdajt temporarily deployed to Integrate Pull Request October 29, 2025 13:21 — with GitHub Actions Inactive
@erdajt erdajt temporarily deployed to Integrate Pull Request October 29, 2025 13:21 — with GitHub Actions Inactive
@erdajt
Copy link
Author

erdajt commented Oct 29, 2025

Hi @erdajt , thanks for this PR. Could you please review the Copilot suggested changes and accept them if they make sense or reject with the justification? Also, it would be helpful to know the Arch version you this is happening in as I will need to setup a VM for myself to reproduce the issue and see that your fix has solved it.

sure, i applied the suggestions, need to have a second look again whenever i have the time

6.16.10-arch1-1 x86_64

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