Rails does not start up due to LoadError (can't find file that exists) - ruby-on-rails

I'm on an ubuntu 20.04
Had a rails application that used to run until last month.
But a certificate issue made me reinstall nginx and passenger and some dependencies.
However all rails commands (console, server, assets:precompile) are now failing with the following error
/home/deploy/mark_antony/shared/bundle/ruby/2.7.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': libffi.so.6: cannot open shared object file: No such file or directory - /home/deploy/mark_antony/shared/bundle/ruby/2.7.0/gems/ffi-1.13.1/lib/ffi_c.so (LoadError)
But when i check, everything seems perfectly fine.. the file does exist:
deploy#ubuntu-s-1vcpu:~/mark_antony/current$ cd /home/deploy/mark_antony/shared/bundle/ruby/2.7.0/gems/ffi-1.13.1/lib/
deploy#ubuntu-s-1vcpu:~/mark_antony/shared/bundle/ruby/2.7.0/gems/ffi-1.13.1/lib$ ll
total 476
drwxrwxr-x 3 deploy deploy 4096 Jan 7 19:08 ./
drwxrwxr-x 6 deploy deploy 4096 Jan 7 19:07 ../
drwxrwxr-x 4 deploy deploy 4096 Jan 7 19:07 ffi/
-rw-rw-r-- 1 deploy deploy 925 Jan 7 19:07 ffi.rb
-rwxr-xr-x 1 deploy deploy 467872 Jan 7 19:08 ffi_c.so*
Any idea on how to get the app working again?

Related

symfony 5.3 logfile could not be opened in append mode: Failed to open stream (docker)

I have a rotating Logfile configured with monolog, which worked like a charm and suddenly I get error messages stating that the file cannot be created, when the frontend is calling my symfony backend, which runs in a alpine docker container.
Creating logfiles while running my phpunit tests is causing no trouble at all.
This is my monolog configuration, which didn't change:
monolog:
handlers:
frontend:
type: rotating_file
path: "%kernel.logs_dir%/%kernel.environment%.frontend.log"
level: error
channels: [ frontend ]
max_files: 3
main:
type: rotating_file
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: [ "!event", "!frontend", "!deprecation" ]
max_files: 3
console:
type: console
process_psr_3_messages: false
channels: [ "!event", "!doctrine", "!console", "!frontend", "!deprecation" ]
What I did was disabling sessions, which should have no influence on whether the system is able to create a file for writing.
Why can my server no longer write logfiles?
My permissions for my log folder are increased to 777 and the server runs as "root" in it's container:
e9dffe459185:/var/www/var# ll
total 8
drwxrwxr-x 6 root root 192 Jul 22 15:07 ./
drwxr-xr-x 51 root root 1632 Jul 23 10:16 ../
drwxrwxr-x 4 root root 128 Jul 23 11:01 cache/
drwxrwxrwx 3 root root 96 Jul 23 11:02 log/
Looks like the problem was fixed with an update of monolog:
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
- Upgrading monolog/monolog (2.3.1 => 2.3.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Downloading monolog/monolog (2.3.2)
- Upgrading monolog/monolog (2.3.1 => 2.3.2): Extracting archive
Looks like version 2.3.1 was buggy. Since the upgrade I don't have further problems.

Remote server log production.log is empty

Issue: log/production.rb file exists but is empty on production Rails 4.2 environment.
App root and permissions:
drwxrwxr-x 2 deploy deploy 4096 Mar 7 14:59 .
drwxrwxr-x 21 deploy deploy 4096 Mar 7 04:16 ..
-rw-rw-r-- 1 deploy deploy 0 Feb 6 17:13 .git_keep
-rw-rw-r-- 1 deploy deploy 95833941 Mar 9 05:16 newrelic_agent.log
-rwxrwxrwx 1 deploy deploy 80 Mar 9 01:16 production.log
-rw------- 1 deploy deploy 129287 Mar 7 08:24 production.searchd.log
-rw------- 1 deploy deploy 93957 Mar 9 05:06 production.searchd.query.log
-rw------- 1 deploy deploy 5 Feb 7 10:37 production.sphinx.pid
config/environments/production.rb
# If you have no front-end server that supports something like X-Sendfile,
# just comment this out and Rails will serve the files
config.log_level = :info
# Basic log config, for calls to Rails.logger.<level> { <message> }
config.logger = Logger.new('log/production.log')
# Formats log entries into: LEVEL MESSAGE
# Heroku adds to this timestamp and worker/dyno id, so datetime can be stripped
config.logger.formatter = ->(severity, datetime, progname, msg) { "#{severity} #{msg}\n" }
# Lograge config, overrides default instrumentation for logging ActionController and ActionView logging
config.lograge.enabled = true
Help please. Thank you for advance

Gradle error when building the android-support-test project

I'm trying to build the Android Support Testing project. I'm following these instructions. I've got my build env setup and I've synced the Repo. When I try to build the project I get this error.
$ pwd
/Volumes/android/android-support-test
$ ls -l
-r--r--r-- 1 me staff 87 Feb 5 12:56 Makefile
-rw-r--r-- 1 me staff 749 Feb 5 16:14 android-support-test.iml
drwxr-xr-x 11 me staff 374 Feb 5 12:56 build
lrwxr-xr-x 1 me staff 31 Feb 5 12:57 build.gradle -> frameworks/testing/build.gradle
drwxr-xr-x 16 me staff 544 Feb 5 12:57 external
drwxr-xr-x 4 me staff 136 Feb 5 12:57 frameworks
drwxr-xr-x 3 me staff 102 Feb 5 16:14 gradle
-r-xr-xr-x 1 me staff 5884 Feb 5 12:57 gradlew
lrwxr-xr-x 1 me staff 35 Feb 5 12:57 local.properties -> frameworks/testing/local.properties
drwxr-xr-x 3 me staff 102 Feb 5 16:17 out
drwxr-xr-x 7 me staff 238 Feb 5 12:57 prebuilts
lrwxr-xr-x 1 me staff 34 Feb 5 12:57 settings.gradle -> frameworks/testing/settings.gradle
$ ./gradlew assembleDebug
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: http://gradle.org/docs/2.5/userguide/gradle_daemon.html.
Configuration on demand is an incubating feature.
FAILURE: Build failed with an exception.
* Where:
Build file '/Volumes/android/android-support-test/frameworks/testing/build.gradle' line: 16
* What went wrong:
A problem occurred evaluating root project 'android-support-test'.
> Could not read script '/Volumes/android/android-support-test/version.gradle' as it does not exist.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.31 secs
The version.gradle file is in /Volumes/android/android-support-test/frameworks/testing but build.gradle is looking for it in /Volumes/android/android-support-test.
I think the aliasing of build.gradle -> frameworks/testing/build.gradle is not working correctly. Am I missing something?
The frameworks/testing Repo project should have contained an additional sym link, but you can just create it yourself:
ln -s frameworks/testing/version.gradle version.gradle
h/t to John Lombardo on the Android Testing Support Library google group

Buck build failing for "events-logs" Gerrit plugin (jar)

I am trying to build Gerrit plugin "events-log" jar ( https://gerrit.googlesource.com/plugins/events-log) via Buck build, but its failing with below error:
root#jenkins-test:~/events-log# ll
drwxr-xr-x 7 root root 4096 Jun 29 13:25 ./
drwxrwxr-x 24 root root 4096 Jun 29 13:22 ../
-rw-r--r-- 1 root root 1017 Jun 29 12:57 BUCK
-rw-r--r-- 1 root root 173 Jun 29 12:57 .buckconfig
drwxr-xr-x 3 root root 4096 Jun 29 13:25 .buckd/
drwxr-xr-x 6 root root 4096 Jun 29 13:05 buck-out/
drwxr-xr-x 8 root root 4096 Jun 29 13:27 .git/
-rw-r--r-- 1 root root 146 Jun 29 12:57 .gitignore
drwxr-xr-x 5 root root 4096 Jun 29 12:57 lib/
drwxr-xr-x 4 root root 4096 Jun 29 12:57 src/
root#jenkins-test:~/events-log# /root/buck/bin/buck build events-log:events-
log
Using buckd.
BUILD FAILED: No build file at events-log/BUCK when resolving target
//events-log:events-log.
Can somebody please tell how to fix it and build the jar.
Thanks
I think I've finally figured it out ...
What I wound up doing is checking out Gerrit and building the events-log plugin in the Gerrit tree.
git clone https://gerrit.googlesource.com/gerrit
cd gerrit
git co v2.11.2
git submodule init
git submodule update
git clone https://gerrit.googlesource.com/plugins/events-log plugins/events-log
buck build plugins/events-log
I'm pretty sure you just want /root/buck/bin/buck build //:events-log. See http://buckbuild.com/concept/build_target.html
Eventually I found src/main/resources/Documentation/build.md, with which I finally succeeded in building events-log:
git clone https://gerrit.googlesource.com/plugins/events-log
git clone https://gerrit.googlesource.com/bucklets
cd events-log
git checkout stable-2.12
ln -s ../bucklets .
ln -s bucklets/buckversion .buckversion
ln -s bucklets/watchmanconfig .watchmanconfig
buck build plugin
This builds buck-out/gen/events-log.jar.
If the version is 2.14 or later, please use bazle to build
And I also try to build v2.13 with buck, you need to modify gerrit_plugin.bucklet which is under bucklets folder
Old content:
target_suffix = ''):
from multiprocessing import cpu_count
from os import path,getcwd
New content:
target_suffix = ''):
with allow_unsafe_import():
from multiprocessing import cpu_count
from os import path,getcwd
Then execute "buck build plugin
Out put:
ruhu#CCM-P700:~/tools/events-log$ buck build plugin
Download http://repo1.maven.org/maven2/com/google/code/gson/gson/2.3.1/gson-2.3.1-sources.jar
Download http://repo1.maven.org/maven2/com/google/code/gson/gson/2.3.1/gson-2.3.1.jar
Download http://repo1.maven.org/maven2/com/google/gerrit/gerrit-plugin-api/2.13/gerrit-plugin-api-2.13.jar
Parsing buck files: finished in 1.3 sec (100%)
Creating action graph: finished in 1.6 sec (100%)
Building: finished in 03:47.3 min (100%) 19/19 jobs, 19 updated, 94.7% cache mis
Total time: 03:50.3 min

Why is capistrano using git clone always

I have some basic issues with capistrano deployment. First of all, I need to know whether capistrano is using git clone even for the second or third when the git repo is already existing. Is there any issue if it uses git pull? I have added set :deploy_via, :remote_cache in my capfile. I am asking this because I tried adding a new file in the path in the server, and not in the git repo as it was a server specific file. The next time I deployed using capistrano, the file disappeared. It seems like capistrano is using git clone even when a git repo is already created. Why cant capistrano use git pull to update the code?
Capistrano creates a new subdirectory in realeases for each release like this
horse:releases xxx$ ls -lart
total 0
drwxrwxr-x 22 xxx staff 748 Jun 26 20:08 20120626180809
drwxrwxr-x 22 xxx staff 748 Jun 26 20:11 20120626181103
drwxrwxr-x 22 xxx staff 748 Jun 26 20:29 20120626182908
drwxrwxr-x 22 xxx staff 748 Jun 26 20:34 20120626183442
drwxrwxr-x 22 xxx staff 748 Jun 26 20:35 20120626183525
drwxrwxr-x 8 xxx staff 272 Jun 27 13:11 .
drwxrwxr-x 22 xxx staff 748 Jun 27 13:11 20120627111102
drwxrwxr-x 5 xxx staff 170 Jun 27 13:11 ..
and then simply sets a symlink to the current release like this
horse:deployed xxx$ ls -lart
total 8
drwxrwxr-x 4 xxx staff 136 Jun 26 19:51 ..
drwxrwxr-x 7 xxx staff 238 Jun 26 20:22 shared
drwxrwxr-x 8 xxx staff 272 Jun 27 13:11 releases
lrwxrwxr-x 1 xxx staff 70 Jun 27 13:11 current -> /Users/xxx/RailsDeployment/server/deployed/releases/20120627111102
This way, rollback of the deployment on the server is really easy as you just have to change the symlink back to the last (working) deployment, but as a new complete subdir is created each time it makes sense using git clone instead of git pull.
If you want to have server-specific files, you have to add a capistrano deploy task to your config/deploy.rb file to copy it from somewhere else outside the app directory (typically the shared subfolder). The reason for this is that the deployment should be fully automatic and document all necessary steps in an automated procedure, and not depend on files on the server that were put there manually as this is the first step to a snowflake server. So, if you need a file that is not part of your git repository, as typically something containing production passwords, you need to change config/deploy.rb to copy this file to where you need it. To see how to do this look at the copy_db_credentials tasks in my deploy.rb:
namespace :deploy do
desc "cause Passenger to initiate a restart"
task :restart do
run "touch #{current_path}/tmp/restart.txt"
end
desc "Copies database credentials"
task :copy_db_credentials do
run "cp #{shared_path}/credentials/database.yml #{current_path}/config/database.yml"
end
desc "reload the database with seed data"
task :seed do
run "cd #{current_path}; rake db:seed RAILS_ENV=#{rails_env}"
end
end
after :deploy, "deploy:copy_db_credentials"
after "deploy:update_code", :bundle_install
desc "install the necessary prerequisites"
task :bundle_install, :roles => :app do
run "cd #{release_path} && bundle install"
end

Resources