Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting up a mastodon development environment #15863

Closed
fvdnabee opened this issue Mar 8, 2021 · 9 comments
Closed

Setting up a mastodon development environment #15863

fvdnabee opened this issue Mar 8, 2021 · 9 comments

Comments

@fvdnabee
Copy link

fvdnabee commented Mar 8, 2021

While trying to setup a dev environment following https://github.com/tootsuite/documentation/blob/master/content/en/dev/setup.md I've seen the following two issues on my system, when trying to run RAILS_ENV=development rails db:setup.

First issue:
LoadError: cannot load such file -- irb
This was fixed by adding gem 'irb' to the Gemfile and running bundle install.

Second issue:

rake aborted!
NameError: uninitialized constant RubyVM::DebugInspector
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.6.0/lib/bootsnap/load_path_cache/core_ext/active_support.rb:80:in `block in load_missing_constant'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.6.0/lib/bootsnap/load_path_cache/core_ext/active_support.rb:9:in `without_bootsnap_cache'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.6.0/lib/bootsnap/load_path_cache/core_ext/active_support.rb:80:in `rescue in load_missing_constant'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.6.0/lib/bootsnap/load_path_cache/core_ext/active_support.rb:59:in `load_missing_constant'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/binding_of_caller-1.0.0/lib/binding_of_caller/mri.rb:21:in `callers'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/better_errors-2.9.1/lib/better_errors/exception_extension.rb:7:in `set_backtrace'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.6.0/lib/bootsnap/load_path_cache/cache.rb:84:in `raise'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.6.0/lib/bootsnap/load_path_cache/cache.rb:84:in `block in find'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.6.0/lib/bootsnap/load_path_cache/cache.rb:52:in `synchronize'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.6.0/lib/bootsnap/load_path_cache/cache.rb:52:in `find'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.6.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:58:in `load'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/activerecord-5.2.4.5/lib/active_record/railtie.rb:49:in `block in <class:Railtie>'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/railties-5.2.4.5/lib/rails/railtie.rb:246:in `instance_exec'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/railties-5.2.4.5/lib/rails/railtie.rb:246:in `block in run_tasks_blocks'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/railties-5.2.4.5/lib/rails/railtie.rb:255:in `each'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/railties-5.2.4.5/lib/rails/railtie.rb:255:in `each_registered_block'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/railties-5.2.4.5/lib/rails/railtie.rb:246:in `run_tasks_blocks'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/railties-5.2.4.5/lib/rails/application.rb:514:in `block in run_tasks_blocks'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/railties-5.2.4.5/lib/rails/engine/railties.rb:15:in `each'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/railties-5.2.4.5/lib/rails/engine/railties.rb:15:in `each'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/railties-5.2.4.5/lib/rails/application.rb:514:in `run_tasks_blocks'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/railties-5.2.4.5/lib/rails/engine.rb:459:in `load_tasks'
/home/fvdnabee/GIT/mastodon/Rakefile:6:in `<top (required)>'
/home/fvdnabee/GIT/mastodon/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/exe/rake:27:in `<top (required)>'
/usr/bin/bundle:23:in `load'
/usr/bin/bundle:23:in `<main>'

This was circumvented by removing the better_errors and binding_of_caller gems from my Gemfile and running bundle update/install.

I don't know how to fix these issues and whether the blame lies with Arch Linux or mastodon. I would like to know how to fix the second issue, rather than circumvent it.

Expected behaviour

A working development environment as per the documentation.

Actual behaviour

Encountered the issues above.

Steps to reproduce the problem

Try to setup a dev environment under Arch Linux.

Specifications

Master branch.
ruby 2.7.2p137 on Arch Linux.

UPDATE: a bit later I noticed that the streaming server doesn't play along nicely with the latest nodejs version, similar to this issue: #14866 (comment)
It seems to me that docker is the way to go.
UPDATE2: using an older nodejs release via nvm for running the streaming server worked for me. I'm using node v12.16.3, which should be the same as in the mastodon docker image. Arch linux is on node v15.11.

@fvdnabee fvdnabee added the bug Something isn't working label Mar 8, 2021
@Gargron
Copy link
Member

Gargron commented Mar 8, 2021

NameError: uninitialized constant RubyVM::DebugInspector

I have actually never seen this error.

Docker is not the way to go for development (too much overhead to quickly see changes, in my opinion), but it is true that latest Node is unsupported. Perhaps our Vagrant image can help, that is actually meant for development.

@fvdnabee
Copy link
Author

fvdnabee commented Mar 9, 2021

In relation to the DebugInspector error, for one user it was due to a missing C extension. However, the .so file is present on my system [1] so the problem seems to lie elsewhere.

[1]

> /usr/lib/ruby sudo find . -name 'debug_inspector*'                                                                                                                                              ./gems/2.7.0/specifications/debug_inspector-1.0.0.gemspec
./gems/2.7.0/extensions/x86_64-linux/2.7.0/debug_inspector-1.0.0
./gems/2.7.0/extensions/x86_64-linux/2.7.0/debug_inspector-1.0.0/debug_inspector.so
./gems/2.7.0/gems/debug_inspector-1.0.0
./gems/2.7.0/gems/debug_inspector-1.0.0/ext/debug_inspector
./gems/2.7.0/gems/debug_inspector-1.0.0/ext/debug_inspector/debug_inspector.c
./gems/2.7.0/gems/debug_inspector-1.0.0/ext/debug_inspector/debug_inspector.so
./gems/2.7.0/gems/debug_inspector-1.0.0/ext/debug_inspector/debug_inspector.o
./gems/2.7.0/gems/debug_inspector-1.0.0/lib/rubyvm/debug_inspector
./gems/2.7.0/gems/debug_inspector-1.0.0/lib/debug_inspector.rb
./gems/2.7.0/gems/debug_inspector-1.0.0/debug_inspector.gemspec
./gems/2.7.0/cache/debug_inspector-1.0.0.gem

@fvdnabee
Copy link
Author

fvdnabee commented Mar 9, 2021

NameError: uninitialized constant RubyVM::DebugInspector

I have actually never seen this error.

Docker is not the way to go for development (too much overhead to quickly see changes, in my opinion), but it is true that latest Node is unsupported. Perhaps our Vagrant image can help, that is actually meant for development.

Could you elaborate why you consider docker too much overhead for development but find Vagrant an acceptable solution? Vagrant appears much more resource demanding than a containerized alternative, i.e. classic virtual machine vs containers debate. I also wouldn't clasify the default development setup as lightweight, as it requires the developer to run postgres and redis services on their machine. Imo, neither of these options appear to fall under the category 'lightweight'. I'd put native and containerized on the same level with the later being much easier to setup.

@RobinDaugherty
Copy link

Hi, I've been trying to track down the cause of the debug_inspector extension failing to load. As you say, the .so file is in the gem, but the installation rake task is supposed to copy from ext/debug_inspector into lib/ within the gem while it's installing. That works for most people, but I've been unable to determine why it's not working in some situations.

Can you try including debug_inspector using the branch I created for banister/debug_inspector#30 ?

gem 'debug_inspector', git: 'https://github.com/BetterErrors/debug_inspector', branch: 'fix/load-extension-from-ext-dir'

If that fixes the issue for you, I'll cut a new release of debug_inspector.

@fvdnabee
Copy link
Author

@RobinDaugherty thank you for your efforts! I'll try with your branch and get back to you by the end of the day (European timezone).

@fvdnabee
Copy link
Author

fvdnabee commented Mar 16, 2021

@RobinDaugherty thank you for your efforts! I'll try with your branch and get back to you by the end of the day (European timezone).

@RobinDaugherty I can confirm that the NameError: uninitialized constant RubyVM::DebugInspector error is solved using your branch. I'm assuming the library is functioning as intended (mastodon appears to working fine in my browser). Many thanks!

To be complete, these are the contents of Gemfile and Gemfile.lock on my system:

> git diff Gemfile | grep  debug_inspector 
+gem 'debug_inspector', git: 'https://github.com/BetterErrors/debug_inspector', branch: 'fix/load-extension-from-ext-dir'

> git diff Gemfile.lock | grep -C2 debug_inspector
@@ -1,3 +1,10 @@
+GIT
+  remote: https://github.com/BetterErrors/debug_inspector
+  revision: bb70e4a5b7302cfc81192545fe2b9bdda8ce3fef
+  branch: fix/load-extension-from-ext-dir
+  specs:
+    debug_inspector (1.0.0)
+
 GIT
--
+    css_parser (1.9.0)
       addressable
-    debug_inspector (1.0.0)
     devise (4.7.3)
       bcrypt (~> 3.0)
--
   concurrent-ruby
   connection_pool
+  debug_inspector!
   devise (~> 4.7)
   devise-two-factor (~> 3.1)

fvdnabee added a commit to fvdnabee/mastodon that referenced this issue Mar 16, 2021
@RobinDaugherty
Copy link

Excellent! debug_inspector 1.1.0rc1 has been released, which contains that fix.

@ClearlyClaire
Copy link
Contributor

As far as I understand, the blame for both errors falls on ArchLinux from stripping stuff from the default Ruby installation (e.g., irb is in a separate package, which, even when installed, requires the dependency to be explicitly set in the Gemfile even though irb is a “default gem”)

@cassieroyal

This comment has been minimized.

@vmstan vmstan added local development and removed bug Something isn't working labels Nov 20, 2023
@vmstan vmstan converted this issue into discussion #28008 Nov 20, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

6 participants