Skip to content

Custom build and usage of rucaptcha library #118

@rautniraj

Description

@rautniraj

Hello @huacnlee

I have made some changes like controlling opacity of the background circle. For this i had to build this gem locally so that it can be integrated in my project. I have successfully compiled and generated .so file which is working as needed in my project. Ruby version used is 3.3.0

The issue is my entire application needs to run in a docker setup which uses base image - ruby:3.3.6-alpine3.20

Now integrating in this setup cause issue. I will describe my issue in short..hope i get some solution

Relative path to this rucaptcha folder containing all the code : lib/rucaptcha

Commands i ran to generate .so file

  1. bundle install
  2. bundle exec rake compile && bundle exec rspec spec

(Earlier bundle exec rake compile was giving error as in my machine Ubuntu 20.04 there was no rust and cargo installed. Tracing the error message i inferred that both needs to be installed. So i installed both latest stable version only and then compiling happened perfectly)

Above two commands generated .so file. Here is my directory structure

Image

Now in my gemfile i used this gem as : gem 'rucaptcha', path: 'lib/rucaptcha'

Configuration file is kept as it is, using all the default value. Except for the self.cache_store which is set to redis container.

Above works very well in my development setup. But when building inside my docker it fails. Let me attach the screenshot :

useradmin | Postgres host: db
useradmin | Postgres port: 5432
useradmin | Redis host: redis
useradmin | Redis port: 6379
useradmin | bin/rails aborted!
useradmin | LoadError: Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /usr/src/app/lib/rucaptcha/lib/rucaptcha/rucaptcha.so) - /usr/src/app/lib/rucaptcha/lib/rucaptcha/rucaptcha.so (LoadError)
useradmin | /usr/src/app/vendor/bundle/ruby/3.3.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in require' useradmin | /usr/src/app/vendor/bundle/ruby/3.3.0/gems/zeitwerk-2.7.2/lib/zeitwerk/core_ext/kernel.rb:34:in require'
useradmin | /usr/src/app/lib/rucaptcha/lib/rucaptcha.rb:10:in rescue in <main>' useradmin | /usr/src/app/lib/rucaptcha/lib/rucaptcha.rb:5:in

'

Image

This part of the rucaptcha.rb located inside customgem/rucaptcha/lib/rucaptcha.rb is throwing error

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions