Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Fix installer on linux using system ruby (#13273)
Damian Legawiecdbefad2a03a4
diff --git a/install.sh b/install.shindex 41a1a7c199..7a07b0b967 100755--- a/install.sh+++ b/install.sh@@ -346,15 +346,15 @@ install_system_deps() {elif [ "$OS" = "linux" ]; thenif [ "$DISTRO" = "ubuntu" ] || [ "$DISTRO" = "debian" ]; then- print_info "Installing libvips-dev..."+ print_info "Installing development dependencies..."run_with_status "Running: apt-get update" sudo apt-get update- run_with_status "Running: apt-get install runtime deps" sudo apt-get install -y build-essential libvips-dev libssl-dev libreadline-dev zlib1g-dev libsqlite3-dev+ run_with_status "Running: apt-get install runtime deps" sudo apt-get install -y build-essential git libvips-dev libssl-dev libreadline-dev zlib1g-dev libsqlite3-dev libyaml-devprint_success "System dependencies installed"elif [ "$DISTRO" = "fedora" ] || [ "$DISTRO" = "rhel" ] || [ "$DISTRO" = "centos" ]; then- print_info "Installing vips development packages..."- run_with_status "Running: dnf/yum install runtime deps" sudo dnf install -y vips vips-devel gcc gcc-c++ make openssl-devel readline-devel zlib-devel sqlite-devel || \- sudo yum install -y vips vips-devel gcc gcc-c++ make openssl-devel readline-devel zlib-devel sqlite-devel+ print_info "Installing development packages..."+ run_with_status "Running: dnf/yum install runtime deps" sudo dnf install -y vips vips-devel gcc gcc-c++ make openssl-devel readline-devel zlib-devel sqlite-devel libyaml-devel git || \+ sudo yum install -y vips vips-devel gcc gcc-c++ make openssl-devel readline-devel zlib-devel sqlite-devel libyaml-devel gitprint_success "System dependencies installed"else@@ -531,7 +531,15 @@ install_ruby() {if [ "$RUBY_MAJOR" -ge 3 ]; thenprint_success "Ruby $CURRENT_RUBY is already installed"- return 0++ # Still need to configure user gem installation if using system Ruby+ GEM_DIR=$(gem environment gemdir 2>/dev/null || echo "")+ if [[ "$GEM_DIR" == /var/lib/* ]] || [[ "$GEM_DIR" == /usr/lib/* ]]; then+ print_info "Configuring user gem installation (system Ruby detected)"+ # Will configure below+ else+ return 0+ fielseprint_warning "Current Ruby version $CURRENT_RUBY is too old (need >= 3.0)"fi@@ -549,6 +557,55 @@ install_ruby() {print_info "Please install Ruby 3.0+ manually from: https://www.ruby-lang.org/en/documentation/installation/"exit 1fi++ # Configure gem to install to user directory (avoids need for sudo)+ print_info "Configuring user gem installation..."+ RUBY_VERSION=$(ruby -e 'puts RbConfig::CONFIG["ruby_version"]')+ USER_GEM_HOME="$HOME/.gem/ruby/$RUBY_VERSION"++ # Add gem configuration to shell profiles+ GEM_CONFIG="# Ruby gem user installation+export GEM_HOME=\"\$HOME/.gem/ruby/$RUBY_VERSION\"+export GEM_PATH=\"\$HOME/.gem/ruby/$RUBY_VERSION:/var/lib/gems/$RUBY_VERSION\"+export PATH=\"\$HOME/.gem/ruby/$RUBY_VERSION/bin:\$PATH\""++ # Add to bashrc (primary config file for Ubuntu/Debian)+ if [ -f ~/.bashrc ]; then+ if ! grep -q "GEM_HOME.*\.gem/ruby" ~/.bashrc; then+ echo "" >> ~/.bashrc+ echo "$GEM_CONFIG" >> ~/.bashrc+ print_info "Added gem configuration to ~/.bashrc"+ fi+ fi++ # Add to bash_profile if it exists+ if [ -f ~/.bash_profile ]; then+ if ! grep -q "GEM_HOME.*\.gem/ruby" ~/.bash_profile; then+ echo "" >> ~/.bash_profile+ echo "$GEM_CONFIG" >> ~/.bash_profile+ print_info "Added gem configuration to ~/.bash_profile"+ fi+ fi++ # Add to zshrc if it exists+ if [ -f ~/.zshrc ]; then+ if ! grep -q "GEM_HOME.*\.gem/ruby" ~/.zshrc; then+ echo "" >> ~/.zshrc+ echo "$GEM_CONFIG" >> ~/.zshrc+ print_info "Added gem configuration to ~/.zshrc"+ fi+ fi++ # Set for current session+ export GEM_HOME="$USER_GEM_HOME"+ export GEM_PATH="$USER_GEM_HOME:/var/lib/gems/$RUBY_VERSION"+ export PATH="$USER_GEM_HOME/bin:$PATH"++ # Create gem directory if it doesn't exist+ mkdir -p "$USER_GEM_HOME"++ RUBY_CONFIGURED=true+ hash -r 2>/dev/null || truefi# Verify Ruby installation and version@@ -592,6 +649,16 @@ install_rails() {hash -r 2>/dev/null || truefi+ # On Linux, ensure user gem paths are set+ if [ "$OS" = "linux" ]; then+ RUBY_VERSION=$(ruby -e 'puts RbConfig::CONFIG["ruby_version"]')+ USER_GEM_HOME="$HOME/.gem/ruby/$RUBY_VERSION"+ export GEM_HOME="$USER_GEM_HOME"+ export GEM_PATH="$USER_GEM_HOME:/var/lib/gems/$RUBY_VERSION"+ export PATH="$USER_GEM_HOME/bin:$PATH"+ mkdir -p "$USER_GEM_HOME"+ fi+# Check if Rails is already installedif command_exists rails; thenCURRENT_RAILS=$(rails --version | awk '{print $2}')@@ -636,6 +703,16 @@ create_rails_app() {hash -r 2>/dev/null || truefi+ # On Linux, ensure user gem paths are set+ if [ "$OS" = "linux" ]; then+ RUBY_VERSION=$(ruby -e 'puts RbConfig::CONFIG["ruby_version"]')+ USER_GEM_HOME="$HOME/.gem/ruby/$RUBY_VERSION"+ export GEM_HOME="$USER_GEM_HOME"+ export GEM_PATH="$USER_GEM_HOME:/var/lib/gems/$RUBY_VERSION"+ export PATH="$USER_GEM_HOME/bin:$PATH"+ mkdir -p "$USER_GEM_HOME"+ fi+# Download template if running from URL, or use local if existsTEMPLATE_FILE="template.rb"if [ ! -f "$TEMPLATE_FILE" ]; then@@ -781,6 +858,15 @@ show_final_instructions() {hash -r 2>/dev/null || truefi+ # On Linux, ensure user gem paths are set+ if [ "$OS" = "linux" ]; then+ RUBY_VERSION=$(ruby -e 'puts RbConfig::CONFIG["ruby_version"]')+ USER_GEM_HOME="$HOME/.gem/ruby/$RUBY_VERSION"+ export GEM_HOME="$USER_GEM_HOME"+ export GEM_PATH="$USER_GEM_HOME:/var/lib/gems/$RUBY_VERSION"+ export PATH="$USER_GEM_HOME/bin:$PATH"+ fi+bin/devfi}@@ -814,13 +900,13 @@ main() {create_rails_appshow_final_instructions- # On macOS, automatically start a new shell with updated PATH if Homebrew Ruby was configured- # (Only needed for Homebrew Ruby since that's when we modify shell profiles)- if [ "$OS" = "macos" ] && [ "$USING_HOMEBREW_RUBY" = true ] && [ "$RUBY_CONFIGURED" = true ]; then+ # Automatically start a new shell with updated PATH if Ruby/gem paths were configured+ # (Only needed when we modify shell profiles - Homebrew Ruby or gem bin paths)+ if [ "$RUBY_CONFIGURED" = true ]; thensleep 1# Detect user's shell and start it with updated environment- USER_SHELL="${SHELL:-/bin/zsh}"+ USER_SHELL="${SHELL:-/bin/bash}"if [[ "$USER_SHELL" == *"zsh"* ]]; thenexec /bin/zsh -l