delayed_job gem - NotImplementedError: fork is not available on this platform - fork

I am using jruby (1.7.3 or 1.7.9), delayed_job (1.8.4), daemons (1.1.9) gems for my rails 2.3.17 application.
I am trying to start the delayed job server using command:
1. jruby script/delayed_job start
Error:
RuntimeError: ObjectSpace is disabled; each_object will only work with Class, pass -X+O to enable
each_object at org/jruby/RubyObjectSpace.java:173
daemonize at /home/user/projects/new_central_repo/mml/mml_services/vendor/gems/delayed_job-1.8.4/lib/delayed/command.rb:39
(root) at script/delayed_job:5
To resolve this error, I passed "-X+O" option & ran following command:
jruby -X+O script/delayed_job start
This has resolved "ObjectSpace is disabled" error but I am getting following error on local.
Error:
NotImplementedError: fork is not available on this platform
fork at org/jruby/RubyKernel.java:1880
safefork at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/daemonize.rb:11
call_as_daemon at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/daemonize.rb:43
start_proc at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/application.rb:259
start at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/application.rb:296
run at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/controller.rb:70
run_proc at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons.rb:197
call at org/jruby/RubyProc.java:290
call at org/jruby/RubyProc.java:224
catch_exceptions at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109
run_proc at /home/user/.rvm/gems/ext-jruby-1.7.9#jruby179-rails2317/gems/daemons-1.1.9/lib/daemons.rb:196
daemonize at /home/user/projects/new_central_repo/mml/mml_services/vendor/gems/delayed_job-1.8.4/lib/delayed/command.rb:45
times at org/jruby/RubyFixnum.java:280
daemonize at /home/user/projects/new_central_repo/mml/mml_services/vendor/gems/delayed_job-1.8.4/lib/delayed/command.rb:43
(root) at script/delayed_job:5
Anyone can help me to resolve this error.
Locally I am able to start my server using "jrake jobs:work" command but I am not whether I can use "jrake jobs:work" instead of "jruby script/delayed_job start".
Thanks.

You cannot use delayed_job on jruby because it relies on Fork which is not available in jruby.

Related

Ruby on Rail running apache show index of when accessing the site

