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
26 changes: 26 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -747,9 +747,35 @@ namespace :rb do

desc 'Update generated Ruby files for local development'
task :local_dev do
puts 'installing ruby, this may take a minute'
Bazel.execute('build', [], '@bundle//:bundle')
Rake::Task['rb:build'].invoke
Rake::Task['grid'].invoke
Bazel.execute('build', [], '@bundle//bin:rubocop')
manage_selenium_ruby!
end

def manage_selenium_ruby!
label = 'selenium-ruby'

rbenv_path = `command -v rbenv`.strip
rbenv_root = `#{rbenv_path} root`.strip
dest = File.join(rbenv_root, 'versions', label)
return if File.symlink?(dest)

rb_dir = File.join(Dir.pwd, 'rb')
bazel_bin = File.expand_path('../bazel-selenium/external/rules_ruby++ruby+ruby/dist/bin', rb_dir)
bazel_dist = File.dirname(bazel_bin)
FileUtils.ln_s(bazel_dist, dest)
system(rbenv_path, 'rehash')

Dir.chdir(rb_dir) do
system('direnv allow')
system('direnv reload')
system({ "RBENV_VERSION" => label }, 'bundle', 'install')
end
rescue StandardError => e
puts "Unable to set Bazel Selenium as Default: #{e.message}"
end

desc 'Push Ruby gems to rubygems'
Expand Down
18 changes: 18 additions & 0 deletions rb/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Local Ruby environment for Selenium's Bazel-built Ruby
# Safe to check in — only activates if the symlink already exists.

if command -v rbenv >/dev/null 2>&1; then
LABEL=selenium-ruby

RBENV_ROOT_DEFAULT="$(rbenv root 2>/dev/null || echo "$HOME/.rbenv")"
RUBY_SYMLINK="${RBENV_ROOT_DEFAULT}/versions/${LABEL}"
BIN_DIR="${RUBY_SYMLINK}/bin"

# Always track the directory, even if missing now
watch_file "${BIN_DIR}"

# Only set environment variable if directory currently present
if [ -d "${BIN_DIR}" ]; then
export RBENV_VERSION="${LABEL}"
fi
fi
Loading