-
Notifications
You must be signed in to change notification settings - Fork 399
Description
Tracer Version(s)
2.23.0
Ruby Version(s)
(All)
Bug Report
I'm opening this as an issue on GitHub in case any customers run into it in v2.23.0 of the datadog gem.
This is a regression in v2.23.0 caused by #4999 . In that PR we added a call to Bundler.bin_path but did not realize that bundler not only returns the path BUT CRUCIALLY it makes sure the path exists, even going as far as trying to create it if it doesn't.
If the directory does not exist, and the application directory is read-only, the application will fail with
There was an error while trying to write to (directory). It is likely that you need to grant write permissions for that path. (Bundler::PermissionError)
Suggested workarounds -- any one of these should make the issue go away:
- Add an empty file
.gitkeepfile in thebin/folder - Revert to version v2.22.0
- Disable profiling 😢
Full example stack trace for the issue:
/usr/share/rubygems-integration/all/gems/bundler-2.4.20/lib/bundler/shared_helpers.rb:105:in `rescue in filesystem_access': There was an error while trying to write to `/usr/src/app/bin`. It is likely that you need to grant write permissions for that path. (Bundler::PermissionError)
from /usr/share/rubygems-integration/all/gems/bundler-2.4.20/lib/bundler/shared_helpers.rb:102:in `filesystem_access'
from /usr/share/rubygems-integration/all/gems/bundler-2.4.20/lib/bundler.rb:120:in `bin_path'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/profiling/collectors/code_provenance.rb:25:in `initialize'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/profiling/component.rb:107:in `new'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/profiling/component.rb:107:in `build_profiler_exporter'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/profiling/component.rb:79:in `build_profiler_component'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/core/configuration/components.rb:135:in `initialize'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/core/configuration.rb:259:in `new'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/core/configuration.rb:259:in `build_components'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/core/configuration.rb:204:in `block in components'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/core/configuration.rb:238:in `block in safely_synchronize'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/core/configuration.rb:237:in `synchronize'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/core/configuration.rb:237:in `safely_synchronize'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/core/configuration.rb:200:in `components'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/profiling.rb:30:in `start_if_enabled'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/profiling/preload.rb:5:in `<top (required)>'
from <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:38:in `require'
from <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:38:in `require'
/usr/share/rubygems-integration/all/gems/bundler-2.4.20/lib/bundler/vendor/fileutils/lib/fileutils.rb:406:in `mkdir': Permission denied @ dir_s_mkdir - /usr/src/app/bin (Errno::EACCES)
from /usr/share/rubygems-integration/all/gems/bundler-2.4.20/lib/bundler/vendor/fileutils/lib/fileutils.rb:406:in `fu_mkdir'
from /usr/share/rubygems-integration/all/gems/bundler-2.4.20/lib/bundler/vendor/fileutils/lib/fileutils.rb:384:in `block (2 levels) in mkdir_p'
from /usr/share/rubygems-integration/all/gems/bundler-2.4.20/lib/bundler/vendor/fileutils/lib/fileutils.rb:382:in `reverse_each'
from /usr/share/rubygems-integration/all/gems/bundler-2.4.20/lib/bundler/vendor/fileutils/lib/fileutils.rb:382:in `block in mkdir_p'
from /usr/share/rubygems-integration/all/gems/bundler-2.4.20/lib/bundler/vendor/fileutils/lib/fileutils.rb:374:in `each'
from /usr/share/rubygems-integration/all/gems/bundler-2.4.20/lib/bundler/vendor/fileutils/lib/fileutils.rb:374:in `mkdir_p'
from /usr/share/rubygems-integration/all/gems/bundler-2.4.20/lib/bundler.rb:120:in `block in bin_path'
from /usr/share/rubygems-integration/all/gems/bundler-2.4.20/lib/bundler/shared_helpers.rb:103:in `filesystem_access'
from /usr/share/rubygems-integration/all/gems/bundler-2.4.20/lib/bundler.rb:120:in `bin_path'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/profiling/collectors/code_provenance.rb:25:in `initialize'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/profiling/component.rb:107:in `new'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/profiling/component.rb:107:in `build_profiler_exporter'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/profiling/component.rb:79:in `build_profiler_component'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/core/configuration/components.rb:135:in `initialize'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/core/configuration.rb:259:in `new'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/core/configuration.rb:259:in `build_components'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/core/configuration.rb:204:in `block in components'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/core/configuration.rb:238:in `block in safely_synchronize'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/core/configuration.rb:237:in `synchronize'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/core/configuration.rb:237:in `safely_synchronize'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/core/configuration.rb:200:in `components'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/profiling.rb:30:in `start_if_enabled'
from /home/dog/.gem/ruby/3.2.0/gems/datadog-2.23.0/lib/datadog/profiling/preload.rb:5:in `<top (required)>'
from <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:38:in `require'
from <internal:/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb>:38:in `require'
Reproduction Code
This can be easily reproduced in a repo checkout with:
$ rm -rf bin/
$ chmod -w .
$ bundle exec rake compile && DD_PROFILING_ENABLED=true bundle exec ruby -rdatadog/profiling/preload -e "puts 'hello'"