I have recently updated to Apache 2.4, and I am using Ruby on Rail to run my application. Following the upgrade, the site shows a content as seen in the image below, and the error on the log file shows this error message. I have tried using the 'Bundle Install' and checked the permission but that hasn't helped. Any advice would be greatly appreciated. Thanks
[ 2022-02-07 07:47:24.5559 8104/7efc89c8f700 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /home/adminuser/hroot: An error occured while starting up the preloader.
Error ID: ba7e6074
Error details saved to: /tmp/passenger-error-RA01E9.html
Message from application: libmysqlclient.so.18: cannot open shared object file: No such file or directory - /usr/local/rvm/gems/ruby-2.0.0-p353#hroot/gems/mysql2-0.3.14/lib/mysql2/mysql2.so (LoadError)
PassengerRuby /usr/local/rvm/gems/ruby-2.0.0-p353#hroot/wrappers/ruby
SetEnv GEM_HOME /root/.gem/ruby/1.9.1
This error shows a problem with the shared objects. You probably updated MySQL/MariaDB libraries with Apache and new libraries are incompatible with your mysql2 gem build. The solution is simple:
First, ensure you are using the ruby-2.0.0-p353#hroot RVM environment.
Then, execute the following command:
gem install mysql2 --version 0.3.14
This should rebuild your mysql2 gem for the new MySQL/MariaDB client libraries on your system.
this isn't the answer anyway but another method to run ruby (in my case Windows 10 ; if you use another OS try to find out how to modify inside index.php the ruby starter)
i post here an alternative method to use apache + php +... and ruby
https://stackoverflow.com/a/71733656/5781320

electron-forge --template=typescript-webpack cannot compile sqlite3

Using a package that leverages sqlite3. It looks like sqlite3 is not being recompiled properly. searched around and saw people recommending better-sqlite3. This would require me to have to port the sqlite3 code (no db.serialize equivalent). Is there another way to get sqlite3 working?
❯ yarn start
...
App threw an error during load
Error: Cannot open [redacted]/node_modules/sqlite3/lib/binding/node-v83-darwin-x64/node_sqlite3.node: Error: The module '[redacted]/node_modules/sqlite3/lib/binding/node-v83-darwin-x64/node_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 83. This version of Node.js requires
NODE_MODULE_VERSION 80. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
...
ERROR in ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
Module not found: Error: Can't resolve './' in '[redacted]/node_modules/node-pre-gyp/lib'
# ./node_modules/node-pre-gyp/lib/node-pre-gyp.js 52:13-32 184:38-57
# ./node_modules/sqlite3/lib/sqlite3-binding.js
# ./node_modules/sqlite3/lib/sqlite3.js
# ./node_modules/chrome-cookies-secure/index.js
Not a great answer but electron-react-boilerplate supports it by adding sqlite into the /app/package.json.

When running an application under ruby 2.3.1 using the rails server command, the following error occurs: can not modify a frozen array (RuntimeError)

I have to run an application developed in Ruby on rails. ruby 2.3.1 and rails 4.2.0
When I execute the rails server command. I get the following error:
.... config / initializers / doorkeeper.rb: 75: in <top (required)>: can not modify a frozen array (RuntimeError).
Can I explain how to succeed to no longer have this error, thank you
Info :
The "bundle install" command runs successfully.
The code around doorkeepee.rb near line 75 : Doorkeeper.configuration.token_grant_types << "password"
I'm trying to understand how RAIL_ENV works. Can you help me at the same time?

Already initialized constant APP PATH rails

I got this error just after installing devise 3.4.0 gem in my application. When I input rails s in terminal, I get the error below..
[kmartin#localhost register]$ rails s
=> Booting WEBrick
=> Rails 4.2.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
bin/rails:6: warning: already initialized constant APP_PATH
/home/kmartin/work/register/bin/rails:6: warning: previous definition of APP_PATH was here
Usage: rails COMMAND [ARGS]
The most common rails commands are:
generate Generate new code (short-cut alias: "g")
console Start the Rails console (short-cut alias: "c")
server Start the Rails server (short-cut alias: "s")
dbconsole Start a console for the database specified in config/database.yml
(short-cut alias: "db")
new Create a new Rails application. "rails new my_app" creates a
new application called MyApp in "./my_app"
In addition to those, there are:
destroy Undo code generated with "generate" (short-cut alias: "d")
plugin new Generates skeleton for developing a Rails plugin
runner Run a piece of code in the application environment (short-cut alias: "r")
All commands can be run with -h (or --help) for more information.
I actually just changed my devise gem from 3.1. to just gem 'devise' then bundle installed and my problem was solved...It seems the version of devise wasnt supported by rails 4.

How can you tell if running a command through the heroku cli succeeded?

When running a command through heroku, such as:
heroku run rake db:migrate
I would like to know if the command succeeded or not. Unfortunately, even if running the migration fails, I get an exit status of 0.
I'm writing some ruby code that wraps this command and invokes it, and raises an error if the command failed. The code looks like:
Open3.popen2e('heroku run rake db:migrate') do |stdin, stdout_and_stderr, wait_thr|
raise 'running migration failed' unless wait_thr.value.success?
end
Even when running this fails, and I get a message:
rake aborted! StandardError: An error has occurred, this and all later
migrations canceled:
My code itself does not raise an error. Inspecting wait_thr.value in the above code, it has an exit code of 0, which means the heroku CLI believes the rake call succeeded.
How can my code know if the command that was run by the heroku cli failed? Is there a way to tell the heroku CLI to return the status code of the command it ran?
There is now official support for this from their CLI:
heroku help run
Usage: heroku run COMMAND
run an attached dyno
-s, --size SIZE # specify dyno size
--exit-code # return exit code from process
So you would now run:
heroku run --exit-code rake db:migrate
You're not alone with this. Many have complained about this before, check this out:
https://github.com/heroku/heroku/issues/186
You can (dirty) work around the problem with this gem:
https://github.com/glenngillen/heroku-exit-status

Resources