getappmap / appmap-ruby

AppMap client agent for Ruby
https://appland.org
Other
100 stars 13 forks source link

Error running Rails Application with AppMap Installed on Centos Stream 9 with system ruby #354

Closed kgilpin closed 3 months ago

kgilpin commented 8 months ago
An error occurred while running the command: bundle exec appmap-agent-init
The command exited with code 1
> bundler: failed to load command: appmap-agent-init (/usr/bin/appmap-agent-init)
> /usr/share/gems/gems/appmap-1.0.0/lib/appmap.rb:79:in `<top (required)>': undefined method `recording_enabled?' for AppMap:Module (NoMethodError)
> from /usr/share/gems/gems/appmap-1.0.0/exe/appmap-agent-init:5:in `require'
> from /usr/share/gems/gems/appmap-1.0.0/exe/appmap-agent-init:5:in `<top (required)>'
> from /usr/bin/appmap-agent-init:25:in `load'
> from /usr/bin/appmap-agent-init:25:in `<top (required)>'
> from /usr/local/share/gems/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:58:in `load'
> from /usr/local/share/gems/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:58:in `kernel_load'
> from /usr/local/share/gems/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:23:in `run'
> from /usr/local/share/gems/gems/bundler-2.4.19/lib/bundler/cli.rb:492:in `exec'
> from /usr/local/share/gems/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
> from /usr/local/share/gems/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
> from /usr/local/share/gems/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
> from /usr/local/share/gems/gems/bundler-2.4.19/lib/bundler/cli.rb:34:in `dispatch'
> from /usr/local/share/gems/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
> from /usr/local/share/gems/gems/bundler-2.4.19/lib/bundler/cli.rb:28:in `start'
> from /usr/local/share/gems/gems/bundler-2.4.19/exe/bundle:37:in `block in <top (required)>'
> from /usr/local/share/gems/gems/bundler-2.4.19/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
> from /usr/local/share/gems/gems/bundler-2.4.19/exe/bundle:29:in `<top (required)>'
> from /usr/local/bin/bundle:23:in `load'
> from /usr/local/bin/bundle:23:in `<main>'
petecheslock commented 7 months ago

Steps to recreate the issue.

Using a CentOS Stream version 9 running on a virtual machine.
Using the mainline branch from this Rails project: https://github.com/land-of-apps/rails-test-project

System ruby on Stream 9 uses 3.0.4 - so i updated the Gemfile to support

ruby "3.0.4"
 ruby -v
ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [aarch64-linux]

Then add AppMap to the Gemfile and bundle install

gem 'appmap', :groups => [:development, :test]

Bundle install should complete sucessfully.

Now run bundle exec rails server

You will get the following error:

$ bundle exec rails server
/home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/appmap-1.0.0/lib/appmap/agent.rb:12:in `require_relative': cannot load such file -- /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/appmap-1.0.0/lib/appmap/appmap (LoadError)
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/appmap-1.0.0/lib/appmap/agent.rb:12:in `<main>'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/appmap-1.0.0/lib/appmap.rb:24:in `<main>'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /home/centos/.local/share/gem/ruby/gems/bundler-2.3.22/lib/bundler/runtime.rb:60:in `block (2 levels) in require'
        from /home/centos/.local/share/gem/ruby/gems/bundler-2.3.22/lib/bundler/runtime.rb:55:in `each'
        from /home/centos/.local/share/gem/ruby/gems/bundler-2.3.22/lib/bundler/runtime.rb:55:in `block in require'
        from /home/centos/.local/share/gem/ruby/gems/bundler-2.3.22/lib/bundler/runtime.rb:44:in `each'
        from /home/centos/.local/share/gem/ruby/gems/bundler-2.3.22/lib/bundler/runtime.rb:44:in `require'
        from /home/centos/.local/share/gem/ruby/gems/bundler-2.3.22/lib/bundler.rb:187:in `require'
        from /home/centos/rails-test-project/config/application.rb:7:in `<main>'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/railties-7.0.4/lib/rails/commands/server/server_command.rb:137:in `block in perform'
        from <internal:kernel>:90:in `tap'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/railties-7.0.4/lib/rails/commands/server/server_command.rb:134:in `perform'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/railties-7.0.4/lib/rails/command/base.rb:87:in `perform'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/railties-7.0.4/lib/rails/command.rb:48:in `invoke'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/railties-7.0.4/lib/rails/commands.rb:18:in `<main>'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /home/centos/rails-test-project/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.12.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from bin/rails:4:in `<main>'
petecheslock commented 7 months ago

Additional testing internally

Coming back to this - still not entirely sure what is with this path issue with require_relative But i will still hit it with APPMAP=false > https://gist.github.com/petecheslock/0ebe798652c1c3d4b110b2ab513c9e70

if i do require_relative "../appmap" - i can get the app to start with APPMAP false

Screenshot 2024-04-01 at 4 11 46 PM (1)

but running with appmap true will cause new problems. which kinda makes sense. https://gist.github.com/petecheslock/facc43532f68488b244c9402e1b143de

petecheslock commented 7 months ago

Ok - this seems to be directly related to the system ruby on Centos Stream 9 (although i can not tell you why).

Using ASDF to install ruby 3.1.2 - Works as expected, no error

Using ASDF to install the same version of ruby as the system ruby 3.0.4 - Works as expected, no error

So there is clearly some problem with the version of ruby that comes via installation using Centos package managers.

Recommend for users who find this github issue is to install another version of ruby using rbenv or asdf and not use the system ruby available from centos upstream package managers.

These are the affected versions

ruby.aarch64                                     3.0.4-161.el9                    @appstream    
ruby-default-gems.noarch                         3.0.4-161.el9                    @appstream    
ruby-devel.aarch64                               3.0.4-161.el9                    @appstream    
ruby-libs.aarch64                                3.0.4-161.el9                    @appstream